Version Notes
For installation and configuration instructions, as well as a full list of new features and known issues, please review the Implementation Guide.
Download this release
Release Info
Developer | Chris Geiss |
Extension | Bronto_Extension |
Version | 2.1.0 |
Comparing to | |
See all releases |
Code changes from version 2.0.4.2 to 2.1.0
- app/code/community/Bronto/Common/Block/Adminhtml/System/Config/About.php +12 -2
- app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Cron.php +141 -18
- app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field.php +7 -2
- app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Apitoken.php +26 -68
- app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Debug.php +60 -0
- app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Download.php +58 -0
- app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Image.php +36 -0
- app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/List.php +1 -2
- app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Support.php +21 -0
- app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Support/Site.php +28 -0
- app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Fieldset.php +21 -0
- app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Support.php +36 -0
- app/code/community/Bronto/Common/Block/Adminhtml/Widget/Button/Abstract.php +41 -0
- app/code/community/Bronto/Common/Block/Adminhtml/Widget/Button/Debug.php +13 -0
- app/code/community/Bronto/Common/Block/Adminhtml/Widget/Button/Download.php +12 -0
- app/code/community/Bronto/Common/Helper/Contact.php +5 -5
- app/code/community/Bronto/Common/Helper/Data.php +628 -217
- app/code/community/Bronto/Common/Helper/DataInterface.php +1 -1
- app/code/community/Bronto/Common/Helper/Field.php +4 -4
- app/code/community/Bronto/Common/Helper/Message.php +31 -14
- app/code/community/Bronto/Common/Helper/Product.php +14 -10
- app/code/community/Bronto/Common/Helper/Support.php +446 -0
- app/code/community/Bronto/Common/Model/Api.php +5 -5
- app/code/community/Bronto/Common/Model/Archive.php +73 -0
- app/code/community/Bronto/Common/Model/Email/{Message.php → Template.php} +119 -63
- app/code/community/Bronto/Common/Model/Email/{Message → Template}/Filter.php +182 -120
- app/code/community/Bronto/Common/Model/Email/{Message → Template}/Templatefilter.php +27 -58
- app/code/community/Bronto/Common/Model/Keysentry.php +55 -25
- app/code/community/Bronto/Common/Model/Observer.php +146 -4
- app/code/community/Bronto/Common/Model/Resource/Setup.php +1 -1
- app/code/community/Bronto/Common/Model/System/Config/Backend/Cron.php +32 -18
- app/code/community/Bronto/Common/Model/System/Config/Backend/Enable.php +32 -0
- app/code/community/Bronto/Common/Model/System/Config/Backend/Token.php +16 -7
- app/code/community/Bronto/Common/Model/System/Config/Source/Contact/Status.php +3 -3
- app/code/community/Bronto/Common/Model/System/Config/Source/Cron/Frequency.php +6 -6
- app/code/community/Bronto/Common/Model/System/Config/Source/Cron/Minutes.php +3 -3
- app/code/community/Bronto/Common/Model/System/Config/Source/Field.php +6 -6
- app/code/community/Bronto/Common/Model/System/Config/Source/Image.php +22 -0
- app/code/community/Bronto/{Order → Common}/Model/System/Config/Source/Limit.php +6 -6
- app/code/community/Bronto/Common/Model/System/Config/Source/List.php +2 -2
- app/code/community/Bronto/Common/Model/System/Config/Source/Message.php +1 -1
- app/code/community/Bronto/Common/Model/System/Config/Source/Role.php +31 -0
- app/code/community/Bronto/Common/Model/System/Config/Source/Synclimit.php +23 -0
- app/code/community/Bronto/Common/Test/Config/Config.php +0 -171
- app/code/community/Bronto/Common/Test/Model/Checkout.php +0 -187
- app/code/community/Bronto/Common/Test/Model/Keysentry.php +0 -70
- app/code/community/Bronto/Common/Test/Model/Keysentry/fixtures/seed.yaml +0 -3
- app/code/community/Bronto/Common/controllers/Adminhtml/DebugController.php +88 -0
- app/code/community/Bronto/Common/controllers/LogController.php +4 -4
- app/code/community/Bronto/Common/etc/adminhtml.xml +2 -1
- app/code/community/Bronto/Common/etc/config.xml +46 -21
- app/code/community/Bronto/Common/etc/system.xml +185 -3
- app/code/community/Bronto/ConflictChecker/Block/Adminhtml/System/Config/About.php +0 -54
- app/code/community/Bronto/ConflictChecker/Block/Adminhtml/System/Config/Conflictchecker.php +0 -88
- app/code/community/Bronto/ConflictChecker/Block/Printer.php +0 -77
- app/code/community/Bronto/ConflictChecker/Helper/Data.php +0 -34
- app/code/community/Bronto/ConflictChecker/Model/Config/Blocks.php +0 -69
- app/code/community/Bronto/ConflictChecker/Model/Config/Checker.php +0 -64
- app/code/community/Bronto/ConflictChecker/Model/Config/ConfigAbstract.php +0 -125
- app/code/community/Bronto/ConflictChecker/Model/Config/ConfigInterface.php +0 -46
- app/code/community/Bronto/ConflictChecker/Model/Config/Helpers.php +0 -69
- app/code/community/Bronto/ConflictChecker/Model/Config/Models.php +0 -68
- app/code/community/Bronto/ConflictChecker/Model/Config/Printer.php +0 -58
- app/code/community/Bronto/ConflictChecker/Model/Config/Resources.php +0 -69
- app/code/community/Bronto/ConflictChecker/Model/Core/Config/Base.php +0 -50
- app/code/community/Bronto/ConflictChecker/Model/Lib/Varien/Simplexml/Config.php +0 -46
- app/code/community/Bronto/ConflictChecker/Model/Mysql4/Core/Config.php +0 -35
- app/code/community/Bronto/ConflictChecker/Model/Path/Locator/Factory.php +0 -55
- app/code/community/Bronto/ConflictChecker/Model/Path/Locator/IteratorAbstract.php +0 -60
- app/code/community/Bronto/ConflictChecker/Model/Path/Locator/LocatorInterface.php +0 -63
- app/code/community/Bronto/ConflictChecker/Test/Config/Config.php +0 -259
- app/code/community/Bronto/ConflictChecker/Test/Model/Path/Locator/Array.php +0 -25
- app/code/community/Bronto/ConflictChecker/Test/Model/Path/Locator/Factory.php +0 -21
- app/code/community/Bronto/ConflictChecker/Test/Model/Path/Locator/Stack.php +0 -25
- app/code/community/Bronto/ConflictChecker/etc/adminhtml.xml +0 -32
- app/code/community/Bronto/ConflictChecker/etc/config.xml +0 -60
- app/code/community/Bronto/ConflictChecker/etc/system.xml +0 -32
- app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/About.php +1 -1
- app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Cron.php +44 -10
- app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Fieldset/Attributes.php +80 -69
- app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Fieldset/Attributes/Address.php +2 -1
- app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Fieldset/Attributes/Customer.php +2 -1
- app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Reset.php +6 -2
- app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Run.php +2 -2
- app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Sync.php +3 -11
- app/code/community/Bronto/Customer/Helper/Data.php +167 -59
- app/code/community/Bronto/Customer/Model/Mysql4/Queue.php +12 -3
- app/code/community/Bronto/Customer/Model/Mysql4/Queue/Collection.php +13 -12
- app/code/community/Bronto/Customer/Model/Observer.php +195 -102
- app/code/community/Bronto/Customer/Model/Queue.php +73 -36
- app/code/community/Bronto/Customer/Model/Resource/Customer.php +1 -1
- app/code/community/Bronto/Customer/Model/System/Config/Backend/Brontofield.php +6 -6
- app/code/community/Bronto/Customer/Model/System/Config/Backend/Cron.php +1 -1
- app/code/community/Bronto/Customer/Model/System/Config/Backend/Newfield.php +17 -8
- app/code/community/Bronto/Customer/Test/Config/Config.php +0 -159
- app/code/community/Bronto/Customer/controllers/Adminhtml/CustomerController.php +53 -33
- app/code/community/Bronto/Customer/etc/adminhtml.xml +2 -1
- app/code/community/Bronto/Customer/etc/config.xml +26 -29
- app/code/community/Bronto/Customer/etc/system.xml +132 -72
- app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-install-1.0.0.php +1 -1
- app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-install-1.0.3.php +47 -0
- app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-upgrade-1.0.0-1.0.1.php +1 -1
- app/code/community/Bronto/Email/Block/Adminhtml/System/Config/About.php +1 -1
- app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Settings.php +23 -0
- app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates.php +210 -0
- app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Field.php +24 -0
- app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Fieldset.php +390 -0
- app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Label.php +37 -0
- app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Sendtype.php +26 -0
- app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import.php +94 -0
- app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import/Edit.php +26 -0
- app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import/Grid.php +94 -0
- app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import/Grid/Renderer/Action.php +84 -0
- app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log.php +15 -5
- app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log/Grid.php +23 -23
- app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log/Grid/Renderer/Customer.php +2 -2
- app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log/Grid/Renderer/Fields.php +1 -1
- app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template.php +44 -12
- app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Edit.php +135 -9
- app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Edit/Form.php +329 -47
- app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid.php +103 -38
- app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid/Renderer/Action.php +66 -0
- app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid/Renderer/Message.php +0 -30
- app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid/Renderer/Storename.php +24 -0
- app/code/community/Bronto/Email/Helper/Contact.php +1 -1
- app/code/community/Bronto/Email/Helper/Data.php +200 -9
- app/code/community/Bronto/Email/Model/Email/Message.php +0 -67
- app/code/community/Bronto/Email/Model/Message.php +15 -0
- app/code/community/Bronto/Email/Model/Mysql4/Log/Collection.php +2 -2
- app/code/community/Bronto/Email/Model/Mysql4/Message.php +22 -0
- app/code/community/Bronto/Email/Model/Mysql4/Message/Collection.php +15 -0
- app/code/community/Bronto/Email/Model/Mysql4/Template.php +72 -0
- app/code/community/Bronto/Email/Model/Mysql4/Template/Collection.php +40 -0
- app/code/community/Bronto/Email/Model/Observer.php +82 -0
- app/code/community/Bronto/Email/Model/Resource/Setup.php +53 -0
- app/code/community/Bronto/Email/Model/System/Config/Backend/Templates/Field.php +40 -0
- app/code/community/Bronto/Email/Model/System/Config/Backend/Templates/Sendtype.php +37 -0
- app/code/community/Bronto/Email/Model/System/Config/Backend/Usebronto.php +13 -0
- app/code/community/Bronto/Email/Model/System/Config/Source/Email/Template.php +54 -17
- app/code/community/Bronto/Email/Model/System/Config/Source/Sendtype.php +20 -0
- app/code/community/Bronto/Email/Model/Template.php +212 -0
- app/code/community/Bronto/Email/Model/Template/Import.php +243 -108
- app/code/community/Bronto/Email/Model/Template/Mailer.php +79 -0
- app/code/community/Bronto/Email/Test/Config/Config.php +0 -216
- app/code/community/Bronto/Email/Test/Model/Email/Message.php +0 -37
- app/code/community/Bronto/Email/controllers/Adminhtml/System/Email/LogController.php +5 -5
- app/code/community/Bronto/Email/controllers/Adminhtml/System/Email/TemplateController.php +453 -40
- app/code/community/Bronto/Email/etc/adminhtml.xml +3 -3
- app/code/community/Bronto/Email/etc/config.xml +34 -36
- app/code/community/Bronto/Email/etc/system.xml +1297 -6
- app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.1.2.php +1 -1
- app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.1.7.php +63 -0
- app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.1.1-1.1.2.php +1 -1
- app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-upgrade-1.1.2-1.1.7.php +63 -0
- app/code/community/Bronto/News/Block/Adminhtml/ItemRender.php +23 -0
- app/code/community/Bronto/News/Block/Adminhtml/Redirect.php +26 -0
- app/code/community/Bronto/News/Block/Adminhtml/System/Config/About.php +15 -0
- app/code/community/Bronto/News/Block/Adminhtml/System/Config/Form.php +28 -0
- app/code/community/Bronto/News/Block/Adminhtml/System/Config/General.php +13 -0
- app/code/community/Bronto/News/Block/Adminhtml/System/Config/News.php +141 -0
- app/code/community/Bronto/News/Block/Adminhtml/System/Config/Releases.php +13 -0
- app/code/community/Bronto/News/Helper/Data.php +208 -0
- app/code/community/Bronto/News/Model/Item.php +139 -0
- app/code/community/Bronto/News/Model/Mysql4/Item.php +13 -0
- app/code/community/Bronto/News/Model/Mysql4/Item/Collection.php +24 -0
- app/code/community/Bronto/News/Model/Observer.php +52 -0
- app/code/community/Bronto/News/Model/Resource/Setup.php +36 -0
- app/code/community/Bronto/News/controllers/Adminhtml/AnnouncementController.php +52 -0
- app/code/community/Bronto/News/controllers/RouteController.php +24 -0
- app/code/community/Bronto/News/etc/adminhtml.xml +23 -0
- app/code/community/Bronto/News/etc/config.xml +116 -0
- app/code/community/Bronto/News/etc/system.xml +45 -0
- app/code/community/Bronto/News/sql/bronto_news_setup/mysql4-install-1.0.0.php +33 -0
- app/code/community/Bronto/Newsletter/Block/Adminhtml/System/Config/About.php +3 -3
- app/code/community/Bronto/Newsletter/Block/Adminhtml/System/Config/Cron.php +48 -8
- app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Reset.php +5 -2
- app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Run.php +3 -7
- app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Sync.php +23 -0
- app/code/community/Bronto/Newsletter/Block/Checkout/Onepage/Newsletter.php +19 -19
- app/code/community/Bronto/Newsletter/Helper/Contact.php +12 -8
- app/code/community/Bronto/Newsletter/Helper/Data.php +63 -60
- app/code/community/Bronto/Newsletter/Model/Mysql4/Queue.php +18 -9
- app/code/community/Bronto/Newsletter/Model/Mysql4/Queue/Collection.php +33 -33
- app/code/community/Bronto/Newsletter/Model/Observer.php +214 -109
- app/code/community/Bronto/Newsletter/Model/Queue.php +86 -28
- app/code/community/Bronto/Newsletter/Model/System/Config/Backend/Cron.php +1 -1
- app/code/community/Bronto/Newsletter/Test/Config/Config.php +0 -228
- app/code/community/Bronto/Newsletter/controllers/Adminhtml/NewsletterController.php +99 -23
- app/code/community/Bronto/Newsletter/etc/adminhtml.xml +3 -2
- app/code/community/Bronto/Newsletter/etc/config.xml +24 -29
- app/code/community/Bronto/Newsletter/etc/system.xml +36 -30
- app/code/community/Bronto/Newsletter/sql/bronto_newsletter_setup/mysql4-install-1.4.0.php +1 -1
- app/code/community/Bronto/Newsletter/sql/bronto_newsletter_setup/mysql4-install-1.4.4.php +29 -0
- app/code/community/Bronto/Newsletter/sql/bronto_newsletter_setup/mysql4-install-1.4.5.php +56 -0
- app/code/community/Bronto/Newsletter/sql/bronto_newsletter_setup/mysql4-upgrade-1.4.4-1.4.5.php +44 -0
- app/code/community/Bronto/Order/Block/Adminhtml/Sales/Order/View/Tab/Info.php +5 -5
- app/code/community/Bronto/Order/Block/Adminhtml/System/Config/About.php +3 -3
- app/code/community/Bronto/Order/Block/Adminhtml/System/Config/Cron.php +43 -8
- app/code/community/Bronto/Order/Block/Adminhtml/Widget/Button/Reset.php +5 -7
- app/code/community/Bronto/Order/Block/Adminhtml/Widget/Button/Run.php +7 -8
- app/code/community/Bronto/Order/Block/Adminhtml/Widget/Button/Sync.php +3 -11
- app/code/community/Bronto/Order/Block/Bta.php +8 -0
- app/code/community/Bronto/Order/Helper/Data.php +46 -45
- app/code/community/Bronto/Order/Model/Mysql4/Queue.php +12 -3
- app/code/community/Bronto/Order/Model/Mysql4/Queue/Collection.php +12 -13
- app/code/community/Bronto/Order/Model/Mysql4/Setup.php +8 -8
- app/code/community/Bronto/Order/Model/Observer.php +186 -83
- app/code/community/Bronto/Order/Model/Order/Observer.php +17 -17
- app/code/community/Bronto/Order/Model/Queue.php +72 -32
- app/code/community/Bronto/Order/Model/Quote/Observer.php +4 -4
- app/code/community/Bronto/Order/Model/System/Config/Backend/Cron.php +1 -1
- app/code/community/Bronto/Order/Model/System/Config/Source/Description.php +1 -1
- app/code/community/Bronto/Order/Test/Config/Config.php +0 -235
- app/code/community/Bronto/Order/controllers/Adminhtml/OrderController.php +58 -38
- app/code/community/Bronto/Order/etc/adminhtml.xml +1 -0
- app/code/community/Bronto/Order/etc/config.xml +11 -24
- app/code/community/Bronto/Order/etc/system.xml +44 -18
- app/code/community/Bronto/Order/sql/bronto_order_setup/mysql4-install-1.0.0.php +3 -3
- app/code/community/Bronto/Order/sql/bronto_order_setup/mysql4-install-1.1.8.php +53 -0
- app/code/community/Bronto/Order/sql/bronto_order_setup/{mysql4-upgrade-1.1.5-1.1.6.php → mysql4-upgrade-1.0.0-1.1.6.php} +1 -1
- app/code/community/Bronto/PermissionChecker/Block/Adminhtml/System/Config/About.php +0 -54
- app/code/community/Bronto/PermissionChecker/Block/Adminhtml/System/Config/Permissionchecker.php +0 -78
- app/code/community/Bronto/PermissionChecker/Block/Printer.php +0 -77
- app/code/community/Bronto/PermissionChecker/Helper/Data.php +0 -33
- app/code/community/Bronto/PermissionChecker/Model/Validator/Directory.php +0 -65
- app/code/community/Bronto/PermissionChecker/Model/Validator/File.php +0 -67
- app/code/community/Bronto/PermissionChecker/Model/Validator/Filter/PatternIterator.php +0 -55
- app/code/community/Bronto/PermissionChecker/Model/Validator/Group.php +0 -69
- app/code/community/Bronto/PermissionChecker/Model/Validator/Owner.php +0 -69
- app/code/community/Bronto/PermissionChecker/Model/Validator/Printer.php +0 -53
- app/code/community/Bronto/PermissionChecker/Model/Validator/ValidatorInterface.php +0 -48
- app/code/community/Bronto/PermissionChecker/Test/Config/Config.php +0 -197
- app/code/community/Bronto/PermissionChecker/etc/adminhtml.xml +0 -32
- app/code/community/Bronto/PermissionChecker/etc/config.xml +0 -64
- app/code/community/Bronto/PermissionChecker/etc/system.xml +0 -79
- app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder.php +10 -0
- app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit.php +8 -8
- app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tab/Bronto.php +35 -19
- app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tab/Conditions.php +1 -1
- app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tab/Customers.php +45 -45
- app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tab/General.php +25 -25
- app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tabs.php +4 -4
- app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Grid.php +32 -32
- app/code/community/Bronto/Reminder/Block/Adminhtml/System/Config/About.php +1 -1
- app/code/community/Bronto/Reminder/Block/Adminhtml/System/Config/Settings.php +2 -2
- app/code/community/Bronto/Reminder/Helper/Data.php +171 -22
- app/code/community/Bronto/Reminder/Model/Condition/Abstract.php +3 -3
- app/code/community/Bronto/Reminder/Model/Condition/Combine/Abstract.php +8 -8
- app/code/community/Bronto/Reminder/Model/Email/Message.php +25 -1
- app/code/community/Bronto/Reminder/Model/Mysql4/Customer/Collection.php +11 -11
- app/code/community/Bronto/Reminder/Model/Mysql4/Rule.php +120 -80
- app/code/community/Bronto/Reminder/Model/Mysql4/Rule/Collection.php +7 -7
- app/code/community/Bronto/Reminder/Model/Observer.php +18 -9
- app/code/community/Bronto/Reminder/Model/Rule.php +57 -57
- app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart.php +28 -77
- app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Amount.php +3 -3
- app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Attributes.php +3 -3
- app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Couponcode.php +3 -3
- app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Itemsquantity.php +3 -3
- app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Sku.php +3 -3
- app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Storeview.php +3 -3
- app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Subselection.php +4 -4
- app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Totalquantity.php +3 -3
- app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Virtual.php +3 -3
- app/code/community/Bronto/Reminder/Model/Rule/Condition/Combine/Root.php +74 -74
- app/code/community/Bronto/Reminder/Model/Rule/Condition/Wishlist.php +14 -15
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/About.php
CHANGED
@@ -79,7 +79,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_About extends Mage_Adminhtml_B
|
|
79 |
*/
|
80 |
public function hasDebugEnabled()
|
81 |
{
|
82 |
-
return (bool)
|
83 |
}
|
84 |
|
85 |
/**
|
@@ -90,6 +90,16 @@ class Bronto_Common_Block_Adminhtml_System_Config_About extends Mage_Adminhtml_B
|
|
90 |
public function logFileExists()
|
91 |
{
|
92 |
$logFile = Mage::getBaseDir('log') . DIRECTORY_SEPARATOR . "{$this->_module}.log";
|
93 |
-
return (bool)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
}
|
95 |
}
|
79 |
*/
|
80 |
public function hasDebugEnabled()
|
81 |
{
|
82 |
+
return (bool)Mage::helper($this->_module)->isDebugEnabled();
|
83 |
}
|
84 |
|
85 |
/**
|
90 |
public function logFileExists()
|
91 |
{
|
92 |
$logFile = Mage::getBaseDir('log') . DIRECTORY_SEPARATOR . "{$this->_module}.log";
|
93 |
+
return (bool)@file_exists($logFile);
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Forwards call to helper from view
|
98 |
+
*
|
99 |
+
* @return boolean
|
100 |
+
*/
|
101 |
+
public function isValidApiToken()
|
102 |
+
{
|
103 |
+
return Mage::helper('bronto_common')->validApiToken();
|
104 |
}
|
105 |
}
|
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Cron.php
CHANGED
@@ -103,6 +103,106 @@ class Bronto_Common_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Bl
|
|
103 |
return $html;
|
104 |
}
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
/**
|
107 |
* Get the HTML markup for the progress bar
|
108 |
*
|
@@ -110,22 +210,29 @@ class Bronto_Common_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Bl
|
|
110 |
*/
|
111 |
public function getProgressBarHtml()
|
112 |
{
|
113 |
-
$
|
114 |
-
$pending = (int) $this->getProgressBarPending();
|
115 |
-
$total = (int) $this->getProgressBarTotal();
|
116 |
-
|
117 |
-
$complete = $total - $pending;
|
118 |
-
if ($complete > 0) {
|
119 |
-
$percent = round(($complete / $total) * 100);
|
120 |
-
}
|
121 |
|
122 |
-
|
123 |
-
$html
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
129 |
$html .= '</div>';
|
130 |
|
131 |
return $html;
|
@@ -164,7 +271,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Bl
|
|
164 |
/**
|
165 |
* Add button widget
|
166 |
*
|
167 |
-
* @param Mage_Adminhtml_Block_Widget_Button
|
168 |
* @return Bronto_Common_Block_Adminhtml_System_Config_Cron
|
169 |
*/
|
170 |
public function addButton(Mage_Adminhtml_Block_Widget_Button $button)
|
@@ -186,7 +293,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Bl
|
|
186 |
/**
|
187 |
* Set if we're using a progress bar
|
188 |
*
|
189 |
-
* @param bool
|
190 |
* @return Bronto_Common_Block_Adminhtml_System_Config_Cron
|
191 |
*/
|
192 |
public function setHasProgressBar($hasProgressBar)
|
@@ -202,7 +309,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Bl
|
|
202 |
*/
|
203 |
public function hasProgressBar()
|
204 |
{
|
205 |
-
return (bool)
|
206 |
}
|
207 |
|
208 |
/**
|
@@ -220,4 +327,20 @@ class Bronto_Common_Block_Adminhtml_System_Config_Cron extends Mage_Adminhtml_Bl
|
|
220 |
{
|
221 |
return 0;
|
222 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
223 |
}
|
103 |
return $html;
|
104 |
}
|
105 |
|
106 |
+
protected function _getProgressComplete($total, $getCount = false, $getBar = true, $getLegend = false)
|
107 |
+
{
|
108 |
+
$html = '';
|
109 |
+
$percent = 0;
|
110 |
+
$pending = (int)$this->getProgressBarPending();
|
111 |
+
$disabled = $this->_getProgressDisabled($total, true);
|
112 |
+
$suppressed = $this->_getProgressSuppressed($total, true);
|
113 |
+
$pending = $pending - $disabled;
|
114 |
+
|
115 |
+
$count = $total - ($pending + $suppressed + $disabled);
|
116 |
+
|
117 |
+
if ($getCount) {
|
118 |
+
return $count;
|
119 |
+
}
|
120 |
+
|
121 |
+
if ($total > 0) {
|
122 |
+
$percent = round(((float)$count / (float)$total) * 100, 1);
|
123 |
+
}
|
124 |
+
|
125 |
+
if ($getBar) {
|
126 |
+
if ($count > 0) {
|
127 |
+
$html .= "<div class=\"bronto-progress-bar-complete\" style=\"width: {$percent}%\">";
|
128 |
+
$html .= ($percent > 4) ? "{$percent}%" : " ";
|
129 |
+
$html .= "</div>";
|
130 |
+
}
|
131 |
+
}
|
132 |
+
|
133 |
+
if ($getLegend) {
|
134 |
+
$html .= '<div class="bronto-progress-bar-legend-complete">';
|
135 |
+
$html .= '<div class="bronto-progress-bar-legend-status"></div>';
|
136 |
+
$html .= "<div class=\"bronto-progress-bar-legend-details\">Completed: {$percent}% ({$count}/{$total})</div>";
|
137 |
+
$html .= '</div>';
|
138 |
+
}
|
139 |
+
|
140 |
+
return $html;
|
141 |
+
}
|
142 |
+
|
143 |
+
protected function _getProgressSuppressed($total, $getCount = false, $getBar = true, $getLegend = false)
|
144 |
+
{
|
145 |
+
$html = '';
|
146 |
+
$percent = 0;
|
147 |
+
$count = (int)$this->getProgressBarSuppressed();
|
148 |
+
|
149 |
+
if ($getCount) {
|
150 |
+
return $count;
|
151 |
+
}
|
152 |
+
|
153 |
+
if ($total > 0) {
|
154 |
+
$percent = round(((float)$count / (float)$total) * 100, 1);
|
155 |
+
}
|
156 |
+
|
157 |
+
if ($getBar) {
|
158 |
+
if ($count > 0) {
|
159 |
+
$html .= "<div class=\"bronto-progress-bar-suppressed\" style=\"width: {$percent}%\">";
|
160 |
+
$html .= ($percent > 4) ? "{$percent}%" : " ";
|
161 |
+
$html .= "</div>";
|
162 |
+
}
|
163 |
+
}
|
164 |
+
|
165 |
+
if ($getLegend) {
|
166 |
+
$html .= '<div class="bronto-progress-bar-legend-suppressed">';
|
167 |
+
$html .= '<div class="bronto-progress-bar-legend-status"></div>';
|
168 |
+
$html .= "<div class=\"bronto-progress-bar-legend-details\">Suppressed: {$percent}% ({$count}/{$total})</div>";
|
169 |
+
$html .= '</div>';
|
170 |
+
}
|
171 |
+
return $html;
|
172 |
+
}
|
173 |
+
|
174 |
+
protected function _getProgressDisabled($total, $getCount = false, $getBar = true, $getLegend = false)
|
175 |
+
{
|
176 |
+
$html = '';
|
177 |
+
$percent = 0;
|
178 |
+
$count = (int)$this->getProgressBarDisabled();
|
179 |
+
|
180 |
+
if ($getCount) {
|
181 |
+
return $count;
|
182 |
+
}
|
183 |
+
|
184 |
+
if ($total > 0) {
|
185 |
+
$percent = round(((float)$count / (float)$total) * 100, 1);
|
186 |
+
}
|
187 |
+
|
188 |
+
if ($getBar) {
|
189 |
+
if ($count > 0) {
|
190 |
+
$html .= "<div class=\"bronto-progress-bar-disabled\" style=\"width: {$percent}%\">";
|
191 |
+
$html .= ($percent > 4) ? "{$percent}%" : " ";
|
192 |
+
$html .= "</div>";
|
193 |
+
}
|
194 |
+
}
|
195 |
+
|
196 |
+
if ($getLegend) {
|
197 |
+
$html .= '<div class="bronto-progress-bar-legend-disabled">';
|
198 |
+
$html .= '<div class="bronto-progress-bar-legend-status"></div>';
|
199 |
+
$html .= "<div class=\"bronto-progress-bar-legend-details\">Disabled: {$percent}% ({$count}/{$total})</div>";
|
200 |
+
$html .= '</div>';
|
201 |
+
}
|
202 |
+
|
203 |
+
return $html;
|
204 |
+
}
|
205 |
+
|
206 |
/**
|
207 |
* Get the HTML markup for the progress bar
|
208 |
*
|
210 |
*/
|
211 |
public function getProgressBarHtml()
|
212 |
{
|
213 |
+
$total = (int)$this->getProgressBarTotal();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
214 |
|
215 |
+
// Build Status Legend
|
216 |
+
$html = '<div class="bronto-progress-bar-legend">';
|
217 |
+
$html .= $this->_getProgressComplete($total, false, false, true);
|
218 |
+
$html .= $this->_getProgressSuppressed($total, false, false, true);
|
219 |
+
$html .= $this->_getProgressDisabled($total, false, false, true);
|
220 |
+
$html .= '</div>';
|
221 |
+
|
222 |
+
// Build Progress Bar
|
223 |
+
$html .= "<div class=\"bronto-progress-bar\">";
|
224 |
+
$html .= $this->_getProgressComplete($total);
|
225 |
+
$html .= $this->_getProgressSuppressed($total);
|
226 |
+
$html .= $this->_getProgressDisabled($total);
|
227 |
+
$html .= '</div>';
|
228 |
+
|
229 |
+
// Add Info Hover
|
230 |
+
$html .= '<div class="bronto-help bronto-floater">';
|
231 |
+
$html .= ' <ul class="bronto-help-window">';
|
232 |
+
$html .= ' <li><strong>Completed</strong> refers to items that have been successfully imported.</li>';
|
233 |
+
$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>';
|
234 |
+
$html .= ' <li><strong>Disabled</strong> refers to items that exist in stores where this module is not enabled</li>';
|
235 |
+
$html .= ' </ul>';
|
236 |
$html .= '</div>';
|
237 |
|
238 |
return $html;
|
271 |
/**
|
272 |
* Add button widget
|
273 |
*
|
274 |
+
* @param Mage_Adminhtml_Block_Widget_Button $button
|
275 |
* @return Bronto_Common_Block_Adminhtml_System_Config_Cron
|
276 |
*/
|
277 |
public function addButton(Mage_Adminhtml_Block_Widget_Button $button)
|
293 |
/**
|
294 |
* Set if we're using a progress bar
|
295 |
*
|
296 |
+
* @param bool $hasProgressBar
|
297 |
* @return Bronto_Common_Block_Adminhtml_System_Config_Cron
|
298 |
*/
|
299 |
public function setHasProgressBar($hasProgressBar)
|
309 |
*/
|
310 |
public function hasProgressBar()
|
311 |
{
|
312 |
+
return (bool)$this->_hasProgressBar;
|
313 |
}
|
314 |
|
315 |
/**
|
327 |
{
|
328 |
return 0;
|
329 |
}
|
330 |
+
|
331 |
+
/**
|
332 |
+
* @return int
|
333 |
+
*/
|
334 |
+
protected function getProgressBarSuppressed()
|
335 |
+
{
|
336 |
+
return 0;
|
337 |
+
}
|
338 |
+
|
339 |
+
/**
|
340 |
+
* @return int
|
341 |
+
*/
|
342 |
+
protected function getProgressBarDisabled()
|
343 |
+
{
|
344 |
+
return 0;
|
345 |
+
}
|
346 |
}
|
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field.php
CHANGED
@@ -18,11 +18,16 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field extends Mage_Adminh
|
|
18 |
if (!extension_loaded('soap') || !extension_loaded('openssl')) {
|
19 |
$element->setDisabled('disabled')->setValue(0);
|
20 |
} else {
|
21 |
-
if (!Mage::helper('bronto_common')->
|
22 |
$element->setDisabled('disabled')->setValue(0);
|
23 |
-
if ($element->getLabel() === 'Enable Module') {
|
24 |
$element->setComment('<span style="color:red;font-weight: bold">A valid Bronto API key is required.</span>');
|
25 |
}
|
|
|
|
|
|
|
|
|
|
|
26 |
}
|
27 |
}
|
28 |
|
18 |
if (!extension_loaded('soap') || !extension_loaded('openssl')) {
|
19 |
$element->setDisabled('disabled')->setValue(0);
|
20 |
} else {
|
21 |
+
if (!Mage::helper('bronto_common')->validApiToken()) {
|
22 |
$element->setDisabled('disabled')->setValue(0);
|
23 |
+
if (trim($element->getLabel()) === 'Enable Module') {
|
24 |
$element->setComment('<span style="color:red;font-weight: bold">A valid Bronto API key is required.</span>');
|
25 |
}
|
26 |
+
} else if (!Mage::helper('bronto_common/support')->isRegistered()) {
|
27 |
+
if (trim($element->getLabel()) !== 'Enable Module' || !$element->getValue()) {
|
28 |
+
$element->setDisabled('disabled');
|
29 |
+
$element->setComment('<span style="color:red;font-weight:bold">Extension registration is required.</span>');
|
30 |
+
}
|
31 |
}
|
32 |
}
|
33 |
|
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Apitoken.php
CHANGED
@@ -26,19 +26,19 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Apitoken extends Ma
|
|
26 |
*/
|
27 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
28 |
{
|
29 |
-
$_html
|
30 |
-
|
31 |
// Create form object to grab scope details
|
32 |
-
$form
|
33 |
-
$scope
|
34 |
$scopeId = $form->getScopeId();
|
35 |
-
|
36 |
$element->setData('onchange', "validateToken(this.form, this);");
|
37 |
$element->setData('after_element_html', "
|
38 |
-
<
|
39 |
-
<
|
40 |
-
<
|
41 |
-
</
|
42 |
<script>
|
43 |
function toggleDisabled(form, element) {
|
44 |
var statusText = $('bronto-validation-status');
|
@@ -79,7 +79,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Apitoken extends Ma
|
|
79 |
function validateToken(form, element) {
|
80 |
var token = trim1($('{$element->getId()}').value);
|
81 |
var statusText = $('bronto-validation-status');
|
82 |
-
var reloadurl = '{$this->getUrl('*/
|
83 |
|
84 |
statusText.innerHTML = $('loadingmask').innerHTML;
|
85 |
statusText.removeClassName('valid').removeClassName('invalid');
|
@@ -107,74 +107,32 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Apitoken extends Ma
|
|
107 |
}
|
108 |
</script>
|
109 |
");
|
110 |
-
|
111 |
if (!$this->helper('bronto_common')->getApiToken()) {
|
112 |
$element->setComment('<span style="color:red;font-weight:bold">Please enter your Bronto API key here.</span>');
|
113 |
$buttonHtml = "";
|
114 |
} else {
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
-
$buttonHtml = "<p class=\"form-buttons\" id=\"verify-button\">{$button}</p>";
|
120 |
-
|
121 |
-
$organization = null;
|
122 |
-
$name = null;
|
123 |
-
$email = null;
|
124 |
-
|
125 |
-
/* @var $loginObject Bronto_Api_Login */
|
126 |
-
$loginObject = Mage::helper('bronto_common')->getApi()->getLoginObject();
|
127 |
-
$iterator = $loginObject->readAll()->iterate();
|
128 |
-
foreach ($iterator as $login /* @var $login Bronto_Api_Login_Row */) {
|
129 |
-
if ($iterator->count() == 1) {
|
130 |
-
if (isset($login->contactInformation->organization)) {
|
131 |
-
$organization = $login->contactInformation->organization;
|
132 |
-
}
|
133 |
-
if (isset($login->contactInformation->firstName)) {
|
134 |
-
$name = trim($login->contactInformation->firstName);
|
135 |
-
}
|
136 |
-
if (isset($login->contactInformation->lastName)) {
|
137 |
-
$name .= trim(' ' . $login->contactInformation->lastName);
|
138 |
-
}
|
139 |
-
if (isset($login->contactInformation->email)) {
|
140 |
-
$email = trim($login->contactInformation->email);
|
141 |
-
}
|
142 |
-
} else {
|
143 |
-
if (isset($login->contactInformation->organization)) {
|
144 |
-
if (strlen($login->contactInformation->organization) > $organization) {
|
145 |
-
$organization = $login->contactInformation->organization;
|
146 |
-
}
|
147 |
-
}
|
148 |
-
}
|
149 |
-
}
|
150 |
-
|
151 |
-
if (!empty($organization)) {
|
152 |
-
$_html[] = '<strong style="float: left; width: 88px">Organization:</strong> ' . $organization;
|
153 |
-
}
|
154 |
-
|
155 |
-
if (!empty($name)) {
|
156 |
-
$_html[] = '<strong style="float: left; width: 88px">Name:</strong> ' . $name;
|
157 |
-
}
|
158 |
-
|
159 |
-
if (!empty($email)) {
|
160 |
-
$_html[] = '<strong style="float: left; width: 88px">Email:</strong> ' . $email;
|
161 |
-
}
|
162 |
-
} catch (Exception $e) {
|
163 |
-
//
|
164 |
-
}
|
165 |
}
|
166 |
|
167 |
// Show Roundtrip Install Verification Status
|
168 |
-
$_html[] = '<style>' .
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
|
175 |
// Show everything Else
|
176 |
if (!empty($_html)) {
|
177 |
-
$elementHtml
|
|
|
|
|
|
|
|
|
178 |
$elementHtml .= '<div style="margin-top:10px">';
|
179 |
$elementHtml .= implode('<br />', $_html);
|
180 |
$elementHtml .= '</div>';
|
26 |
*/
|
27 |
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
28 |
{
|
29 |
+
$_html = array();
|
30 |
+
|
31 |
// Create form object to grab scope details
|
32 |
+
$form = new Mage_Adminhtml_Block_System_Config_Form;
|
33 |
+
$scope = $form->getScope();
|
34 |
$scopeId = $form->getScopeId();
|
35 |
+
|
36 |
$element->setData('onchange', "validateToken(this.form, this);");
|
37 |
$element->setData('after_element_html', "
|
38 |
+
<span id=\"loadingmask\" style=\"display: none; width: 100px;\">
|
39 |
+
<span class=\"loader\" id=\"loading-mask-loader\" style=\"background: url(" . $this->getSkinUrl('bronto/images/ajax-loader-tr.gif') . ") no-repeat 0 50%; background-size: 20px; padding:3px 0 3px 25px;\">" . $this->__(' Verifying...') . "</span>
|
40 |
+
<span id=\"loading-mask\"></span>
|
41 |
+
</span>
|
42 |
<script>
|
43 |
function toggleDisabled(form, element) {
|
44 |
var statusText = $('bronto-validation-status');
|
79 |
function validateToken(form, element) {
|
80 |
var token = trim1($('{$element->getId()}').value);
|
81 |
var statusText = $('bronto-validation-status');
|
82 |
+
var reloadurl = '{$this->getUrl('*/apitoken/ajaxvalidation')}';
|
83 |
|
84 |
statusText.innerHTML = $('loadingmask').innerHTML;
|
85 |
statusText.removeClassName('valid').removeClassName('invalid');
|
107 |
}
|
108 |
</script>
|
109 |
");
|
110 |
+
|
111 |
if (!$this->helper('bronto_common')->getApiToken()) {
|
112 |
$element->setComment('<span style="color:red;font-weight:bold">Please enter your Bronto API key here.</span>');
|
113 |
$buttonHtml = "";
|
114 |
} else {
|
115 |
+
$button = $this->getLayout()
|
116 |
+
->createBlock('bronto_verify/adminhtml_widget_button_runtoken')
|
117 |
+
->toHtml();
|
118 |
+
$buttonHtml = "<p class=\"form-buttons\" id=\"verify-button\">{$button}</p>";
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
}
|
120 |
|
121 |
// Show Roundtrip Install Verification Status
|
122 |
+
$_html[] = '<style>' .
|
123 |
+
'#bronto-validation-status { color:grey; font-weight:bold; }' .
|
124 |
+
'#bronto-validation-status.valid { color: green; }' .
|
125 |
+
'#bronto-validation-status.invalid { color: red; }' .
|
126 |
+
'</style>' . '<strong style="float: left; width: 80px">Last Status:</strong> ' .
|
127 |
+
$this->helper('bronto_verify/apitoken')->getAdminScopedApitokenStatusText() . $buttonHtml;
|
128 |
|
129 |
// Show everything Else
|
130 |
if (!empty($_html)) {
|
131 |
+
$elementHtml = $element->getElementHtml();
|
132 |
+
if ($element->getComment()) {
|
133 |
+
$elementHtml.= '<p class="note"><span>'.$element->getComment().'</span></p>';
|
134 |
+
$element->setComment(null);
|
135 |
+
}
|
136 |
$elementHtml .= '<div style="margin-top:10px">';
|
137 |
$elementHtml .= implode('<br />', $_html);
|
138 |
$elementHtml .= '</div>';
|
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Debug.php
ADDED
@@ -0,0 +1,60 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Debug extends Mage_Adminhtml_Block_System_Config_Form_Field {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Generate the button and surround html
|
7 |
+
*
|
8 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
9 |
+
* @return string
|
10 |
+
*/
|
11 |
+
protected function _getButtonHtml(Varien_Data_Form_Element_Abstract $element) {
|
12 |
+
$script = '
|
13 |
+
<p class="note" style="margin-top: 3px; width:550px"><strong>Disclaimer:</strong> Only share with Bronto Support through an actual Bronto support case and not on any public forums.</p>
|
14 |
+
<span id="debug-loadingmask" style="display:none; width: 100px;">
|
15 |
+
<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>
|
16 |
+
</span>
|
17 |
+
<div id="debug-information-result" style="display:none;margin: 13px 3px 3px 0"></div>
|
18 |
+
<script>
|
19 |
+
function collectDebugInformation() {
|
20 |
+
var collectUrl = "' . $this->getUrl("*/debug/collect") . '";
|
21 |
+
var debugResult = $("debug-information-result");
|
22 |
+
debugResult.innerHTML = $("debug-loadingmask").innerHTML;
|
23 |
+
Element.show(debugResult);
|
24 |
+
|
25 |
+
new Ajax.Request(collectUrl, {
|
26 |
+
method: "post",
|
27 |
+
onComplete: function(transport) {
|
28 |
+
debugResult.innerHTML = "<textarea readonly style=\"width: 480px; height:480px; resize:none;\">" + JSON.stringify(transport.responseJSON, undefined, 4) + "</textarea>";
|
29 |
+
}
|
30 |
+
});
|
31 |
+
}
|
32 |
+
</script>
|
33 |
+
';
|
34 |
+
|
35 |
+
$button = $this->getLayout()->createBlock('bronto_common/adminhtml_widget_button_debug');
|
36 |
+
return $button->toHtml() . $script;
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Empty the element html
|
41 |
+
*
|
42 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
43 |
+
* @return string
|
44 |
+
*/
|
45 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
|
46 |
+
return '';
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Remove the "scope" value
|
51 |
+
*
|
52 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
53 |
+
* @return string
|
54 |
+
*/
|
55 |
+
public function render(Varien_Data_Form_Element_Abstract $element) {
|
56 |
+
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
|
57 |
+
$element->setLabel($this->_getButtonHtml($element));
|
58 |
+
return parent::render($element);
|
59 |
+
}
|
60 |
+
}
|
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Download.php
ADDED
@@ -0,0 +1,58 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Download extends Mage_Adminhtml_Block_System_Config_Form_Field {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
7 |
+
* @return string
|
8 |
+
*/
|
9 |
+
protected function _getButtonHtml(Varien_Data_Form_Element_Abstract $element) {
|
10 |
+
$script = '
|
11 |
+
<span id="archive-loadingmask" style="display:none; width: 100px;">
|
12 |
+
<span class="loader" id="archive-loading-mask-loader" style="background: url(' . $this->getSkinUrl('bronto/images/ajax-loader-tr.gif') . ') no-repeat 0 50%; background-size: 20px; padding: 3px 0 3px 25px;">' . $this->__('Creating Archive'). '</span>
|
13 |
+
</span>
|
14 |
+
<div id="archive-information-result" style="display:none;margin:13px 3px 0 0"></div>
|
15 |
+
<script>
|
16 |
+
function createLogArchive() {
|
17 |
+
var archiveUrl = "' . $this->getUrl("*/debug/archive") . '";
|
18 |
+
var archiveResult = $("archive-information-result");
|
19 |
+
archiveResult.innerHTML = $("archive-loadingmask").innerHTML;
|
20 |
+
Element.show(archiveResult);
|
21 |
+
|
22 |
+
new Ajax.Request(archiveUrl, {
|
23 |
+
method: "post",
|
24 |
+
onComplete: function(transport) {
|
25 |
+
var response = transport.responseJSON;
|
26 |
+
archiveResult.innerHTML = "<p>Created archive: <a target=\"_blank\" href=\"" + response.link + "\">" + response.name + "</a></p>";
|
27 |
+
}
|
28 |
+
});
|
29 |
+
}
|
30 |
+
</script>
|
31 |
+
';
|
32 |
+
|
33 |
+
$button = $this->getLayout()->createBlock('bronto_common/adminhtml_widget_button_download');
|
34 |
+
return $button->toHtml() . $script;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Empty the element html
|
39 |
+
*
|
40 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
41 |
+
* @return string
|
42 |
+
*/
|
43 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element) {
|
44 |
+
return '';
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* Remove the "scope" value
|
49 |
+
*
|
50 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
51 |
+
* @return string
|
52 |
+
*/
|
53 |
+
public function render(Varien_Data_Form_Element_Abstract $element) {
|
54 |
+
$element->unsScope()->unsCanUseWebsiteValue()->unsCanUseDefaultValue();
|
55 |
+
$element->setLabel($this->_getButtonHtml($element));
|
56 |
+
return parent::render($element);
|
57 |
+
}
|
58 |
+
}
|
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Image.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 dropdown to place recommended defaults
|
8 |
+
*
|
9 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
10 |
+
* @return string
|
11 |
+
*/
|
12 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
13 |
+
{
|
14 |
+
$defaultSizes = array(
|
15 |
+
'image' => array('width' => '265', 'height' => ''),
|
16 |
+
'small_image' => array('width' => '88', 'height' => '77'),
|
17 |
+
'thumbnail' => array('width' => '75', 'height' => '75'),
|
18 |
+
);
|
19 |
+
|
20 |
+
$element->setData('onchange', "defaultImageSize();");
|
21 |
+
$element->setData('after_element_html', "
|
22 |
+
<script>
|
23 |
+
function defaultImageSize() {
|
24 |
+
var sizes = " . json_encode($defaultSizes) . ";
|
25 |
+
var size = sizes[$('{$element->getId()}').value];
|
26 |
+
if (size) {
|
27 |
+
for (var name in size) {
|
28 |
+
$('bronto_format_image_' + name).value = size[name];
|
29 |
+
}
|
30 |
+
}
|
31 |
+
}
|
32 |
+
</script>
|
33 |
+
");
|
34 |
+
return parent::_getElementHtml($element);
|
35 |
+
}
|
36 |
+
}
|
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/List.php
CHANGED
@@ -20,8 +20,7 @@ class Bronto_Common_Block_Adminhtml_System_Config_Form_Field_List extends Bronto
|
|
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 |
|
20 |
if (!$request->getParam('store') && !$request->getParam('website') && !$request->getParam('group')) {
|
21 |
$element->setCanUseDefaultValue(false)
|
22 |
->setDisabled('disabled')
|
23 |
+
->setValue(null);
|
|
|
24 |
}
|
25 |
}
|
26 |
|
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Support.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @return string
|
11 |
+
*/
|
12 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
13 |
+
{
|
14 |
+
$helper = Mage::helper('bronto_common');
|
15 |
+
if (!$helper->validApiToken()) {
|
16 |
+
$element->setDisabled('disabled');
|
17 |
+
}
|
18 |
+
|
19 |
+
return parent::_getElementHtml($element);
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Field/Support/Site.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @return string
|
10 |
+
*/
|
11 |
+
protected function _getElementHtml(Varien_Data_Form_Element_Abstract $element)
|
12 |
+
{
|
13 |
+
$brontoLink = '<a href="http://app.bronto.com" target="_blank"'
|
14 |
+
. 'title="Home Dashboard | Bronto Marketing Platform">Bronto</a>';
|
15 |
+
$helpIcon = $this->getSkinUrl('bronto/images/site_name.png');
|
16 |
+
$comment = 'Found within '
|
17 |
+
. $brontoLink . ', located at:'
|
18 |
+
. '<div class="bronto-with-help">'
|
19 |
+
. '<strong>Home » Settings » General Settings</strong>'
|
20 |
+
. '<div class="bronto-help bronto-vertical-align">'
|
21 |
+
. '<div class="bronto-help-window bronto-large-image">'
|
22 |
+
. '<img src="' . $helpIcon . '"/></div></div></div>';
|
23 |
+
|
24 |
+
$element->setComment($comment);
|
25 |
+
|
26 |
+
return parent::_getElementHtml($element);
|
27 |
+
}
|
28 |
+
}
|
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Form/Fieldset.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bronto_Common_Block_Adminhtml_System_Config_Form_Fieldset extends Mage_Adminhtml_Block_System_Config_Form_Fieldset {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Collapsed or expanded fieldset when page loaded?
|
7 |
+
*
|
8 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
9 |
+
* @return bool
|
10 |
+
*/
|
11 |
+
protected function _getCollapseState($element)
|
12 |
+
{
|
13 |
+
$user = Mage::getSingleton('admin/session')->getUser();
|
14 |
+
$extra = $user->getExtra();
|
15 |
+
if (!isset($extra['configState'][$element->getId()])) {
|
16 |
+
return 1;
|
17 |
+
}
|
18 |
+
|
19 |
+
return parent::_getCollapseState($element);
|
20 |
+
}
|
21 |
+
}
|
app/code/community/Bronto/Common/Block/Adminhtml/System/Config/Support.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @return bool
|
25 |
+
*/
|
26 |
+
protected function _getCollapseState($element)
|
27 |
+
{
|
28 |
+
$helper = Mage::helper('bronto_common/support');
|
29 |
+
|
30 |
+
if (!$helper->isRegistered()) {
|
31 |
+
return 1;
|
32 |
+
}
|
33 |
+
|
34 |
+
return parent::_getCollapseState($element);
|
35 |
+
}
|
36 |
+
}
|
app/code/community/Bronto/Common/Block/Adminhtml/Widget/Button/Abstract.php
ADDED
@@ -0,0 +1,41 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
abstract class Bronto_Common_Block_Adminhtml_Widget_Button_Abstract extends Mage_Adminhtml_Block_Widget_Button {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* @var Mage_Core_Helper_Data
|
7 |
+
*/
|
8 |
+
protected $_helper;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* @return Mage_Core_Helper_Data
|
12 |
+
*/
|
13 |
+
protected function _getHelper() {
|
14 |
+
if (is_null($this->_helper)) {
|
15 |
+
$this->_helper = Mage::helper('bronto_common/support');
|
16 |
+
}
|
17 |
+
return $this->_helper;
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @param Mage_Core_Helper_Data $helper
|
22 |
+
* @return Bronto_Common_Block_Adminhtml_Widget_Button_Abstract
|
23 |
+
*/
|
24 |
+
public function setHelper(Mage_Core_Helper_Data $helper) {
|
25 |
+
$this->_helper = $helper;
|
26 |
+
return $this;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Children override for button definition
|
31 |
+
*/
|
32 |
+
protected abstract function _setUp();
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Define the button
|
36 |
+
*/
|
37 |
+
protected function _construct() {
|
38 |
+
$this->setDisabled(!$this->_getHelper()->isRegistered());
|
39 |
+
$this->_setup();
|
40 |
+
}
|
41 |
+
}
|
app/code/community/Bronto/Common/Block/Adminhtml/Widget/Button/Debug.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bronto_Common_Block_Adminhtml_Widget_Button_Debug extends Bronto_Common_Block_Adminhtml_Widget_Button_Abstract {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* Sets up the JS action for gathering debug information
|
7 |
+
* @see parent
|
8 |
+
*/
|
9 |
+
protected function _setUp() {
|
10 |
+
$this->setLabel('Generate Debug Information');
|
11 |
+
$this->setOnClick('collectDebugInformation(); return false;');
|
12 |
+
}
|
13 |
+
}
|
app/code/community/Bronto/Common/Block/Adminhtml/Widget/Button/Download.php
ADDED
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bronto_Common_Block_Adminhtml_Widget_Button_Download extends Bronto_Common_Block_Adminhtml_Widget_Button_Abstract {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* @see parent
|
7 |
+
*/
|
8 |
+
protected function _setUp() {
|
9 |
+
$this->setLabel('Create Log Archive');
|
10 |
+
$this->setOnClick('createLogArchive(); return false;');
|
11 |
+
}
|
12 |
+
}
|
app/code/community/Bronto/Common/Helper/Contact.php
CHANGED
@@ -8,9 +8,9 @@
|
|
8 |
class Bronto_Common_Helper_Contact extends Bronto_Common_Helper_Data
|
9 |
{
|
10 |
/**
|
11 |
-
* @param string
|
12 |
-
* @param string
|
13 |
-
* @param int
|
14 |
* @return Bronto_Api_Contact_Row
|
15 |
*/
|
16 |
public function getContactByEmail($email, $customSource = null, $store = null)
|
@@ -24,7 +24,7 @@ class Bronto_Common_Helper_Contact extends Bronto_Common_Helper_Data
|
|
24 |
$contactObject = $api->getContactObject();
|
25 |
|
26 |
// Load Contact
|
27 |
-
$contact = $contactObject->createRow();
|
28 |
$contact->email = $email;
|
29 |
try {
|
30 |
$contact = $contact->read();
|
@@ -42,7 +42,7 @@ class Bronto_Common_Helper_Contact extends Bronto_Common_Helper_Data
|
|
42 |
|
43 |
/**
|
44 |
* @param Bronto_Api_Contact_Row $contact
|
45 |
-
* @param bool
|
46 |
* @return Bronto_Api_Contact_Row
|
47 |
*/
|
48 |
public function saveContact(Bronto_Api_Contact_Row $contact, $persistOnly = false)
|
8 |
class Bronto_Common_Helper_Contact extends Bronto_Common_Helper_Data
|
9 |
{
|
10 |
/**
|
11 |
+
* @param string $email
|
12 |
+
* @param string $customSource
|
13 |
+
* @param int $store
|
14 |
* @return Bronto_Api_Contact_Row
|
15 |
*/
|
16 |
public function getContactByEmail($email, $customSource = null, $store = null)
|
24 |
$contactObject = $api->getContactObject();
|
25 |
|
26 |
// Load Contact
|
27 |
+
$contact = $contactObject->createRow(array('email' => $email));
|
28 |
$contact->email = $email;
|
29 |
try {
|
30 |
$contact = $contact->read();
|
42 |
|
43 |
/**
|
44 |
* @param Bronto_Api_Contact_Row $contact
|
45 |
+
* @param bool $persistOnly
|
46 |
* @return Bronto_Api_Contact_Row
|
47 |
*/
|
48 |
public function saveContact(Bronto_Api_Contact_Row $contact, $persistOnly = false)
|
app/code/community/Bronto/Common/Helper/Data.php
CHANGED
@@ -5,8 +5,10 @@
|
|
5 |
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
* @version 1.6.7
|
7 |
*/
|
8 |
-
class Bronto_Common_Helper_Data
|
|
|
9 |
{
|
|
|
10 |
const XML_PATH_GLOBAL_SETTINGS = 'bronto/settings/';
|
11 |
const XML_PATH_API_TOKEN = 'bronto/settings/api_token';
|
12 |
const XML_PATH_DEBUG = 'bronto/settings/debug';
|
@@ -14,103 +16,249 @@ class Bronto_Common_Helper_Data extends Mage_Core_Helper_Abstract
|
|
14 |
const XML_PATH_TEST = 'bronto/settings/test';
|
15 |
const XML_PATH_NOTICES = 'bronto/settings/notices';
|
16 |
const XML_PATH_ENABLED = 'bronto/settings/enabled';
|
17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
/**
|
19 |
* @param string $path
|
20 |
-
*
|
21 |
-
* @
|
22 |
-
* @return mixed
|
23 |
*/
|
24 |
-
public function
|
25 |
{
|
26 |
-
|
27 |
-
|
28 |
-
} elseif (!is_null($websiteId)) {
|
29 |
-
$website = Mage::app()->getWebsite($websiteId);
|
30 |
-
return $website->getConfig($path);
|
31 |
-
}
|
32 |
|
33 |
-
|
34 |
-
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
}
|
45 |
}
|
46 |
|
47 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
* @return bool
|
52 |
*/
|
53 |
-
public function
|
54 |
{
|
55 |
-
return (bool)
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
-
*
|
|
|
|
|
60 |
*
|
61 |
-
* @
|
62 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
* @return boolean
|
64 |
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
65 |
public function varifyRequirements($module, $required = array())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
66 |
{
|
67 |
// Check for required PHP extensions
|
68 |
-
$verified
|
69 |
-
$missing
|
70 |
$defaultRequired = array('soap', 'openssl');
|
71 |
-
$required
|
|
|
72 |
|
73 |
/*
|
74 |
* Run through PHP extensions to see if they are loaded
|
75 |
* if no, add them to the list of missing and set verified = false flag
|
76 |
*/
|
77 |
foreach ($required as $extName) {
|
78 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
$missing[] = $extName;
|
80 |
-
$verified =
|
81 |
}
|
82 |
}
|
83 |
|
84 |
// If not verified, create a message telling the user what they are missing
|
85 |
if (!$verified) {
|
86 |
// If module is enabled, disable it
|
87 |
-
if ($
|
88 |
Mage::helper($module)->disableModule();
|
89 |
}
|
90 |
// Create message informing of missing extensions
|
91 |
$message = Mage::getSingleton('core/message')->error(
|
92 |
-
|
93 |
sprintf(
|
94 |
-
'The module "'
|
|
|
|
|
95 |
implode(',', $missing)
|
96 |
)
|
97 |
)
|
98 |
);
|
99 |
$message->setIdentifier($module);
|
100 |
Mage::getSingleton('adminhtml/session')->addMessage($message);
|
101 |
-
|
|
|
102 |
}
|
103 |
|
104 |
-
return
|
105 |
}
|
106 |
|
107 |
/**
|
108 |
* @param string $token
|
109 |
* @param int $store
|
110 |
* @param int $websiteId
|
|
|
111 |
* @return Bronto_Common_Model_Api
|
112 |
*/
|
113 |
-
public function getApi($token =
|
114 |
{
|
115 |
if (empty($token)) {
|
116 |
$token = $this->getApiToken($store, $websiteId);
|
@@ -119,30 +267,49 @@ class Bronto_Common_Helper_Data extends Mage_Core_Helper_Abstract
|
|
119 |
return Bronto_Common_Model_Api::getInstance($token);
|
120 |
}
|
121 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
122 |
/**
|
123 |
* Determine if API token is valid
|
124 |
*
|
125 |
-
* @param string
|
126 |
-
* @param int
|
127 |
-
* @param int
|
|
|
128 |
* @return boolean
|
129 |
*/
|
130 |
-
public function validApiToken($token =
|
131 |
{
|
132 |
if (empty($token)) {
|
133 |
$token = $this->getApiToken($store, $websiteId);
|
134 |
}
|
135 |
|
136 |
if (strlen($token) < 36) {
|
137 |
-
return
|
138 |
}
|
139 |
try {
|
140 |
-
$api = new Bronto_Api($token, array('debug' =>
|
141 |
$api->login();
|
142 |
-
} catch (Exception $e) {
|
143 |
-
return false;
|
144 |
}
|
145 |
-
|
|
|
|
|
|
|
|
|
146 |
}
|
147 |
|
148 |
/**
|
@@ -151,35 +318,46 @@ class Bronto_Common_Helper_Data extends Mage_Core_Helper_Abstract
|
|
151 |
*/
|
152 |
public function validApiTokens($identifier = 'bronto_common')
|
153 |
{
|
154 |
-
$valid =
|
155 |
if (!$this->validApiToken()) {
|
156 |
$message = Mage::getSingleton('core/message')->error(
|
157 |
-
|
158 |
);
|
159 |
$message->setIdentifier($identifier);
|
160 |
Mage::getSingleton('adminhtml/session')->addMessage($message);
|
161 |
-
$valid =
|
162 |
}
|
163 |
foreach (Mage::app()->getWebsites() as $website) {
|
164 |
-
if (!$this->validApiToken(
|
165 |
$message = Mage::getSingleton('core/message')->error(
|
166 |
-
|
|
|
|
|
|
|
|
|
|
|
167 |
);
|
168 |
$message->setIdentifier($identifier);
|
169 |
Mage::getSingleton('adminhtml/session')->addMessage($message);
|
170 |
-
$valid =
|
171 |
}
|
172 |
foreach ($website->getGroups() as $group) {
|
173 |
$stores = $group->getStores();
|
174 |
if (count($stores) > 0) {
|
175 |
foreach ($stores as $store) {
|
176 |
-
if (!$this->validApiToken(
|
177 |
$message = Mage::getSingleton('core/message')->error(
|
178 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
179 |
);
|
180 |
$message->setIdentifier($identifier);
|
181 |
Mage::getSingleton('adminhtml/session')->addMessage($message);
|
182 |
-
$valid =
|
183 |
}
|
184 |
}
|
185 |
}
|
@@ -191,13 +369,14 @@ class Bronto_Common_Helper_Data extends Mage_Core_Helper_Abstract
|
|
191 |
|
192 |
/**
|
193 |
* @param string $moduleName
|
|
|
194 |
* @return bool
|
195 |
*/
|
196 |
-
public function isModuleInstalled($moduleName =
|
197 |
{
|
198 |
$modules = (array) Mage::getConfig()->getNode('modules')->children();
|
199 |
|
200 |
-
if ($moduleName ===
|
201 |
$moduleName = $this->_getModuleName();
|
202 |
}
|
203 |
|
@@ -206,63 +385,18 @@ class Bronto_Common_Helper_Data extends Mage_Core_Helper_Abstract
|
|
206 |
|
207 |
/**
|
208 |
* @param string $moduleName
|
|
|
209 |
* @return string
|
210 |
*/
|
211 |
-
public function getModuleVersion($moduleName =
|
212 |
{
|
213 |
$modules = (array) Mage::getConfig()->getNode('modules')->children();
|
214 |
|
215 |
-
if ($moduleName ===
|
216 |
$moduleName = $this->_getModuleName();
|
217 |
}
|
218 |
|
219 |
-
return isset($modules[$moduleName]) ? (string) $modules[$moduleName]->version :
|
220 |
-
}
|
221 |
-
|
222 |
-
/**
|
223 |
-
* @param string $store
|
224 |
-
* @return string
|
225 |
-
*/
|
226 |
-
public function getApiToken($store = null, $websiteId = null)
|
227 |
-
{
|
228 |
-
$token = $this->getAdminScopedConfig(self::XML_PATH_API_TOKEN, $store, $websiteId);
|
229 |
-
|
230 |
-
if (!$token || empty($token)) {
|
231 |
-
return false;
|
232 |
-
}
|
233 |
-
|
234 |
-
return $token;
|
235 |
-
}
|
236 |
-
|
237 |
-
/**
|
238 |
-
* @param string $store
|
239 |
-
* @return Bronto_Api_ApiToken_Row
|
240 |
-
*/
|
241 |
-
public function getApiTokenRow($store = null)
|
242 |
-
{
|
243 |
-
if (!($token = $this->getApiToken($store))) {
|
244 |
-
return false;
|
245 |
-
}
|
246 |
-
|
247 |
-
if ($api = $this->getApi($token)) {
|
248 |
-
if (!$api->isAuthenticated()) {
|
249 |
-
return false;
|
250 |
-
}
|
251 |
-
} else {
|
252 |
-
return false;
|
253 |
-
}
|
254 |
-
|
255 |
-
$apiTokenObject = $api->getApiTokenObject();
|
256 |
-
$apiToken = $apiTokenObject->createRow();
|
257 |
-
$apiToken->id = $token;
|
258 |
-
try {
|
259 |
-
$apiToken->read();
|
260 |
-
} catch (Exception $e) {
|
261 |
-
$this->writeError($e);
|
262 |
-
return false;
|
263 |
-
}
|
264 |
-
|
265 |
-
return $apiToken;
|
266 |
}
|
267 |
|
268 |
/**
|
@@ -270,11 +404,11 @@ class Bronto_Common_Helper_Data extends Mage_Core_Helper_Abstract
|
|
270 |
*/
|
271 |
public function isDebugEnabled()
|
272 |
{
|
273 |
-
if (!$this->getApiToken()){
|
274 |
-
return
|
275 |
}
|
276 |
|
277 |
-
return (bool)
|
278 |
}
|
279 |
|
280 |
/**
|
@@ -283,10 +417,10 @@ class Bronto_Common_Helper_Data extends Mage_Core_Helper_Abstract
|
|
283 |
public function isVerboseEnabled()
|
284 |
{
|
285 |
if (!$this->isDebugEnabled()) {
|
286 |
-
return
|
287 |
}
|
288 |
|
289 |
-
return (bool)
|
290 |
}
|
291 |
|
292 |
/**
|
@@ -294,11 +428,11 @@ class Bronto_Common_Helper_Data extends Mage_Core_Helper_Abstract
|
|
294 |
*/
|
295 |
public function isTestModeEnabled()
|
296 |
{
|
297 |
-
if (!$this->getApiToken()){
|
298 |
-
return
|
299 |
}
|
300 |
|
301 |
-
return (bool)
|
302 |
}
|
303 |
|
304 |
/**
|
@@ -306,54 +440,20 @@ class Bronto_Common_Helper_Data extends Mage_Core_Helper_Abstract
|
|
306 |
*/
|
307 |
public function isNoticesEnabled()
|
308 |
{
|
309 |
-
if (!$this->getApiToken()){
|
310 |
-
return
|
311 |
}
|
312 |
|
313 |
-
return (bool)
|
314 |
-
}
|
315 |
-
|
316 |
-
/**
|
317 |
-
* @param string $path
|
318 |
-
* @param string $scope
|
319 |
-
* @param int $scopeId
|
320 |
-
* @return bool
|
321 |
-
*/
|
322 |
-
protected function _disableModule($path, $scope = 'default', $scopeId = 0)
|
323 |
-
{
|
324 |
-
$config = Mage::getModel('core/config');
|
325 |
-
$config->saveConfig($path, 0, $scope, $scopeId);
|
326 |
-
|
327 |
-
$version = Mage::getVersionInfo();
|
328 |
-
if ( 1 == $version['major']
|
329 |
-
&& (9 != $version['minor'] && 10 != $version['minor'])
|
330 |
-
) {
|
331 |
-
// Get the Module alias from the path
|
332 |
-
// $path = bronto_email/settings/api_token
|
333 |
-
// $module = bronto_email
|
334 |
-
list($module) = explode('/', $path);
|
335 |
-
// we have to physically insert the enabled path into the
|
336 |
-
// core_config_data table of the DB w/ a value of 0, or the module
|
337 |
-
// could inherit from its parent and not actually get disabled.
|
338 |
-
// b/c the state of the checkbox is determined by whether or not
|
339 |
-
// a value is set in the core_config_data table.
|
340 |
-
$configData = Mage::getModel('core/config_data');
|
341 |
-
$configData->setScope($scope)
|
342 |
-
->setScopeId($scopeId)
|
343 |
-
->setPath("$module/settings/enabled")
|
344 |
-
->setValue(0)
|
345 |
-
->save();
|
346 |
-
}
|
347 |
-
|
348 |
-
return $this;
|
349 |
}
|
350 |
|
351 |
/**
|
352 |
* @param string $message
|
353 |
* @param string|null $file
|
|
|
354 |
* @return bool|void
|
355 |
*/
|
356 |
-
public function writeDebug($message, $file =
|
357 |
{
|
358 |
if ($verbose && !$this->isVerboseEnabled()) {
|
359 |
return;
|
@@ -367,40 +467,45 @@ class Bronto_Common_Helper_Data extends Mage_Core_Helper_Abstract
|
|
367 |
/**
|
368 |
* @param string $message
|
369 |
* @param string|null $file
|
|
|
370 |
* @return bool|void
|
371 |
*/
|
372 |
-
public function writeVerboseDebug($message, $file =
|
373 |
{
|
374 |
if ($this->isVerboseEnabled()) {
|
375 |
-
return $this->writeDebug($message, $file,
|
376 |
}
|
377 |
}
|
378 |
|
379 |
/**
|
380 |
* @param string $message
|
381 |
* @param string|null $file
|
|
|
382 |
* @return bool|void
|
383 |
*/
|
384 |
-
public function writeInfo($message, $file =
|
385 |
{
|
386 |
if ($this->isNoticesEnabled()) {
|
387 |
if (Mage::getSingleton('admin/session')->isLoggedIn()) {
|
388 |
/* @var $message Mage_Core_Model_Message_Notice */
|
389 |
$message = Mage::getSingleton('core/message')->notice("[Bronto] {$message}");
|
390 |
Mage::getSingleton('adminhtml/session')->addMessage($message);
|
391 |
-
}
|
|
|
392 |
Mage::getSingleton('core/session')->addNotice("[Bronto] {$message}");
|
393 |
}
|
394 |
}
|
|
|
395 |
return $this->writeLog($message, $file, Zend_Log::INFO);
|
396 |
}
|
397 |
|
398 |
/**
|
399 |
* @param Exception|string $message
|
400 |
* @param string|null $file
|
|
|
401 |
* @return bool|void
|
402 |
*/
|
403 |
-
public function writeError($message, $file =
|
404 |
{
|
405 |
if (is_object($message) && $message instanceOf Exception) {
|
406 |
$message = $message->getMessage();
|
@@ -410,10 +515,12 @@ class Bronto_Common_Helper_Data extends Mage_Core_Helper_Abstract
|
|
410 |
/* @var $message Mage_Core_Model_Message_Error */
|
411 |
$message = Mage::getSingleton('core/message')->error("[Bronto] {$message}");
|
412 |
Mage::getSingleton('adminhtml/session')->addMessage($message);
|
413 |
-
}
|
|
|
414 |
Mage::getSingleton('core/session')->addError("[Bronto] {$message}");
|
415 |
}
|
416 |
}
|
|
|
417 |
return $this->writeLog($message, $file, Zend_Log::ERR);
|
418 |
}
|
419 |
|
@@ -421,9 +528,10 @@ class Bronto_Common_Helper_Data extends Mage_Core_Helper_Abstract
|
|
421 |
* @param string $message
|
422 |
* @param string|null $file
|
423 |
* @param int $level
|
|
|
424 |
* @return bool|void
|
425 |
*/
|
426 |
-
public function writeLog($message, $file =
|
427 |
{
|
428 |
if (empty($file)) {
|
429 |
$file = strtolower($this->_getModuleName()) . '.log';
|
@@ -431,84 +539,387 @@ class Bronto_Common_Helper_Data extends Mage_Core_Helper_Abstract
|
|
431 |
if (!is_string($message)) {
|
432 |
if (method_exists($message, '__toString')) {
|
433 |
$message = $message->__toString();
|
434 |
-
}
|
435 |
-
|
|
|
436 |
}
|
437 |
}
|
438 |
-
|
439 |
-
|
440 |
-
if (strtolower($this->_getModuleName()) == 'bronto_common') {
|
441 |
-
$this->_advancedLogging($level, $file);
|
442 |
-
}
|
443 |
-
|
444 |
-
return Mage::log($message, $level, $file, true);
|
445 |
}
|
446 |
-
|
447 |
/**
|
448 |
-
*
|
449 |
-
*
|
450 |
-
* @param
|
451 |
-
*
|
|
|
452 |
*/
|
453 |
-
protected function
|
454 |
{
|
455 |
-
//
|
456 |
-
$
|
457 |
-
|
458 |
-
|
459 |
-
// Log PHP version
|
460 |
-
if (phpversion()) {
|
461 |
-
$message .= 'PHP v' . phpversion() . ' - ';
|
462 |
}
|
463 |
-
|
464 |
-
|
465 |
-
|
|
|
|
|
466 |
}
|
467 |
-
|
468 |
-
//
|
469 |
-
|
470 |
-
$message .= 'Installed Modules: ' . $modules;
|
471 |
-
|
472 |
-
Mage::log($message, $level, $file, true);
|
473 |
}
|
474 |
-
|
475 |
/**
|
476 |
* Get list of active custom modules
|
477 |
-
* @return
|
478 |
*/
|
479 |
-
|
480 |
{
|
481 |
$moduleList = array();
|
482 |
-
$modules
|
483 |
-
|
484 |
foreach ($modules as $name => $module) {
|
485 |
-
if (strpos($name, 'Mage_') === FALSE && strpos($name, 'Enterprise_') === FALSE &&
|
|
|
|
|
486 |
$moduleList[] = $name . ' [v' . $module->version . ' codePool: ' . $module->codePool . ']';
|
487 |
}
|
488 |
}
|
489 |
-
|
490 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
491 |
}
|
492 |
-
|
493 |
/**
|
494 |
* Get Array of Store Ids based on current store/website/group
|
495 |
* @return boolean|array
|
496 |
*/
|
497 |
public function getStoreIds()
|
498 |
{
|
499 |
-
|
500 |
-
|
501 |
-
|
502 |
-
|
503 |
-
|
504 |
-
|
505 |
-
|
506 |
-
|
507 |
-
|
508 |
-
|
509 |
-
|
510 |
-
|
511 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
512 |
return $storeIds;
|
513 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
514 |
}
|
5 |
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
* @version 1.6.7
|
7 |
*/
|
8 |
+
class Bronto_Common_Helper_Data
|
9 |
+
extends Mage_Core_Helper_Abstract
|
10 |
{
|
11 |
+
|
12 |
const XML_PATH_GLOBAL_SETTINGS = 'bronto/settings/';
|
13 |
const XML_PATH_API_TOKEN = 'bronto/settings/api_token';
|
14 |
const XML_PATH_DEBUG = 'bronto/settings/debug';
|
16 |
const XML_PATH_TEST = 'bronto/settings/test';
|
17 |
const XML_PATH_NOTICES = 'bronto/settings/notices';
|
18 |
const XML_PATH_ENABLED = 'bronto/settings/enabled';
|
19 |
+
|
20 |
+
const XML_PATH_IMAGE_TYPE = 'bronto/format/image_type';
|
21 |
+
const XML_PATH_IMAGE_WIDTH = 'bronto/format/image_width';
|
22 |
+
const XML_PATH_IMAGE_HEIGHT = 'bronto/format/image_height';
|
23 |
+
const XML_PATH_USE_SYMBOL = 'bronto/format/use_symbol';
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @return bool
|
27 |
+
*/
|
28 |
+
public function isEnabled()
|
29 |
+
{
|
30 |
+
return (bool) $this->getAdminScopedConfig(self::XML_PATH_ENABLED);
|
31 |
+
}
|
32 |
+
|
33 |
+
/*
|
34 |
+
* Get Text to display in notice when enabling module
|
35 |
+
*
|
36 |
+
* @return string
|
37 |
+
*/
|
38 |
+
public function getModuleEnabledText()
|
39 |
+
{
|
40 |
+
return $this->__('If you have changed your API token, please ensure you reconfigure all available options.');
|
41 |
+
}
|
42 |
+
|
43 |
/**
|
44 |
* @param string $path
|
45 |
+
*
|
46 |
+
* @return bool
|
|
|
47 |
*/
|
48 |
+
public function disableModule($scope = 'default', $scopeId = 0)
|
49 |
{
|
50 |
+
return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId);
|
51 |
+
}
|
|
|
|
|
|
|
|
|
52 |
|
53 |
+
/**
|
54 |
+
* Determine if email can be sent through bronto
|
55 |
+
*
|
56 |
+
* @param Mage_Core_Model_Email_Template $template
|
57 |
+
*
|
58 |
+
* @return boolean
|
59 |
+
*/
|
60 |
+
public function canSendBronto(Mage_Core_Model_Email_Template $template, $storeId = null)
|
61 |
+
{
|
62 |
+
if ($this->isEnabled($storeId)) {
|
63 |
+
return TRUE;
|
|
|
64 |
}
|
65 |
|
66 |
+
return FALSE;
|
67 |
+
}
|
68 |
+
|
69 |
+
/**
|
70 |
+
* @return string
|
71 |
+
*/
|
72 |
+
public function getProductImageUrl($product)
|
73 |
+
{
|
74 |
+
return (string) Mage::helper('catalog/image')
|
75 |
+
->init($product, $this->getImageType($product->getStoreId()))
|
76 |
+
->resize(
|
77 |
+
$this->getImageWidth($product->getStoreId()),
|
78 |
+
$this->getImageHeight($product->getStoreId())
|
79 |
+
);
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* @return string
|
84 |
+
*/
|
85 |
+
public function getImageType($storeId = null)
|
86 |
+
{
|
87 |
+
return $this->getAdminScopedConfig(self::XML_PATH_IMAGE_TYPE, $storeId);
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* @return int|null
|
92 |
+
*/
|
93 |
+
public function getImageWidth($storeId = null)
|
94 |
+
{
|
95 |
+
$width = (int) $this->getAdminScopedConfig(self::XML_PATH_IMAGE_WIDTH, $storeId);
|
96 |
+
|
97 |
+
return empty($width) ? NULL : abs($width);
|
98 |
+
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* @return int|null
|
102 |
+
*/
|
103 |
+
public function getImageHeight($storeId = null)
|
104 |
+
{
|
105 |
+
$height = (int) $this->getAdminScopedConfig(self::XML_PATH_IMAGE_HEIGHT, $storeId);
|
106 |
+
|
107 |
+
return empty($height) ? NULL : abs($height);
|
108 |
}
|
109 |
|
110 |
/**
|
111 |
* @return bool
|
112 |
*/
|
113 |
+
public function useCurrenySymbol($storeId = null)
|
114 |
{
|
115 |
+
return (bool) $this->getAdminScopedConfig(self::XML_PATH_USE_SYMBOL, $storeId);
|
116 |
}
|
117 |
|
118 |
/**
|
119 |
+
* @param string $path
|
120 |
+
* @param string $scope
|
121 |
+
* @param int $scopeId
|
122 |
*
|
123 |
+
* @return bool
|
124 |
+
*/
|
125 |
+
protected function _disableModule($path, $scope = 'default', $scopeId = 0)
|
126 |
+
{
|
127 |
+
$config = Mage::getModel('core/config');
|
128 |
+
$config->saveConfig($path, 0, $scope, $scopeId);
|
129 |
+
|
130 |
+
if (!$this->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, 9, 10))) {
|
131 |
+
// Get the Module alias from the path
|
132 |
+
// $path = bronto_email/settings/api_token
|
133 |
+
// $module = bronto_email
|
134 |
+
list($module) = explode('/', $path);
|
135 |
+
// we have to physically insert the enabled path into the
|
136 |
+
// core_config_data table of the DB w/ a value of 0, or the module
|
137 |
+
// could inherit from its parent and not actually get disabled.
|
138 |
+
// b/c the state of the checkbox is determined by whether or not
|
139 |
+
// a value is set in the core_config_data table.
|
140 |
+
$configData = Mage::getModel('core/config_data');
|
141 |
+
$configData->setScope($scope)
|
142 |
+
->setScopeId($scopeId)
|
143 |
+
->setPath("$module/settings/enabled")
|
144 |
+
->setValue(0)
|
145 |
+
->save();
|
146 |
+
}
|
147 |
+
|
148 |
+
return $this;
|
149 |
+
}
|
150 |
+
|
151 |
+
/**
|
152 |
+
* Determine if module is active
|
153 |
* @return boolean
|
154 |
*/
|
155 |
+
public function isModuleActive()
|
156 |
+
{
|
157 |
+
// If module is not enabled, return false
|
158 |
+
if (!$this->isEnabled()) {
|
159 |
+
return FALSE;
|
160 |
+
}
|
161 |
+
|
162 |
+
// If module is missing token, return false
|
163 |
+
if (!$this->getApiToken()) {
|
164 |
+
return FALSE;
|
165 |
+
}
|
166 |
+
|
167 |
+
// If requirements are not met, return false
|
168 |
+
if (!$this->verifyRequirements($this->_getModuleName())) {
|
169 |
+
return FALSE;
|
170 |
+
}
|
171 |
+
|
172 |
+
return TRUE;
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Does this helper have custom config?
|
177 |
+
*
|
178 |
+
* @return boolean
|
179 |
+
*/
|
180 |
+
public function hasCustomConfig()
|
181 |
+
{
|
182 |
+
return FALSE;
|
183 |
+
}
|
184 |
+
|
185 |
+
/**
|
186 |
+
* @deprecated since version 1.6.7
|
187 |
+
* @see verifyRequirements
|
188 |
+
*/
|
189 |
public function varifyRequirements($module, $required = array())
|
190 |
+
{
|
191 |
+
return $this->verifyRequirements($module, $required);
|
192 |
+
}
|
193 |
+
|
194 |
+
/**
|
195 |
+
* Verify that all required PHP extensions are loaded
|
196 |
+
*
|
197 |
+
* @param string $module
|
198 |
+
* @param array $required
|
199 |
+
*
|
200 |
+
* @return boolean
|
201 |
+
*/
|
202 |
+
public function verifyRequirements($module, $required = array())
|
203 |
{
|
204 |
// Check for required PHP extensions
|
205 |
+
$verified = TRUE;
|
206 |
+
$missing = array();
|
207 |
$defaultRequired = array('soap', 'openssl');
|
208 |
+
$required = array_merge($required, $defaultRequired);
|
209 |
+
$module = strtolower($module);
|
210 |
|
211 |
/*
|
212 |
* Run through PHP extensions to see if they are loaded
|
213 |
* if no, add them to the list of missing and set verified = false flag
|
214 |
*/
|
215 |
foreach ($required as $extName) {
|
216 |
+
try {
|
217 |
+
if (!extension_loaded($extName)) {
|
218 |
+
$missing[] = $extName;
|
219 |
+
$verified = FALSE;
|
220 |
+
}
|
221 |
+
}
|
222 |
+
catch (Exception $e) {
|
223 |
$missing[] = $extName;
|
224 |
+
$verified = FALSE;
|
225 |
}
|
226 |
}
|
227 |
|
228 |
// If not verified, create a message telling the user what they are missing
|
229 |
if (!$verified) {
|
230 |
// If module is enabled, disable it
|
231 |
+
if (Mage::helper($module)->isEnabled()) {
|
232 |
Mage::helper($module)->disableModule();
|
233 |
}
|
234 |
// Create message informing of missing extensions
|
235 |
$message = Mage::getSingleton('core/message')->error(
|
236 |
+
$this->__(
|
237 |
sprintf(
|
238 |
+
'The module "' .
|
239 |
+
$module .
|
240 |
+
'" has been automatically disabled due to missing PHP extensions: %s',
|
241 |
implode(',', $missing)
|
242 |
)
|
243 |
)
|
244 |
);
|
245 |
$message->setIdentifier($module);
|
246 |
Mage::getSingleton('adminhtml/session')->addMessage($message);
|
247 |
+
|
248 |
+
return FALSE;
|
249 |
}
|
250 |
|
251 |
+
return TRUE;
|
252 |
}
|
253 |
|
254 |
/**
|
255 |
* @param string $token
|
256 |
* @param int $store
|
257 |
* @param int $websiteId
|
258 |
+
*
|
259 |
* @return Bronto_Common_Model_Api
|
260 |
*/
|
261 |
+
public function getApi($token = NULL, $store = NULL, $websiteId = NULL)
|
262 |
{
|
263 |
if (empty($token)) {
|
264 |
$token = $this->getApiToken($store, $websiteId);
|
267 |
return Bronto_Common_Model_Api::getInstance($token);
|
268 |
}
|
269 |
|
270 |
+
/**
|
271 |
+
* @param string $store
|
272 |
+
*
|
273 |
+
* @return string
|
274 |
+
*/
|
275 |
+
public function getApiToken($store = NULL, $websiteId = NULL)
|
276 |
+
{
|
277 |
+
$token = $this->getAdminScopedConfig(self::XML_PATH_API_TOKEN, $store, $websiteId);
|
278 |
+
|
279 |
+
if (!$token || empty($token)) {
|
280 |
+
return FALSE;
|
281 |
+
}
|
282 |
+
|
283 |
+
return $token;
|
284 |
+
}
|
285 |
+
|
286 |
/**
|
287 |
* Determine if API token is valid
|
288 |
*
|
289 |
+
* @param string $token
|
290 |
+
* @param int $store
|
291 |
+
* @param int $websiteId
|
292 |
+
*
|
293 |
* @return boolean
|
294 |
*/
|
295 |
+
public function validApiToken($token = NULL, $store = NULL, $websiteId = NULL)
|
296 |
{
|
297 |
if (empty($token)) {
|
298 |
$token = $this->getApiToken($store, $websiteId);
|
299 |
}
|
300 |
|
301 |
if (strlen($token) < 36) {
|
302 |
+
return FALSE;
|
303 |
}
|
304 |
try {
|
305 |
+
$api = new Bronto_Api($token, array('debug' => TRUE));
|
306 |
$api->login();
|
|
|
|
|
307 |
}
|
308 |
+
catch (Exception $e) {
|
309 |
+
return FALSE;
|
310 |
+
}
|
311 |
+
|
312 |
+
return TRUE;
|
313 |
}
|
314 |
|
315 |
/**
|
318 |
*/
|
319 |
public function validApiTokens($identifier = 'bronto_common')
|
320 |
{
|
321 |
+
$valid = TRUE;
|
322 |
if (!$this->validApiToken()) {
|
323 |
$message = Mage::getSingleton('core/message')->error(
|
324 |
+
$this->__('The Bronto API Token you have entered for Default Configuration appears to be invalid.')
|
325 |
);
|
326 |
$message->setIdentifier($identifier);
|
327 |
Mage::getSingleton('adminhtml/session')->addMessage($message);
|
328 |
+
$valid = FALSE;
|
329 |
}
|
330 |
foreach (Mage::app()->getWebsites() as $website) {
|
331 |
+
if (!$this->validApiToken(NULL, NULL, $website->getId())) {
|
332 |
$message = Mage::getSingleton('core/message')->error(
|
333 |
+
$this->__(
|
334 |
+
sprintf(
|
335 |
+
'The Bronto API Token you have entered for website "%s" appears to be invalid.',
|
336 |
+
$website->getName()
|
337 |
+
)
|
338 |
+
)
|
339 |
);
|
340 |
$message->setIdentifier($identifier);
|
341 |
Mage::getSingleton('adminhtml/session')->addMessage($message);
|
342 |
+
$valid = FALSE;
|
343 |
}
|
344 |
foreach ($website->getGroups() as $group) {
|
345 |
$stores = $group->getStores();
|
346 |
if (count($stores) > 0) {
|
347 |
foreach ($stores as $store) {
|
348 |
+
if (!$this->validApiToken(NULL, $store->getId(), $website->getId())) {
|
349 |
$message = Mage::getSingleton('core/message')->error(
|
350 |
+
$this->__(
|
351 |
+
sprintf(
|
352 |
+
'The Bronto API Token you have entered for store "%s" on website "%s" appears to be invalid.',
|
353 |
+
$store->getName(),
|
354 |
+
$website->getName()
|
355 |
+
)
|
356 |
+
)
|
357 |
);
|
358 |
$message->setIdentifier($identifier);
|
359 |
Mage::getSingleton('adminhtml/session')->addMessage($message);
|
360 |
+
$valid = FALSE;
|
361 |
}
|
362 |
}
|
363 |
}
|
369 |
|
370 |
/**
|
371 |
* @param string $moduleName
|
372 |
+
*
|
373 |
* @return bool
|
374 |
*/
|
375 |
+
public function isModuleInstalled($moduleName = NULL)
|
376 |
{
|
377 |
$modules = (array) Mage::getConfig()->getNode('modules')->children();
|
378 |
|
379 |
+
if ($moduleName === NULL) {
|
380 |
$moduleName = $this->_getModuleName();
|
381 |
}
|
382 |
|
385 |
|
386 |
/**
|
387 |
* @param string $moduleName
|
388 |
+
*
|
389 |
* @return string
|
390 |
*/
|
391 |
+
public function getModuleVersion($moduleName = NULL)
|
392 |
{
|
393 |
$modules = (array) Mage::getConfig()->getNode('modules')->children();
|
394 |
|
395 |
+
if ($moduleName === NULL) {
|
396 |
$moduleName = $this->_getModuleName();
|
397 |
}
|
398 |
|
399 |
+
return isset($modules[$moduleName]) ? (string) $modules[$moduleName]->version : NULL;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
400 |
}
|
401 |
|
402 |
/**
|
404 |
*/
|
405 |
public function isDebugEnabled()
|
406 |
{
|
407 |
+
if (!$this->getApiToken()) {
|
408 |
+
return FALSE;
|
409 |
}
|
410 |
|
411 |
+
return (bool) $this->getAdminScopedConfig(self::XML_PATH_DEBUG);
|
412 |
}
|
413 |
|
414 |
/**
|
417 |
public function isVerboseEnabled()
|
418 |
{
|
419 |
if (!$this->isDebugEnabled()) {
|
420 |
+
return FALSE;
|
421 |
}
|
422 |
|
423 |
+
return (bool) $this->getAdminScopedConfig(self::XML_PATH_VERBOSE);
|
424 |
}
|
425 |
|
426 |
/**
|
428 |
*/
|
429 |
public function isTestModeEnabled()
|
430 |
{
|
431 |
+
if (!$this->getApiToken()) {
|
432 |
+
return FALSE;
|
433 |
}
|
434 |
|
435 |
+
return (bool) $this->getAdminScopedConfig(self::XML_PATH_TEST);
|
436 |
}
|
437 |
|
438 |
/**
|
440 |
*/
|
441 |
public function isNoticesEnabled()
|
442 |
{
|
443 |
+
if (!$this->getApiToken()) {
|
444 |
+
return FALSE;
|
445 |
}
|
446 |
|
447 |
+
return (bool) $this->getAdminScopedConfig(self::XML_PATH_NOTICES);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
448 |
}
|
449 |
|
450 |
/**
|
451 |
* @param string $message
|
452 |
* @param string|null $file
|
453 |
+
*
|
454 |
* @return bool|void
|
455 |
*/
|
456 |
+
public function writeDebug($message, $file = NULL, $verbose = FALSE)
|
457 |
{
|
458 |
if ($verbose && !$this->isVerboseEnabled()) {
|
459 |
return;
|
467 |
/**
|
468 |
* @param string $message
|
469 |
* @param string|null $file
|
470 |
+
*
|
471 |
* @return bool|void
|
472 |
*/
|
473 |
+
public function writeVerboseDebug($message, $file = NULL)
|
474 |
{
|
475 |
if ($this->isVerboseEnabled()) {
|
476 |
+
return $this->writeDebug($message, $file, TRUE);
|
477 |
}
|
478 |
}
|
479 |
|
480 |
/**
|
481 |
* @param string $message
|
482 |
* @param string|null $file
|
483 |
+
*
|
484 |
* @return bool|void
|
485 |
*/
|
486 |
+
public function writeInfo($message, $file = NULL)
|
487 |
{
|
488 |
if ($this->isNoticesEnabled()) {
|
489 |
if (Mage::getSingleton('admin/session')->isLoggedIn()) {
|
490 |
/* @var $message Mage_Core_Model_Message_Notice */
|
491 |
$message = Mage::getSingleton('core/message')->notice("[Bronto] {$message}");
|
492 |
Mage::getSingleton('adminhtml/session')->addMessage($message);
|
493 |
+
}
|
494 |
+
else {
|
495 |
Mage::getSingleton('core/session')->addNotice("[Bronto] {$message}");
|
496 |
}
|
497 |
}
|
498 |
+
|
499 |
return $this->writeLog($message, $file, Zend_Log::INFO);
|
500 |
}
|
501 |
|
502 |
/**
|
503 |
* @param Exception|string $message
|
504 |
* @param string|null $file
|
505 |
+
*
|
506 |
* @return bool|void
|
507 |
*/
|
508 |
+
public function writeError($message, $file = NULL)
|
509 |
{
|
510 |
if (is_object($message) && $message instanceOf Exception) {
|
511 |
$message = $message->getMessage();
|
515 |
/* @var $message Mage_Core_Model_Message_Error */
|
516 |
$message = Mage::getSingleton('core/message')->error("[Bronto] {$message}");
|
517 |
Mage::getSingleton('adminhtml/session')->addMessage($message);
|
518 |
+
}
|
519 |
+
else {
|
520 |
Mage::getSingleton('core/session')->addError("[Bronto] {$message}");
|
521 |
}
|
522 |
}
|
523 |
+
|
524 |
return $this->writeLog($message, $file, Zend_Log::ERR);
|
525 |
}
|
526 |
|
528 |
* @param string $message
|
529 |
* @param string|null $file
|
530 |
* @param int $level
|
531 |
+
*
|
532 |
* @return bool|void
|
533 |
*/
|
534 |
+
public function writeLog($message, $file = NULL, $level = Zend_Log::DEBUG)
|
535 |
{
|
536 |
if (empty($file)) {
|
537 |
$file = strtolower($this->_getModuleName()) . '.log';
|
539 |
if (!is_string($message)) {
|
540 |
if (method_exists($message, '__toString')) {
|
541 |
$message = $message->__toString();
|
542 |
+
}
|
543 |
+
else {
|
544 |
+
return FALSE;
|
545 |
}
|
546 |
}
|
547 |
+
|
548 |
+
return Mage::log($message, $level, $this->_stampFile($file), TRUE);
|
|
|
|
|
|
|
|
|
|
|
549 |
}
|
550 |
+
|
551 |
/**
|
552 |
+
* Add Date Stamp to log file name
|
553 |
+
*
|
554 |
+
* @param type $filename
|
555 |
+
*
|
556 |
+
* @return type
|
557 |
*/
|
558 |
+
protected function _stampFile($filename, $withTime = TRUE)
|
559 |
{
|
560 |
+
// Ensure var/log/bronto exists
|
561 |
+
$logDir = Mage::getBaseDir('var') . DS . 'log' . DS . 'bronto';
|
562 |
+
if (!is_dir($logDir)) {
|
563 |
+
mkdir($logDir, 0777, TRUE);
|
|
|
|
|
|
|
564 |
}
|
565 |
+
|
566 |
+
// If time stamp requested, append
|
567 |
+
if ($withTime) {
|
568 |
+
$stamp = date('Ymd', time());
|
569 |
+
$filename = str_replace('.', ".{$stamp}.", $filename);
|
570 |
}
|
571 |
+
|
572 |
+
// replace bronto_ with bronto/ to place in folder
|
573 |
+
return str_replace('bronto_', 'bronto' . DS, $filename);
|
|
|
|
|
|
|
574 |
}
|
575 |
+
|
576 |
/**
|
577 |
* Get list of active custom modules
|
578 |
+
* @return array
|
579 |
*/
|
580 |
+
public function getInstalledModules()
|
581 |
{
|
582 |
$moduleList = array();
|
583 |
+
$modules = Mage::getConfig()->getNode('modules')->children();
|
584 |
+
|
585 |
foreach ($modules as $name => $module) {
|
586 |
+
if (strpos($name, 'Mage_') === FALSE && strpos($name, 'Enterprise_') === FALSE &&
|
587 |
+
$module->active == 'true'
|
588 |
+
) {
|
589 |
$moduleList[] = $name . ' [v' . $module->version . ' codePool: ' . $module->codePool . ']';
|
590 |
}
|
591 |
}
|
592 |
+
|
593 |
+
return $moduleList;
|
594 |
+
}
|
595 |
+
|
596 |
+
/**
|
597 |
+
* Get array of current scope parameters
|
598 |
+
* @return array
|
599 |
+
*/
|
600 |
+
public function getScopeParams()
|
601 |
+
{
|
602 |
+
// Get Request Object
|
603 |
+
$request = Mage::app()->getRequest();
|
604 |
+
|
605 |
+
// Define Scope Params
|
606 |
+
$scopeParams = array(
|
607 |
+
'scope' => 'default',
|
608 |
+
'default' => 0,
|
609 |
+
'default_id' => 0,
|
610 |
+
'store' => $request->getParam('store', FALSE),
|
611 |
+
'store_id' => 0,
|
612 |
+
'website' => $request->getParam('website', FALSE),
|
613 |
+
'website_id' => 0,
|
614 |
+
'group' => $request->getParam('group', FALSE),
|
615 |
+
'group_id' => 0,
|
616 |
+
);
|
617 |
+
|
618 |
+
// Update Scope based on what has been set
|
619 |
+
if ($scopeParams['store']) {
|
620 |
+
$store = Mage::app()->getStore($scopeParams['store']);
|
621 |
+
if ($store->getId()) {
|
622 |
+
$scopeParams['store_id'] = $store->getId();
|
623 |
+
}
|
624 |
+
$scopeParams['scope'] = 'store';
|
625 |
+
}
|
626 |
+
elseif ($scopeParams['website']) {
|
627 |
+
$website = Mage::app()->getWebsite($scopeParams['website']);
|
628 |
+
if ($website->getId()) {
|
629 |
+
$scopeParams['website_id'] = $website->getId();
|
630 |
+
}
|
631 |
+
$scopeParams['scope'] = 'website';
|
632 |
+
}
|
633 |
+
elseif ($scopeParams['group']) {
|
634 |
+
$group = Mage::app()->getGroup($scopeParams['group']);
|
635 |
+
if ($group->getId()) {
|
636 |
+
$scopeParams['group_id'] = $group->getId();
|
637 |
+
}
|
638 |
+
$scopeParams['scope'] = 'group';
|
639 |
+
}
|
640 |
+
|
641 |
+
// Return array of Scope Params
|
642 |
+
return $scopeParams;
|
643 |
+
}
|
644 |
+
|
645 |
+
/**
|
646 |
+
* Get Url with scope data included
|
647 |
+
*
|
648 |
+
* @param string $url
|
649 |
+
*
|
650 |
+
* @return string
|
651 |
+
*/
|
652 |
+
public function getScopeUrl($url, $scopeParams = array())
|
653 |
+
{
|
654 |
+
$curScopeParams = $this->getScopeParams();
|
655 |
+
$curScope = array(
|
656 |
+
'scope' => $curScopeParams['scope'],
|
657 |
+
$curScopeParams['scope'] => $curScopeParams[$curScopeParams['scope']],
|
658 |
+
);
|
659 |
+
$scopeParams = array_merge($scopeParams, $curScope);
|
660 |
+
|
661 |
+
return Mage::helper('adminhtml')->getUrl($url, $scopeParams);
|
662 |
+
}
|
663 |
+
|
664 |
+
/**
|
665 |
+
* @param string $path
|
666 |
+
* @param mixed $store
|
667 |
+
* @param int $websiteId
|
668 |
+
*
|
669 |
+
* @return mixed
|
670 |
+
*/
|
671 |
+
public function getAdminScopedConfig($path, $store = NULL, $websiteId = NULL)
|
672 |
+
{
|
673 |
+
if (!is_null($store)) {
|
674 |
+
return Mage::getStoreConfig($path, $store);
|
675 |
+
}
|
676 |
+
elseif (!is_null($websiteId)) {
|
677 |
+
$website = Mage::app()->getWebsite($websiteId);
|
678 |
+
|
679 |
+
return $website->getConfig($path);
|
680 |
+
}
|
681 |
+
|
682 |
+
$scopeParams = $this->getScopeParams();
|
683 |
+
$source = FALSE;
|
684 |
+
|
685 |
+
switch ($scopeParams['scope']) {
|
686 |
+
case 'store':
|
687 |
+
$source = Mage::app()->getStore($scopeParams['store']);
|
688 |
+
break;
|
689 |
+
case 'website':
|
690 |
+
$source = Mage::app()->getWebsite($scopeParams['website']);
|
691 |
+
break;
|
692 |
+
case 'group':
|
693 |
+
$source = Mage::app()->getGroup($scopeParams['group'])->getWebsite();
|
694 |
+
break;
|
695 |
+
default:
|
696 |
+
return Mage::getStoreConfig($path);
|
697 |
+
break;
|
698 |
+
}
|
699 |
+
|
700 |
+
if ($source) {
|
701 |
+
return $source->getConfig($path);
|
702 |
+
}
|
703 |
+
|
704 |
+
return Mage::getStoreConfig($path);
|
705 |
}
|
706 |
+
|
707 |
/**
|
708 |
* Get Array of Store Ids based on current store/website/group
|
709 |
* @return boolean|array
|
710 |
*/
|
711 |
public function getStoreIds()
|
712 |
{
|
713 |
+
$scopeParams = $this->getScopeParams();
|
714 |
+
|
715 |
+
switch ($scopeParams['scope']) {
|
716 |
+
case 'store':
|
717 |
+
$source = Mage::app()->getStore($scopeParams['store']);
|
718 |
+
$storeIds = $source->getId();
|
719 |
+
break;
|
720 |
+
case 'website':
|
721 |
+
$source = Mage::app()->getWebsite($scopeParams['website']);
|
722 |
+
$storeIds = $source->getStoreIds();
|
723 |
+
break;
|
724 |
+
case 'group':
|
725 |
+
$source = Mage::app()->getGroup($scopeParams['group'])->getWebsite();
|
726 |
+
$storeIds = $source->getStoreIds();
|
727 |
+
break;
|
728 |
+
default:
|
729 |
+
$storeIds = array_keys(Mage::app()->getStores(TRUE));
|
730 |
+
break;
|
731 |
+
}
|
732 |
+
|
733 |
return $storeIds;
|
734 |
}
|
735 |
+
|
736 |
+
/**
|
737 |
+
* Is this the Enterprise edition?
|
738 |
+
*
|
739 |
+
* @return boolean
|
740 |
+
*/
|
741 |
+
public function isEnterpriseEdition()
|
742 |
+
{
|
743 |
+
return ('Enterprise' == $this->getEdition());
|
744 |
+
}
|
745 |
+
|
746 |
+
/**
|
747 |
+
* Get Edition from version Info
|
748 |
+
*
|
749 |
+
* @param array|boolean $versionInfo
|
750 |
+
*
|
751 |
+
* @return string|boolean
|
752 |
+
*/
|
753 |
+
public function getEdition($versionInfo = FALSE)
|
754 |
+
{
|
755 |
+
// Ensure we have version info
|
756 |
+
if (!$versionInfo || !is_array($versionInfo)) {
|
757 |
+
if (method_exists('Mage', 'getEdition')) {
|
758 |
+
return Mage::getEdition();
|
759 |
+
}
|
760 |
+
$versionInfo = Mage::getVersionInfo();
|
761 |
+
}
|
762 |
+
|
763 |
+
// Get Edition from version
|
764 |
+
if (array_key_exists('major', $versionInfo) && array_key_exists('minor', $versionInfo)) {
|
765 |
+
$major = $versionInfo['major'];
|
766 |
+
$minor = $versionInfo['minor'];
|
767 |
+
|
768 |
+
if (1 == $major) {
|
769 |
+
if ($minor < 9) {
|
770 |
+
return 'Community';
|
771 |
+
}
|
772 |
+
else if ($minor >= 9 && $minor < 11) {
|
773 |
+
return 'Professional';
|
774 |
+
}
|
775 |
+
else if ($minor >= 11) {
|
776 |
+
return 'Enterprise';
|
777 |
+
}
|
778 |
+
}
|
779 |
+
}
|
780 |
+
|
781 |
+
return FALSE;
|
782 |
+
}
|
783 |
+
|
784 |
+
/**
|
785 |
+
* Takes major and minor version info and determines if current magento install matches
|
786 |
+
*
|
787 |
+
* @param array $versionInfo
|
788 |
+
* @param int|string|array $major
|
789 |
+
* @param int|string|array $minor
|
790 |
+
* @param int|string|array $revision (Optional)
|
791 |
+
* @param int|string|array $patch (Optional)
|
792 |
+
* @param string $edition (Optional) 'CE'|'Community'|'PE'|'Professional'|'EE'|'Enterprise'
|
793 |
+
*
|
794 |
+
* @return boolean
|
795 |
+
*/
|
796 |
+
public function isVersionMatch()
|
797 |
+
{
|
798 |
+
/**
|
799 |
+
* Get arguments passed to function
|
800 |
+
*
|
801 |
+
* [0] = Magento Version Array (Required)
|
802 |
+
* [1] = Compare Major Version (Optional)
|
803 |
+
* [2] = Compare Minor Version (Optional)
|
804 |
+
* [3] = Compare Revision Number (Optional)
|
805 |
+
* [4] = Compare Patch Number (Optional)
|
806 |
+
* [5] = Compare Edition (Optional)
|
807 |
+
*/
|
808 |
+
$parts = $this->_mapVersionParts(func_get_args());
|
809 |
+
|
810 |
+
// At least version info and one other
|
811 |
+
if (!array_key_exists('versionInfo', $parts) || count($parts) < 2) {
|
812 |
+
return FALSE;
|
813 |
+
}
|
814 |
+
|
815 |
+
// Get Magento Version from passed arguments
|
816 |
+
$mageVersion = $parts['versionInfo'];
|
817 |
+
$mageVersion['edition'] = $this->getEdition($mageVersion);
|
818 |
+
unset($parts['versionInfo']);
|
819 |
+
|
820 |
+
// Cycle through the elements of the magento version
|
821 |
+
foreach ($mageVersion as $index => $mValue) {
|
822 |
+
// If the compare value doesn't exist for this index, continue
|
823 |
+
if (!isset($parts[$index])) {
|
824 |
+
continue;
|
825 |
+
}
|
826 |
+
|
827 |
+
// Get compare value
|
828 |
+
$value = $parts[$index];
|
829 |
+
// Ensure Value is an array
|
830 |
+
if (!is_array($value)) {
|
831 |
+
$value = array($value);
|
832 |
+
}
|
833 |
+
|
834 |
+
// Cycle through compare value array to compare against
|
835 |
+
// current Magento version element
|
836 |
+
$internalMatch = FALSE;
|
837 |
+
foreach ($value as $option) {
|
838 |
+
$operator = '==';
|
839 |
+
$compare = $option;
|
840 |
+
|
841 |
+
// If the current compare value is an array,
|
842 |
+
// get the operator and value provided
|
843 |
+
if (is_array($option)) {
|
844 |
+
list ($operator, $compare) = $option;
|
845 |
+
}
|
846 |
+
|
847 |
+
if ($index == 'edition') {
|
848 |
+
// handle posibility of initials being used
|
849 |
+
switch (strtoupper($compare)) {
|
850 |
+
case 'EE':
|
851 |
+
$compare = 'Enterprise';
|
852 |
+
break;
|
853 |
+
case 'CE':
|
854 |
+
$compare = 'Community';
|
855 |
+
break;
|
856 |
+
case 'PE':
|
857 |
+
$compare = 'Professional';
|
858 |
+
break;
|
859 |
+
default:
|
860 |
+
break;
|
861 |
+
}
|
862 |
+
|
863 |
+
// If response from getEdition matches compare edition
|
864 |
+
$internalMatch = ($mValue == $compare);
|
865 |
+
}
|
866 |
+
else {
|
867 |
+
// Use version_compare to compare the Magento version to the
|
868 |
+
// Current compare version using the provided operator
|
869 |
+
$internalMatch = version_compare($mValue, $compare, $operator);
|
870 |
+
}
|
871 |
+
|
872 |
+
if ($internalMatch) {
|
873 |
+
break;
|
874 |
+
}
|
875 |
+
}
|
876 |
+
|
877 |
+
// If the internal Match flag hasn't been set to true,
|
878 |
+
// there is no match
|
879 |
+
if (!$internalMatch) {
|
880 |
+
return FALSE;
|
881 |
+
}
|
882 |
+
}
|
883 |
+
|
884 |
+
// If we haven't returned false yet, that means there is a match
|
885 |
+
return TRUE;
|
886 |
+
}
|
887 |
+
|
888 |
+
/**
|
889 |
+
* Maps parts array to expected array
|
890 |
+
*
|
891 |
+
* @param array $parts
|
892 |
+
*
|
893 |
+
* @return array
|
894 |
+
*/
|
895 |
+
private function _mapVersionParts($parts)
|
896 |
+
{
|
897 |
+
// Parts must be array
|
898 |
+
if (!is_array($parts)) {
|
899 |
+
return FALSE;
|
900 |
+
}
|
901 |
+
|
902 |
+
// Generate index map values
|
903 |
+
$mapKeys = array(
|
904 |
+
'versionInfo' => 0,
|
905 |
+
'major' => 1,
|
906 |
+
'minor' => 2,
|
907 |
+
'revision' => 3,
|
908 |
+
'patch' => 4,
|
909 |
+
'edition' => 5,
|
910 |
+
);
|
911 |
+
|
912 |
+
// Placeholder array
|
913 |
+
$versionParts = array();
|
914 |
+
|
915 |
+
// Cycle Through and map values as needed
|
916 |
+
foreach ($mapKeys as $map => $index) {
|
917 |
+
if (array_key_exists($index, $parts) && !is_null($parts[$index])) {
|
918 |
+
$versionParts[$map] = $parts[$index];
|
919 |
+
}
|
920 |
+
}
|
921 |
+
|
922 |
+
// Return Mapped Array
|
923 |
+
return $versionParts;
|
924 |
+
}
|
925 |
}
|
app/code/community/Bronto/Common/Helper/DataInterface.php
CHANGED
@@ -11,7 +11,7 @@ interface Bronto_Common_Helper_DataInterface
|
|
11 |
* Disable the module in the admin configuration
|
12 |
*
|
13 |
* @param string $scope
|
14 |
-
* @param int
|
15 |
* @return bool
|
16 |
*/
|
17 |
public function disableModule($scope = 'default', $scopeId = 0);
|
11 |
* Disable the module in the admin configuration
|
12 |
*
|
13 |
* @param string $scope
|
14 |
+
* @param int $scopeId
|
15 |
* @return bool
|
16 |
*/
|
17 |
public function disableModule($scope = 'default', $scopeId = 0);
|
app/code/community/Bronto/Common/Helper/Field.php
CHANGED
@@ -8,8 +8,8 @@
|
|
8 |
class Bronto_Common_Helper_Field extends Bronto_Common_Helper_Data
|
9 |
{
|
10 |
/**
|
11 |
-
* @param string
|
12 |
-
* @param array
|
13 |
* @return Bronto_Api_Field_Row
|
14 |
*/
|
15 |
public function getFieldByName($name, $options)
|
@@ -19,9 +19,9 @@ class Bronto_Common_Helper_Field extends Bronto_Common_Helper_Data
|
|
19 |
|
20 |
if (!($field = $fieldObject->getFromCache($name))) {
|
21 |
$field = $fieldObject->createRow();
|
22 |
-
$field->name
|
23 |
$field->label = $options['label'];
|
24 |
-
$field->type
|
25 |
if (!empty($options['options'])) {
|
26 |
$field->options = $options['options'];
|
27 |
}
|
8 |
class Bronto_Common_Helper_Field extends Bronto_Common_Helper_Data
|
9 |
{
|
10 |
/**
|
11 |
+
* @param string $name
|
12 |
+
* @param array $options
|
13 |
* @return Bronto_Api_Field_Row
|
14 |
*/
|
15 |
public function getFieldByName($name, $options)
|
19 |
|
20 |
if (!($field = $fieldObject->getFromCache($name))) {
|
21 |
$field = $fieldObject->createRow();
|
22 |
+
$field->name = $name;
|
23 |
$field->label = $options['label'];
|
24 |
+
$field->type = $options['type'];
|
25 |
if (!empty($options['options'])) {
|
26 |
$field->options = $options['options'];
|
27 |
}
|
app/code/community/Bronto/Common/Helper/Message.php
CHANGED
@@ -42,15 +42,18 @@ class Bronto_Common_Helper_Message extends Bronto_Common_Helper_Data
|
|
42 |
continue;
|
43 |
}
|
44 |
foreach ($stores as $store) {
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
51 |
}
|
52 |
}
|
53 |
}
|
|
|
54 |
$existingValues = array();
|
55 |
foreach ($messageOptions as $key => $option) {
|
56 |
if (!in_array($option['value'], $existingValues)) {
|
@@ -68,7 +71,7 @@ class Bronto_Common_Helper_Message extends Bronto_Common_Helper_Data
|
|
68 |
*
|
69 |
* @return array
|
70 |
*/
|
71 |
-
public function getMessagesOptionsArray($store = null, $websiteId = null)
|
72 |
{
|
73 |
/* @var $api Bronto_Api */
|
74 |
$api = $this->getApi(null, $store, $websiteId);
|
@@ -77,15 +80,15 @@ class Bronto_Common_Helper_Message extends Bronto_Common_Helper_Data
|
|
77 |
/* @var $messageObject Bronto_Api_Message */
|
78 |
$messageObject = $api->getMessageObject();
|
79 |
|
80 |
-
$options
|
81 |
$pageNumber = 1;
|
82 |
|
83 |
try {
|
84 |
-
while ($messages = $messageObject->readAll(
|
85 |
if ($messages->count() <= 0) {
|
86 |
break;
|
87 |
}
|
88 |
-
foreach ($messages as $message
|
89 |
if ($message->status == 'active') {
|
90 |
$options[] = array(
|
91 |
'label' => $message->name,
|
@@ -99,10 +102,24 @@ class Bronto_Common_Helper_Message extends Bronto_Common_Helper_Data
|
|
99 |
Mage::helper('bronto_common')->writeError($e);
|
100 |
}
|
101 |
}
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
|
107 |
return $options;
|
108 |
}
|
42 |
continue;
|
43 |
}
|
44 |
foreach ($stores as $store) {
|
45 |
+
if (Mage::helper('bronto_email')->isEnabled($store->getId())) {
|
46 |
+
$storeMessages = Mage::helper('bronto_common/message')
|
47 |
+
->getMessagesOptionsArray(
|
48 |
+
$store->getId(),
|
49 |
+
$website->getId()
|
50 |
+
);
|
51 |
+
$messageOptions = array_merge($messageOptions, $storeMessages);
|
52 |
+
}
|
53 |
}
|
54 |
}
|
55 |
}
|
56 |
+
|
57 |
$existingValues = array();
|
58 |
foreach ($messageOptions as $key => $option) {
|
59 |
if (!in_array($option['value'], $existingValues)) {
|
71 |
*
|
72 |
* @return array
|
73 |
*/
|
74 |
+
public function getMessagesOptionsArray($store = null, $websiteId = null, $filter = array(), $withCreateNew = false)
|
75 |
{
|
76 |
/* @var $api Bronto_Api */
|
77 |
$api = $this->getApi(null, $store, $websiteId);
|
80 |
/* @var $messageObject Bronto_Api_Message */
|
81 |
$messageObject = $api->getMessageObject();
|
82 |
|
83 |
+
$options = array();
|
84 |
$pageNumber = 1;
|
85 |
|
86 |
try {
|
87 |
+
while ($messages = $messageObject->readAll($filter, false, $pageNumber)) {
|
88 |
if ($messages->count() <= 0) {
|
89 |
break;
|
90 |
}
|
91 |
+
foreach ($messages as $message/* @var $message Bronto_Api_Message_Row */) {
|
92 |
if ($message->status == 'active') {
|
93 |
$options[] = array(
|
94 |
'label' => $message->name,
|
102 |
Mage::helper('bronto_common')->writeError($e);
|
103 |
}
|
104 |
}
|
105 |
+
|
106 |
+
if ($withCreateNew) {
|
107 |
+
// Add Create New.. Option
|
108 |
+
array_unshift($options, array(
|
109 |
+
'label' => '** Create New...',
|
110 |
+
'value' => '_new_'
|
111 |
+
));
|
112 |
+
} else {
|
113 |
+
// Add -- None Selected -- Option
|
114 |
+
array_unshift($options, array(
|
115 |
+
'label' => '-- None Selected --',
|
116 |
+
'value' => ''
|
117 |
+
));
|
118 |
+
}
|
119 |
+
|
120 |
+
|
121 |
+
// Sort Alphabetically
|
122 |
+
sort($options);
|
123 |
|
124 |
return $options;
|
125 |
}
|
app/code/community/Bronto/Common/Helper/Product.php
CHANGED
@@ -7,6 +7,7 @@
|
|
7 |
*/
|
8 |
class Bronto_Common_Helper_Product extends Mage_Core_Helper_Abstract
|
9 |
{
|
|
|
10 |
/**
|
11 |
* @var array
|
12 |
*/
|
@@ -23,9 +24,9 @@ class Bronto_Common_Helper_Product extends Mage_Core_Helper_Abstract
|
|
23 |
*
|
24 |
* @link https://github.com/leek/zf-components/blob/master/library/Leek/Config.php
|
25 |
* @param string $subject Template string
|
26 |
-
* @param array
|
27 |
* @param string $delimiter Template parameter delimiter (must be valid without escaping in a regular expression)
|
28 |
-
* @param bool
|
29 |
* @return string
|
30 |
* @static
|
31 |
*/
|
@@ -48,7 +49,7 @@ class Bronto_Common_Helper_Product extends Mage_Core_Helper_Abstract
|
|
48 |
/**
|
49 |
* @param string $subject
|
50 |
* @param string $delimiter
|
51 |
-
* @param mixed
|
52 |
* @return array
|
53 |
*/
|
54 |
public function getTemplateVariables($subject, $delimiter = '%')
|
@@ -69,11 +70,13 @@ class Bronto_Common_Helper_Product extends Mage_Core_Helper_Abstract
|
|
69 |
* @param int $productId
|
70 |
* @return boolean|Mage_Catalog_Model_Product
|
71 |
*/
|
72 |
-
public function getProduct($productId)
|
73 |
{
|
74 |
if (is_int($productId) || is_string($productId)) {
|
75 |
-
if (isset($this->_productCache[$productId])) {
|
76 |
-
return $this->_productCache[$productId];
|
|
|
|
|
77 |
} else {
|
78 |
$product = Mage::getModel('catalog/product')->load($productId);
|
79 |
}
|
@@ -87,18 +90,18 @@ class Bronto_Common_Helper_Product extends Mage_Core_Helper_Abstract
|
|
87 |
$productId = $product->getId();
|
88 |
}
|
89 |
|
90 |
-
$this->_productCache[$productId] = $product;
|
91 |
return $product;
|
92 |
}
|
93 |
|
94 |
/**
|
95 |
* @param Mage_Catalog_Model_Product $product
|
96 |
-
* @param string
|
97 |
* @return mixed
|
98 |
*/
|
99 |
-
public function getProductAttribute($productId, $name)
|
100 |
{
|
101 |
-
if ($product = $this->getProduct($productId)) {
|
102 |
try {
|
103 |
switch ($name) {
|
104 |
case 'img':
|
@@ -135,4 +138,5 @@ class Bronto_Common_Helper_Product extends Mage_Core_Helper_Abstract
|
|
135 |
|
136 |
return false;
|
137 |
}
|
|
|
138 |
}
|
7 |
*/
|
8 |
class Bronto_Common_Helper_Product extends Mage_Core_Helper_Abstract
|
9 |
{
|
10 |
+
|
11 |
/**
|
12 |
* @var array
|
13 |
*/
|
24 |
*
|
25 |
* @link https://github.com/leek/zf-components/blob/master/library/Leek/Config.php
|
26 |
* @param string $subject Template string
|
27 |
+
* @param array $map Key / value pairs to substitute with
|
28 |
* @param string $delimiter Template parameter delimiter (must be valid without escaping in a regular expression)
|
29 |
+
* @param bool $blankIfNone Set to blank if none found
|
30 |
* @return string
|
31 |
* @static
|
32 |
*/
|
49 |
/**
|
50 |
* @param string $subject
|
51 |
* @param string $delimiter
|
52 |
+
* @param mixed $index
|
53 |
* @return array
|
54 |
*/
|
55 |
public function getTemplateVariables($subject, $delimiter = '%')
|
70 |
* @param int $productId
|
71 |
* @return boolean|Mage_Catalog_Model_Product
|
72 |
*/
|
73 |
+
public function getProduct($productId, $storeId = false)
|
74 |
{
|
75 |
if (is_int($productId) || is_string($productId)) {
|
76 |
+
if (isset($this->_productCache[$storeId][$productId])) {
|
77 |
+
return $this->_productCache[$storeId][$productId];
|
78 |
+
} elseif ($storeId) {
|
79 |
+
$product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($productId);
|
80 |
} else {
|
81 |
$product = Mage::getModel('catalog/product')->load($productId);
|
82 |
}
|
90 |
$productId = $product->getId();
|
91 |
}
|
92 |
|
93 |
+
$this->_productCache[$storeId][$productId] = $product;
|
94 |
return $product;
|
95 |
}
|
96 |
|
97 |
/**
|
98 |
* @param Mage_Catalog_Model_Product $product
|
99 |
+
* @param string $name
|
100 |
* @return mixed
|
101 |
*/
|
102 |
+
public function getProductAttribute($productId, $name, $storeId = false)
|
103 |
{
|
104 |
+
if ($product = $this->getProduct($productId, $storeId)) {
|
105 |
try {
|
106 |
switch ($name) {
|
107 |
case 'img':
|
138 |
|
139 |
return false;
|
140 |
}
|
141 |
+
|
142 |
}
|
app/code/community/Bronto/Common/Helper/Support.php
ADDED
@@ -0,0 +1,446 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
// Process registration
|
10 |
+
protected $_registrationUrl = 'https://brontops.com/register/magento';
|
11 |
+
|
12 |
+
// Last time the support information was pushed
|
13 |
+
protected $_lastRun;
|
14 |
+
protected $_client;
|
15 |
+
|
16 |
+
protected $_supportFormFields = array(
|
17 |
+
'site_name',
|
18 |
+
'firstname',
|
19 |
+
'lastname',
|
20 |
+
'email',
|
21 |
+
'number',
|
22 |
+
'title',
|
23 |
+
'using_solution_partner',
|
24 |
+
'partner',
|
25 |
+
'magento_version',
|
26 |
+
'magento_edition',
|
27 |
+
'extension_version',
|
28 |
+
);
|
29 |
+
|
30 |
+
/**
|
31 |
+
* @return bool
|
32 |
+
*/
|
33 |
+
public function isRegistered() {
|
34 |
+
return (bool) $this->getAdminScopedConfig(self::XML_PATH_REGISTERED);
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @return int
|
39 |
+
*/
|
40 |
+
public function getLastRunTimestamp() {
|
41 |
+
if (is_null($this->_lastRun)) {
|
42 |
+
$lastRun = $this->getAdminScopedConfig(self::XML_PATH_LAST_RUN);
|
43 |
+
$this->_lastRun = $lastRun ? $lastRun : 0;
|
44 |
+
}
|
45 |
+
|
46 |
+
return $this->_lastRun;
|
47 |
+
}
|
48 |
+
|
49 |
+
/**
|
50 |
+
* Set the registration value for this extension
|
51 |
+
*
|
52 |
+
* @param boolean $register
|
53 |
+
* @return Mage_Core_Helper_Data
|
54 |
+
*/
|
55 |
+
public function setRegistered($register = true) {
|
56 |
+
$config = Mage::getModel('core/config');
|
57 |
+
$config->saveConfig(self::XML_PATH_REGISTERED, $register ? '1' : '0', 'default', 0);
|
58 |
+
|
59 |
+
// Force the register to pickup immediately
|
60 |
+
Mage::getConfig()->reinit();
|
61 |
+
Mage::app()->reinitStores();
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Set the last run time for this extension
|
67 |
+
*
|
68 |
+
* @param string $date
|
69 |
+
* return Mage_Core_Helper_Data
|
70 |
+
*/
|
71 |
+
public function setLastRunDate($date) {
|
72 |
+
$this->_lastRun = Mage::getModel('core/date')->timestamp($date);
|
73 |
+
|
74 |
+
$config = Mage::getModel('core/config');
|
75 |
+
$config->saveConfig(self::XML_PATH_LAST_RUN, $this->_lastRun, 'default', 0);
|
76 |
+
|
77 |
+
return $this;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Retrieves some support information
|
82 |
+
*
|
83 |
+
* @return array
|
84 |
+
*/
|
85 |
+
public function getSupportInformation() {
|
86 |
+
$data = array();
|
87 |
+
foreach ($this->_supportFormFields as $key) {
|
88 |
+
switch ($key) {
|
89 |
+
case 'extension_version':
|
90 |
+
$value = 'v' . $this->getModuleVersion();
|
91 |
+
break;
|
92 |
+
case 'magento_version':
|
93 |
+
$value = 'v' . Mage::getVersion();
|
94 |
+
break;
|
95 |
+
case 'magento_edition':
|
96 |
+
$value = $this->getEdition();
|
97 |
+
break;
|
98 |
+
default:
|
99 |
+
$value = $this->getAdminScopedConfig(self::XML_PATH_SUPPORT . "/$key");
|
100 |
+
}
|
101 |
+
$data[$key] = $value ? $value : '';
|
102 |
+
}
|
103 |
+
return $data;
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Determines if this last run is a day old
|
108 |
+
*
|
109 |
+
* @param string $currentDate
|
110 |
+
* @return boolean
|
111 |
+
*/
|
112 |
+
public function isLastRunDifferent($currentDate) {
|
113 |
+
$lastRun = $this->getLastRunTimestamp();
|
114 |
+
return $lastRun != Mage::getModel('core/date')->timestamp($currentDate);
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Gets the number of the reminder rules
|
119 |
+
*
|
120 |
+
* @param string $currentDate
|
121 |
+
* @return int
|
122 |
+
*/
|
123 |
+
public function getActiveReminderRules($currentDate) {
|
124 |
+
return Mage::getModel('bronto_reminder/rule')
|
125 |
+
->getCollection()
|
126 |
+
->addDateFilter($currentDate)
|
127 |
+
->addIsActiveFilter(1)
|
128 |
+
->count();
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* Returns debug information as a collection
|
133 |
+
*
|
134 |
+
* @return array
|
135 |
+
*/
|
136 |
+
public function getDebugInformation() {
|
137 |
+
$currentDate = Mage::getModel('core/date')->date('Y-m-d');
|
138 |
+
$brontoModules = $this->getEnabledBrontoModules();
|
139 |
+
$formData = $this->getSupportInformation();
|
140 |
+
$request = Mage::app()->getRequest();
|
141 |
+
|
142 |
+
return array_merge(
|
143 |
+
// Form submission
|
144 |
+
$formData,
|
145 |
+
// Current Websites / Stores; Enabled Bronto Modules
|
146 |
+
array(
|
147 |
+
// Client / Server information
|
148 |
+
'server_name' => $request->getServer('SERVER_NAME'),
|
149 |
+
'server_address' => $request->getServer('SERVER_ADDR'),
|
150 |
+
'server_protocol' => $request->getServer('SERVER_PROTOCOL'),
|
151 |
+
'php_version' => 'v' . phpversion(),
|
152 |
+
'mysql_version' => 'v' . Mage::getResourceModel('core/config')->getReadConnection()->getServerVersion(),
|
153 |
+
'number_active_rules' => $this->getActiveReminderRules($currentDate),
|
154 |
+
),
|
155 |
+
array(
|
156 |
+
// Installed Modules
|
157 |
+
'installed_modules' => $this->getInstalledModules(),
|
158 |
+
'magento_installation' => $this->getStoreInfo(),
|
159 |
+
),
|
160 |
+
array(
|
161 |
+
'bronto_modules' => $brontoModules,
|
162 |
+
'bronto_config' => $this->getBrontoConfigs($brontoModules)
|
163 |
+
)
|
164 |
+
);
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Submits the Support form information
|
169 |
+
*
|
170 |
+
* @param array $formData (Optional)
|
171 |
+
* @return boolean
|
172 |
+
*/
|
173 |
+
public function submitSupportForm($formData = array()) {
|
174 |
+
$currentDate = Mage::getModel('core/date')->date('Y-m-d');
|
175 |
+
$this->setLastRunDate($currentDate)->setRegistered();
|
176 |
+
|
177 |
+
$formData['extension_version'] = 'v' . $this->getModuleVersion();
|
178 |
+
$formData['magento_version'] = 'v' . Mage::getVersion();
|
179 |
+
$formData['magento_edition'] = $this->getEdition();
|
180 |
+
|
181 |
+
$yesNo = Mage::getModel('adminhtml/system_config_source_yesno');
|
182 |
+
$selectedValue = $formData['using_solution_partner'];
|
183 |
+
foreach ($yesNo->toOptionArray() as $option) {
|
184 |
+
if ($option['value'] == $selectedValue) {
|
185 |
+
$label = $option['label'];
|
186 |
+
break;
|
187 |
+
}
|
188 |
+
}
|
189 |
+
$formData['using_solution_partner'] = $label;
|
190 |
+
|
191 |
+
return $this->_submitWebform(
|
192 |
+
array_merge($this->getSupportInformation(), $formData)
|
193 |
+
);
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Gets the Bronto Modules install on the server
|
198 |
+
*
|
199 |
+
* @return array
|
200 |
+
*/
|
201 |
+
public function getEnabledBrontoModules() {
|
202 |
+
$brontoModules = array();
|
203 |
+
|
204 |
+
$modules = Mage::getConfig()->getNode('modules')->children();
|
205 |
+
foreach ($modules as $name => $module) {
|
206 |
+
if (
|
207 |
+
$module->active == 'true' &&
|
208 |
+
strpos($name, 'Bronto_') !== false &&
|
209 |
+
(
|
210 |
+
$name == 'Bronto_Common' ||
|
211 |
+
Mage::helper(strtolower($name))->isEnabled()
|
212 |
+
)
|
213 |
+
) {
|
214 |
+
$brontoModules[$name] = 'v' . $module->version;
|
215 |
+
}
|
216 |
+
}
|
217 |
+
|
218 |
+
return $brontoModules;
|
219 |
+
}
|
220 |
+
|
221 |
+
/**
|
222 |
+
* Gets the Bronto configuration settings
|
223 |
+
*
|
224 |
+
* @param array $brontoModules
|
225 |
+
* @return array
|
226 |
+
*/
|
227 |
+
public function getBrontoConfigs($brontoModules) {
|
228 |
+
$configs = array();
|
229 |
+
$processedConfigs = array();
|
230 |
+
|
231 |
+
foreach ($brontoModules as $name => $module) {
|
232 |
+
$helperName = strtolower($name);
|
233 |
+
|
234 |
+
$helper = Mage::helper($helperName);
|
235 |
+
$reflector = new ReflectionClass(get_class($helper));
|
236 |
+
|
237 |
+
$moduleConfig = array();
|
238 |
+
foreach ($reflector->getConstants() as $cName => $setting) {
|
239 |
+
if ($cName == 'XML_PATH_ENABLED' || isset($processedConfigs[$setting])) {
|
240 |
+
continue;
|
241 |
+
}
|
242 |
+
|
243 |
+
$settingNameParts = explode('/', $setting);
|
244 |
+
$settingName = end($settingNameParts);
|
245 |
+
|
246 |
+
$value = Mage::getStoreConfig($setting);
|
247 |
+
if (empty($settingName)) {
|
248 |
+
continue;
|
249 |
+
}
|
250 |
+
|
251 |
+
$processedConfigs[$setting] = $value;
|
252 |
+
$moduleConfig[$settingName] = $value;
|
253 |
+
}
|
254 |
+
|
255 |
+
if ($helper->hasCustomConfig()) {
|
256 |
+
$moduleConfig = array_merge($moduleConfig, $helper->getCustomConfig());
|
257 |
+
}
|
258 |
+
|
259 |
+
if ($moduleConfig) {
|
260 |
+
$configs["{$helperName}_config"] = $moduleConfig;
|
261 |
+
}
|
262 |
+
}
|
263 |
+
|
264 |
+
return $configs;
|
265 |
+
}
|
266 |
+
|
267 |
+
/**
|
268 |
+
* Retrieve website and store count
|
269 |
+
*
|
270 |
+
* @return array
|
271 |
+
*/
|
272 |
+
public function getStoreInfo() {
|
273 |
+
$storeInfo = array();
|
274 |
+
$websites = Mage::app()->getWebsites();
|
275 |
+
$totalWebsites = count($websites);
|
276 |
+
$totalStores = 0;
|
277 |
+
foreach ($websites as $website) {
|
278 |
+
$websiteStores = count($website->getStores());
|
279 |
+
$totalStores += $websiteStores;
|
280 |
+
$s = $websiteStores == 1 ? '' : 's';
|
281 |
+
$storeInfo[] = "A website with $websiteStores store$s.";
|
282 |
+
}
|
283 |
+
$websites = $totalWebsites == 1 ? 'website' : 'websites';
|
284 |
+
$stores = $totalStores == 1 ? 'store' : 'stores';
|
285 |
+
|
286 |
+
$storeInfo[] = "Total of $totalWebsites $websites and $totalStores $stores";
|
287 |
+
|
288 |
+
return $storeInfo;
|
289 |
+
}
|
290 |
+
|
291 |
+
/**
|
292 |
+
* Creates a log archive with the last 30 days of files in it
|
293 |
+
*
|
294 |
+
* @return Bronto_Common_Model_Archive
|
295 |
+
*/
|
296 |
+
public function getLogArchive() {
|
297 |
+
$logDir = Mage::getBaseDir('var') . DS . 'log';
|
298 |
+
$systemLog = $logDir . DS . 'system.log';
|
299 |
+
$exceptionLog = $logDir . DS . 'exception.log';
|
300 |
+
|
301 |
+
$brontoLogDir = $logDir . DS . 'bronto';
|
302 |
+
$tmpDir = $this->getArchiveDirectory();
|
303 |
+
$file = $tmpDir . DS . 'log.' . time() . '.zip';
|
304 |
+
|
305 |
+
$archive = Mage::getModel('bronto_common/archive');
|
306 |
+
if ($archive->open($file, ZipArchive::OVERWRITE)) {
|
307 |
+
$now = time();
|
308 |
+
$threshold = $now - (60 * 60 * 24 * 30);
|
309 |
+
|
310 |
+
$archive->addEmptyDir('log');
|
311 |
+
|
312 |
+
if (file_exists($systemLog)) {
|
313 |
+
$archive->addFromString('log/system.log', $this->_tailLog($systemLog));
|
314 |
+
}
|
315 |
+
|
316 |
+
if (file_exists($exceptionLog)) {
|
317 |
+
$archive->addFromString('log/exception.log', $this->_tailLog($exceptionLog));
|
318 |
+
}
|
319 |
+
|
320 |
+
$archive->addFromString('log/phpinfo.html', $this->getPhpInfoOutput());
|
321 |
+
$archive->addEmptyDir('log/bronto');
|
322 |
+
foreach (glob($brontoLogDir . DS . "*.log") as $logFile) {
|
323 |
+
$stat = lstat($logFile);
|
324 |
+
if ($stat['mtime'] < $threshold) {
|
325 |
+
continue;
|
326 |
+
}
|
327 |
+
$archive->addFile($logFile, 'log/bronto/' . basename($logFile));
|
328 |
+
}
|
329 |
+
$archive->close();
|
330 |
+
} else {
|
331 |
+
Mage::throwException('Could not create archive at ' . $file);
|
332 |
+
}
|
333 |
+
|
334 |
+
return $archive;
|
335 |
+
}
|
336 |
+
|
337 |
+
/**
|
338 |
+
* Tails a given log for output
|
339 |
+
*
|
340 |
+
* @param string $logFile
|
341 |
+
* @return string
|
342 |
+
*/
|
343 |
+
protected function _tailLog($logfile) {
|
344 |
+
$length = filesize($logfile);
|
345 |
+
$maxRead = (1 * 1000 * 100);
|
346 |
+
$fh = fopen($logfile, 'r');
|
347 |
+
if ($length > $maxRead) {
|
348 |
+
fseek($fh, $length - $maxRead);
|
349 |
+
}
|
350 |
+
$contents = fread($fh, $maxRead);
|
351 |
+
fclose($fh);
|
352 |
+
return $contents;
|
353 |
+
}
|
354 |
+
|
355 |
+
|
356 |
+
/**
|
357 |
+
* Gets the PHPInfo in string format
|
358 |
+
*
|
359 |
+
* @return string
|
360 |
+
*/
|
361 |
+
public function getPhpInfoOutput() {
|
362 |
+
ob_start();
|
363 |
+
phpinfo();
|
364 |
+
return ob_get_clean();
|
365 |
+
}
|
366 |
+
|
367 |
+
/**
|
368 |
+
* Gets the archive directory
|
369 |
+
*
|
370 |
+
* @return string
|
371 |
+
*/
|
372 |
+
public function getArchiveDirectory() {
|
373 |
+
$brontoLogDir = Mage::getBaseDir('var') . DS . 'log' . DS . 'bronto';
|
374 |
+
$tmpDir = $brontoLogDir . DS . 'archives';
|
375 |
+
if (!file_exists($tmpDir)) {
|
376 |
+
mkdir($tmpDir, 0777, true);
|
377 |
+
}
|
378 |
+
return $brontoLogDir . DS . 'archives';
|
379 |
+
}
|
380 |
+
|
381 |
+
/**
|
382 |
+
* Deletes all of the archive logs
|
383 |
+
*/
|
384 |
+
public function clearArchiveDirectory() {
|
385 |
+
foreach (glob($this->getArchiveDirectory() . DS . '*') as $file) {
|
386 |
+
unlink($file);
|
387 |
+
}
|
388 |
+
}
|
389 |
+
|
390 |
+
/**
|
391 |
+
* Sets the internal webform submission client
|
392 |
+
*
|
393 |
+
* @param Mage_HTTP_Client_Curl $client
|
394 |
+
* @return Bronto_Common_Helper_Support
|
395 |
+
*/
|
396 |
+
public function setHttpClient(Mage_HTTP_Client_Curl $client) {
|
397 |
+
$this->_client = $client;
|
398 |
+
return $this;
|
399 |
+
}
|
400 |
+
|
401 |
+
/**
|
402 |
+
* Returns the Curl client used to submit the webform
|
403 |
+
*
|
404 |
+
* @return Mage_HTTP_Client_Curl
|
405 |
+
*/
|
406 |
+
protected function _getHttpClient() {
|
407 |
+
if (empty($this->_client)) {
|
408 |
+
$this->_client = new Mage_HTTP_Client_Curl();
|
409 |
+
}
|
410 |
+
return $this->_client;
|
411 |
+
}
|
412 |
+
|
413 |
+
/**
|
414 |
+
* Submits a webform with the registeration info
|
415 |
+
*
|
416 |
+
* @param array $formData
|
417 |
+
* @return bool
|
418 |
+
*/
|
419 |
+
protected function _submitWebform(array $formData) {
|
420 |
+
|
421 |
+
$client = $this->_getHttpClient();
|
422 |
+
$params = array();
|
423 |
+
foreach ($this->_supportFormFields as $name) {
|
424 |
+
$parts = explode('_', $name);
|
425 |
+
$restCamel = array_map('ucfirst', array_slice($parts, 1));
|
426 |
+
$camel = implode('' , array_merge(array($parts[0]), $restCamel));
|
427 |
+
|
428 |
+
$params[$camel] = $formData[$name];
|
429 |
+
}
|
430 |
+
|
431 |
+
$json = Mage::helper('core')->jsonEncode($params);
|
432 |
+
|
433 |
+
try {
|
434 |
+
$client->setOptions(array(
|
435 |
+
CURLOPT_SSL_VERIFYPEER => 0,
|
436 |
+
CURLOPT_POSTFIELDS => $json
|
437 |
+
));
|
438 |
+
$client->post($this->_registrationUrl, $json);
|
439 |
+
} catch (Exception $e) {
|
440 |
+
$this->writeError('Registration submission failed: ', $e->getMessage());
|
441 |
+
return false;
|
442 |
+
}
|
443 |
+
|
444 |
+
return true;
|
445 |
+
}
|
446 |
+
}
|
app/code/community/Bronto/Common/Model/Api.php
CHANGED
@@ -17,8 +17,8 @@ class Bronto_Common_Model_Api extends Bronto_Api
|
|
17 |
// {{{ getInstance()
|
18 |
|
19 |
/**
|
20 |
-
* @param string
|
21 |
-
* @param bool
|
22 |
*
|
23 |
* @return Bronto_Common_Model_Api
|
24 |
* @access public
|
@@ -31,7 +31,7 @@ class Bronto_Common_Model_Api extends Bronto_Api
|
|
31 |
Mage::helper('bronto_common')->writeDebug("Initiating API for token: {$token}");
|
32 |
self::$_instances[$token] = new self($token, array(
|
33 |
'retry_limit' => 2,
|
34 |
-
'debug'
|
35 |
));
|
36 |
}
|
37 |
|
@@ -43,8 +43,8 @@ class Bronto_Common_Model_Api extends Bronto_Api
|
|
43 |
|
44 |
/**
|
45 |
* @param string|Exception $exception
|
46 |
-
* @param string
|
47 |
-
* @param string
|
48 |
*
|
49 |
* @return void
|
50 |
* @access public
|
17 |
// {{{ getInstance()
|
18 |
|
19 |
/**
|
20 |
+
* @param string $token
|
21 |
+
* @param bool $debug
|
22 |
*
|
23 |
* @return Bronto_Common_Model_Api
|
24 |
* @access public
|
31 |
Mage::helper('bronto_common')->writeDebug("Initiating API for token: {$token}");
|
32 |
self::$_instances[$token] = new self($token, array(
|
33 |
'retry_limit' => 2,
|
34 |
+
'debug' => $debug,
|
35 |
));
|
36 |
}
|
37 |
|
43 |
|
44 |
/**
|
45 |
* @param string|Exception $exception
|
46 |
+
* @param string $message
|
47 |
+
* @param string $code
|
48 |
*
|
49 |
* @return void
|
50 |
* @access public
|
app/code/community/Bronto/Common/Model/Archive.php
ADDED
@@ -0,0 +1,73 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bronto_Common_Model_Archive {
|
4 |
+
|
5 |
+
/**
|
6 |
+
* @var string
|
7 |
+
*/
|
8 |
+
protected $_filename;
|
9 |
+
|
10 |
+
/**
|
11 |
+
* @var ZipArchive
|
12 |
+
*/
|
13 |
+
protected $_zip;
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @var boolean
|
17 |
+
*/
|
18 |
+
protected $_isOpen = false;
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Get the archive filename
|
22 |
+
*
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
public function getFilename() {
|
26 |
+
return $this->_filename;
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Sets the underlying zip
|
31 |
+
*
|
32 |
+
* @param ZipArchive $zip
|
33 |
+
* @return Bronto_Common_Model_Archive
|
34 |
+
*/
|
35 |
+
public function setZip(ZipArchive $zip) {
|
36 |
+
if ($this->_isOpen) {
|
37 |
+
throw new InvalidArgumentException("Archiver is already open.");
|
38 |
+
}
|
39 |
+
$this->_zip = $zip;
|
40 |
+
return $this;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* @return ZipArchive
|
45 |
+
*/
|
46 |
+
public function getZip() {
|
47 |
+
if (is_null($this->_zip)) {
|
48 |
+
$this->setZip(new ZipArchive);
|
49 |
+
}
|
50 |
+
return $this->_zip;
|
51 |
+
}
|
52 |
+
|
53 |
+
|
54 |
+
/**
|
55 |
+
* Forwards calls to proxy object
|
56 |
+
* @param string $name
|
57 |
+
* @param array $args
|
58 |
+
* @return mixed
|
59 |
+
*/
|
60 |
+
public function __call($name, $args) {
|
61 |
+
$return = call_user_func_array(array($this->getZip(), $name), $args);
|
62 |
+
switch ($name) {
|
63 |
+
case 'close':
|
64 |
+
$this->_isOpen = false;
|
65 |
+
break;
|
66 |
+
case 'open':
|
67 |
+
$this->_filename = $this->getZip()->filename;
|
68 |
+
$this->_isOpen = $return === true;
|
69 |
+
default:
|
70 |
+
return $return;
|
71 |
+
}
|
72 |
+
}
|
73 |
+
}
|
app/code/community/Bronto/Common/Model/Email/{Message.php → Template.php}
RENAMED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* @package Bronto
|
5 |
-
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
-
* @version 1.6.
|
7 |
*/
|
8 |
-
class
|
9 |
{
|
10 |
/**
|
11 |
* @var string
|
@@ -17,11 +17,6 @@ class Bronto_Common_Model_Email_Message extends Mage_Core_Model_Email_Template
|
|
17 |
*/
|
18 |
protected $_message;
|
19 |
|
20 |
-
/**
|
21 |
-
* @var Bronto_Common_Model_Email_Message_Filter
|
22 |
-
*/
|
23 |
-
protected $_messageFilter;
|
24 |
-
|
25 |
/**
|
26 |
* @var string
|
27 |
*/
|
@@ -32,6 +27,16 @@ class Bronto_Common_Model_Email_Message extends Mage_Core_Model_Email_Template
|
|
32 |
*/
|
33 |
protected $_log;
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
/**
|
36 |
* Get the message currently set
|
37 |
*
|
@@ -42,7 +47,7 @@ class Bronto_Common_Model_Email_Message extends Mage_Core_Model_Email_Template
|
|
42 |
if (empty($this->_message)) {
|
43 |
$messageId = $this->getBrontoMessageId();
|
44 |
if (!empty($messageId)) {
|
45 |
-
$this->_message = Mage::helper(
|
46 |
} else {
|
47 |
return false;
|
48 |
}
|
@@ -51,39 +56,33 @@ class Bronto_Common_Model_Email_Message extends Mage_Core_Model_Email_Template
|
|
51 |
}
|
52 |
|
53 |
/**
|
54 |
-
*
|
55 |
*
|
56 |
-
* @
|
57 |
*/
|
58 |
-
public function
|
59 |
{
|
60 |
-
$this->
|
61 |
-
|
|
|
62 |
|
63 |
-
|
64 |
-
|
65 |
-
*
|
66 |
-
* @return Bronto_Common_Model_Email_Message_Filter
|
67 |
-
*/
|
68 |
-
public function getMessageFilter()
|
69 |
-
{
|
70 |
-
if (empty($this->_messageFilter)) {
|
71 |
-
$this->_messageFilter = Mage::getModel('bronto_common/email_message_filter');
|
72 |
}
|
73 |
-
return $this->
|
74 |
}
|
75 |
|
76 |
/**
|
77 |
* Process email template code
|
78 |
*
|
79 |
* @param Bronto_Api_Delivery_Row $delivery
|
80 |
-
* @param array
|
81 |
*
|
82 |
* @return Bronto_Api_Delivery_Row
|
83 |
*/
|
84 |
public function getProcessedDelivery(Bronto_Api_Delivery_Row $delivery, array $variables = array())
|
85 |
{
|
86 |
-
$processor = $this->
|
87 |
|
88 |
if (isset($variables['subscriber']) && ($variables['subscriber'] instanceof Mage_Newsletter_Model_Subscriber)) {
|
89 |
$processor->setStoreId($variables['subscriber']->getStoreId());
|
@@ -130,15 +129,15 @@ class Bronto_Common_Model_Email_Message extends Mage_Core_Model_Email_Template
|
|
130 |
/**
|
131 |
* Send mail to recipient
|
132 |
*
|
133 |
-
* @param array|string
|
134 |
* @param array|string|null $name receiver name(s)
|
135 |
-
* @param array
|
136 |
*
|
137 |
* @return boolean
|
138 |
*/
|
139 |
public function send($email, $name = null, array $variables = array())
|
140 |
{
|
141 |
-
if (!Mage::helper($this->_helper)->
|
142 |
return parent::send($email, $name, $variables);
|
143 |
}
|
144 |
|
@@ -154,9 +153,9 @@ class Bronto_Common_Model_Email_Message extends Mage_Core_Model_Email_Template
|
|
154 |
return false;
|
155 |
}
|
156 |
|
157 |
-
$emails = array_values((array)
|
158 |
-
$names
|
159 |
-
$names
|
160 |
foreach ($emails as $key => $email) {
|
161 |
if (!isset($names[$key])) {
|
162 |
$names[$key] = substr($email, 0, strpos($email, '@'));
|
@@ -164,21 +163,21 @@ class Bronto_Common_Model_Email_Message extends Mage_Core_Model_Email_Template
|
|
164 |
}
|
165 |
|
166 |
$variables['email'] = reset($emails);
|
167 |
-
$variables['name']
|
168 |
// Load Bronto Contact(s)
|
169 |
$contacts = array();
|
170 |
foreach ($emails as $key => $email) {
|
171 |
-
Mage::helper(
|
172 |
-
$contacts[$key] = Mage::helper(
|
173 |
}
|
174 |
|
175 |
-
$deliveryCount
|
176 |
$deliveryErrors = 0;
|
177 |
/* @var $contact Bronto_Api_Contact_Row */
|
178 |
foreach ($contacts as $key => $contact) {
|
179 |
try {
|
180 |
if (!$contact->id || empty($contact->id)) {
|
181 |
-
$contact = Mage::helper(
|
182 |
if (!$contact->id || empty($contact->id)) {
|
183 |
$this->_beforeSend($contact, $message);
|
184 |
$deliveryErrors++;
|
@@ -187,6 +186,7 @@ class Bronto_Common_Model_Email_Message extends Mage_Core_Model_Email_Template
|
|
187 |
continue;
|
188 |
}
|
189 |
}
|
|
|
190 |
$this->_beforeSend($contact, $message);
|
191 |
|
192 |
/* @var $deliveryObject Bronto_Api_Delivery */
|
@@ -195,30 +195,33 @@ class Bronto_Common_Model_Email_Message extends Mage_Core_Model_Email_Template
|
|
195 |
->getApi(null, $variables['store']->getId())
|
196 |
->getDeliveryObject();
|
197 |
$deliveryCount++;
|
|
|
198 |
|
|
|
199 |
/* @var $delivery Bronto_Api_Delivery_Row */
|
200 |
$delivery = $deliveryObject->createRow();
|
201 |
-
$delivery->start
|
202 |
-
$delivery->messageId
|
203 |
-
|
|
|
204 |
if (Mage::helper($this->_helper)->isTestModeEnabled()) {
|
205 |
-
$delivery->type
|
206 |
}
|
207 |
-
$delivery->fromEmail
|
208 |
-
$delivery->fromName
|
209 |
$delivery->replyEmail = $this->getSenderEmail();
|
210 |
$delivery->recipients = array(
|
211 |
array(
|
212 |
'type' => 'contact',
|
213 |
-
'id'
|
214 |
),
|
215 |
);
|
216 |
-
|
217 |
$delivery = $this->getProcessedDelivery($delivery, $variables);
|
218 |
-
|
219 |
Mage::helper($this->_helper)->writeDebug(' Saving Delivery...');
|
220 |
|
221 |
$delivery->save();
|
|
|
222 |
if ($delivery->id) {
|
223 |
$this->setLastDeliveryId($delivery->id);
|
224 |
$this->_afterSend(true, null, $delivery);
|
@@ -227,13 +230,19 @@ class Bronto_Common_Model_Email_Message extends Mage_Core_Model_Email_Template
|
|
227 |
$this->_afterSend(false, null, $delivery);
|
228 |
}
|
229 |
} catch (Exception $e) {
|
|
|
230 |
if ($e->getCode() === Bronto_Api_Delivery_Exception::MESSAGE_NOT_TRANSACTIONAL_APPROVED) {
|
231 |
-
|
232 |
-
|
|
|
|
|
|
|
|
|
233 |
}
|
|
|
234 |
$deliveryErrors++;
|
235 |
-
Mage::helper($this->_helper)->writeError($
|
236 |
-
$this->_afterSend(false, $
|
237 |
}
|
238 |
}
|
239 |
|
@@ -243,21 +252,66 @@ class Bronto_Common_Model_Email_Message extends Mage_Core_Model_Email_Template
|
|
243 |
/**
|
244 |
* Send transactional email to recipient
|
245 |
*
|
246 |
-
* @param int
|
247 |
* @param string|array $sender Sender information, can be declared as part of config path
|
248 |
-
* @param string
|
249 |
-
* @param string
|
250 |
-
* @param array
|
251 |
-
* @param int|null
|
252 |
*
|
253 |
* @return Mage_Core_Model_Email_Template
|
254 |
*/
|
255 |
public function sendTransactional($templateId, $sender, $email, $name, $vars = array(), $storeId = null)
|
256 |
{
|
257 |
-
if (!Mage::helper($this->_helper)->
|
258 |
return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
|
259 |
} else {
|
260 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
261 |
}
|
262 |
|
263 |
$this->setSentSuccess(false);
|
@@ -271,8 +325,8 @@ class Bronto_Common_Model_Email_Message extends Mage_Core_Model_Email_Template
|
|
271 |
$this->setBrontoMessageApproved(1);
|
272 |
|
273 |
if (!is_array($sender)) {
|
274 |
-
$this->setSenderName(Mage::getStoreConfig('trans_email/ident_'
|
275 |
-
$this->setSenderEmail(Mage::getStoreConfig('trans_email/ident_'
|
276 |
} else {
|
277 |
$this->setSenderName($sender['name']);
|
278 |
$this->setSenderEmail($sender['email']);
|
@@ -281,14 +335,16 @@ class Bronto_Common_Model_Email_Message extends Mage_Core_Model_Email_Template
|
|
281 |
if (!isset($vars['store'])) {
|
282 |
$vars['store'] = Mage::app()->getStore($storeId);
|
283 |
}
|
|
|
284 |
$this->setSentSuccess($this->send($email, $name, $vars));
|
|
|
285 |
return $this;
|
286 |
}
|
287 |
|
288 |
/**
|
289 |
* @param string $deliveryId
|
290 |
*
|
291 |
-
* @return
|
292 |
*/
|
293 |
public function setLastDeliveryId($deliveryId)
|
294 |
{
|
@@ -313,8 +369,8 @@ class Bronto_Common_Model_Email_Message extends Mage_Core_Model_Email_Template
|
|
313 |
}
|
314 |
|
315 |
/**
|
316 |
-
* @param int
|
317 |
-
* @param string
|
318 |
* @param Bronto_Api_Delivery_Row $delivery
|
319 |
*/
|
320 |
protected function _afterSend($success, $error = null, Bronto_Api_Delivery_Row $delivery = null)
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* @package Bronto/Common
|
5 |
+
* @copyright (c) 2011-2012, Bronto Software, Inc.
|
6 |
+
* @version 1.6.8
|
7 |
*/
|
8 |
+
class Bronto_Common_Model_Email_Template extends Mage_Core_Model_Email_Template
|
9 |
{
|
10 |
/**
|
11 |
* @var string
|
17 |
*/
|
18 |
protected $_message;
|
19 |
|
|
|
|
|
|
|
|
|
|
|
20 |
/**
|
21 |
* @var string
|
22 |
*/
|
27 |
*/
|
28 |
protected $_log;
|
29 |
|
30 |
+
/**
|
31 |
+
* Set the message
|
32 |
+
*
|
33 |
+
* @param Bronto_Api_Message_Row $message
|
34 |
+
*/
|
35 |
+
public function setMessage(Bronto_Api_Message_Row $message)
|
36 |
+
{
|
37 |
+
$this->_message = $message;
|
38 |
+
}
|
39 |
+
|
40 |
/**
|
41 |
* Get the message currently set
|
42 |
*
|
47 |
if (empty($this->_message)) {
|
48 |
$messageId = $this->getBrontoMessageId();
|
49 |
if (!empty($messageId)) {
|
50 |
+
$this->_message = Mage::helper('bronto_common/message')->getMessageById($messageId);
|
51 |
} else {
|
52 |
return false;
|
53 |
}
|
56 |
}
|
57 |
|
58 |
/**
|
59 |
+
* Get filter object for template processing logi
|
60 |
*
|
61 |
+
* @return Mage_Core_Model_Email_Template_Filter
|
62 |
*/
|
63 |
+
public function getTemplateFilter($storeId = null)
|
64 |
{
|
65 |
+
if (!Mage::helper($this->_helper)->canSendBronto($this, $storeId)) {
|
66 |
+
return parent::getTemplateFilter();
|
67 |
+
}
|
68 |
|
69 |
+
if (empty($this->_templateFilter)) {
|
70 |
+
$this->_templateFilter = Mage::getModel('bronto_common/email_template_filter');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
71 |
}
|
72 |
+
return $this->_templateFilter;
|
73 |
}
|
74 |
|
75 |
/**
|
76 |
* Process email template code
|
77 |
*
|
78 |
* @param Bronto_Api_Delivery_Row $delivery
|
79 |
+
* @param array $variables
|
80 |
*
|
81 |
* @return Bronto_Api_Delivery_Row
|
82 |
*/
|
83 |
public function getProcessedDelivery(Bronto_Api_Delivery_Row $delivery, array $variables = array())
|
84 |
{
|
85 |
+
$processor = $this->getTemplateFilter($variables['store']->getId());
|
86 |
|
87 |
if (isset($variables['subscriber']) && ($variables['subscriber'] instanceof Mage_Newsletter_Model_Subscriber)) {
|
88 |
$processor->setStoreId($variables['subscriber']->getStoreId());
|
129 |
/**
|
130 |
* Send mail to recipient
|
131 |
*
|
132 |
+
* @param array|string $email E-mail(s)
|
133 |
* @param array|string|null $name receiver name(s)
|
134 |
+
* @param array $variables template variables
|
135 |
*
|
136 |
* @return boolean
|
137 |
*/
|
138 |
public function send($email, $name = null, array $variables = array())
|
139 |
{
|
140 |
+
if (!Mage::helper($this->_helper)->canSendBronto($this, $variables['store']->getId())) {
|
141 |
return parent::send($email, $name, $variables);
|
142 |
}
|
143 |
|
153 |
return false;
|
154 |
}
|
155 |
|
156 |
+
$emails = array_values((array)$email);
|
157 |
+
$names = is_array($name) ? $name : (array)$name;
|
158 |
+
$names = array_values($names);
|
159 |
foreach ($emails as $key => $email) {
|
160 |
if (!isset($names[$key])) {
|
161 |
$names[$key] = substr($email, 0, strpos($email, '@'));
|
163 |
}
|
164 |
|
165 |
$variables['email'] = reset($emails);
|
166 |
+
$variables['name'] = reset($names);
|
167 |
// Load Bronto Contact(s)
|
168 |
$contacts = array();
|
169 |
foreach ($emails as $key => $email) {
|
170 |
+
Mage::helper('bronto_common/contact')->writeDebug(' Getting Contact Object for: ' . $email . ' - Store: ' . $variables['store']->getId());
|
171 |
+
$contacts[$key] = Mage::helper('bronto_common/contact')->getContactByEmail($email, $this->_helper, $variables['store']->getId(), 2);
|
172 |
}
|
173 |
|
174 |
+
$deliveryCount = 0;
|
175 |
$deliveryErrors = 0;
|
176 |
/* @var $contact Bronto_Api_Contact_Row */
|
177 |
foreach ($contacts as $key => $contact) {
|
178 |
try {
|
179 |
if (!$contact->id || empty($contact->id)) {
|
180 |
+
$contact = Mage::helper('bronto_common/contact')->saveContact($contact);
|
181 |
if (!$contact->id || empty($contact->id)) {
|
182 |
$this->_beforeSend($contact, $message);
|
183 |
$deliveryErrors++;
|
186 |
continue;
|
187 |
}
|
188 |
}
|
189 |
+
|
190 |
$this->_beforeSend($contact, $message);
|
191 |
|
192 |
/* @var $deliveryObject Bronto_Api_Delivery */
|
195 |
->getApi(null, $variables['store']->getId())
|
196 |
->getDeliveryObject();
|
197 |
$deliveryCount++;
|
198 |
+
Mage::helper($this->_helper)->writeDebug(' Delivery Object Created Successfully');
|
199 |
|
200 |
+
Mage::helper($this->_helper)->writeDebug(' Creating Delivery Row...');
|
201 |
/* @var $delivery Bronto_Api_Delivery_Row */
|
202 |
$delivery = $deliveryObject->createRow();
|
203 |
+
$delivery->start = date('c');
|
204 |
+
$delivery->messageId = $message->id;
|
205 |
+
// TODO: Remove once reminder get send type support
|
206 |
+
$delivery->type = $this->getTemplateSendType() ? $this->getTemplateSendType() : 'transactional';
|
207 |
if (Mage::helper($this->_helper)->isTestModeEnabled()) {
|
208 |
+
$delivery->type = 'test';
|
209 |
}
|
210 |
+
$delivery->fromEmail = $this->getSenderEmail();
|
211 |
+
$delivery->fromName = $this->getSenderName();
|
212 |
$delivery->replyEmail = $this->getSenderEmail();
|
213 |
$delivery->recipients = array(
|
214 |
array(
|
215 |
'type' => 'contact',
|
216 |
+
'id' => $contact->id,
|
217 |
),
|
218 |
);
|
219 |
+
Mage::helper($this->_helper)->writeDebug(' Processing Delivery');
|
220 |
$delivery = $this->getProcessedDelivery($delivery, $variables);
|
|
|
221 |
Mage::helper($this->_helper)->writeDebug(' Saving Delivery...');
|
222 |
|
223 |
$delivery->save();
|
224 |
+
|
225 |
if ($delivery->id) {
|
226 |
$this->setLastDeliveryId($delivery->id);
|
227 |
$this->_afterSend(true, null, $delivery);
|
230 |
$this->_afterSend(false, null, $delivery);
|
231 |
}
|
232 |
} catch (Exception $e) {
|
233 |
+
$errorMessage = $e->getMessage();
|
234 |
if ($e->getCode() === Bronto_Api_Delivery_Exception::MESSAGE_NOT_TRANSACTIONAL_APPROVED) {
|
235 |
+
// Replace message id with message name
|
236 |
+
if (preg_match_all("/([a-zA-Z0-9\-]){36}/", $errorMessage, $matches)) { // Grab field id if exists
|
237 |
+
foreach ($matches[0] as $match) {
|
238 |
+
$errorMessage = str_replace($match, $message->name, $errorMessage);
|
239 |
+
}
|
240 |
+
}
|
241 |
}
|
242 |
+
|
243 |
$deliveryErrors++;
|
244 |
+
Mage::helper($this->_helper)->writeError($errorMessage);
|
245 |
+
$this->_afterSend(false, $errorMessage, isset($delivery) ? $delivery : null);
|
246 |
}
|
247 |
}
|
248 |
|
252 |
/**
|
253 |
* Send transactional email to recipient
|
254 |
*
|
255 |
+
* @param int $templateId
|
256 |
* @param string|array $sender Sender information, can be declared as part of config path
|
257 |
+
* @param string $email Recipient email
|
258 |
+
* @param string $name Recipient name
|
259 |
+
* @param array $vars Variables which can be used in template
|
260 |
+
* @param int|null $storeId
|
261 |
*
|
262 |
* @return Mage_Core_Model_Email_Template
|
263 |
*/
|
264 |
public function sendTransactional($templateId, $sender, $email, $name, $vars = array(), $storeId = null)
|
265 |
{
|
266 |
+
if (!Mage::helper($this->_helper)->canSendBronto($this, $storeId)) {
|
267 |
return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
|
268 |
} else {
|
269 |
+
// If module enabled and template ID is not an instance of the api row, see if we can pull an instance
|
270 |
+
if (!($templateId instanceOf Bronto_Api_Message_Row)) {
|
271 |
+
$emailTemplate = Mage::getModel('bronto_email/template');
|
272 |
+
|
273 |
+
if (is_numeric($templateId)) {
|
274 |
+
$emailTemplate->load($templateId);
|
275 |
+
} else {
|
276 |
+
$this->setTemplateSendType('magento');
|
277 |
+
return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
|
278 |
+
}
|
279 |
+
|
280 |
+
// If Template doesn't have a Bronto Message ID, send through magento
|
281 |
+
if (!$emailTemplate->getBrontoMessageId() || is_null($emailTemplate->getBrontoMessageId())) {
|
282 |
+
return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
|
283 |
+
}
|
284 |
+
|
285 |
+
// Load Store
|
286 |
+
$store = Mage::getModel('core/store')->load($storeId);
|
287 |
+
|
288 |
+
// Load Bronto Message
|
289 |
+
/* @var $messageObject Bronto_Api_Message */
|
290 |
+
$messageObject = Mage::helper('bronto_common/message')->getApi(null, $store->getId(), $store->getWebsiteId())->getMessageObject();
|
291 |
+
|
292 |
+
// Load Message
|
293 |
+
try {
|
294 |
+
/* @var $message Bronto_Api_Message_Row */
|
295 |
+
$message = $messageObject->createRow();
|
296 |
+
$message->id = $emailTemplate->getBrontoMessageId();
|
297 |
+
$message->read();
|
298 |
+
} catch (Exception $e) {
|
299 |
+
Mage::helper($this->_helper)->writeDebug('Falling Back to Magento Sending: ' . $e);
|
300 |
+
return parent::sendTransactional($templateId, $sender, $email, $name, $vars, $storeId);
|
301 |
+
}
|
302 |
+
|
303 |
+
// Send through main template model
|
304 |
+
return $emailTemplate->sendTransactional(
|
305 |
+
$message,
|
306 |
+
$sender,
|
307 |
+
$email,
|
308 |
+
$name,
|
309 |
+
$vars,
|
310 |
+
$storeId
|
311 |
+
);
|
312 |
+
} else {
|
313 |
+
$message = $templateId;
|
314 |
+
}
|
315 |
}
|
316 |
|
317 |
$this->setSentSuccess(false);
|
325 |
$this->setBrontoMessageApproved(1);
|
326 |
|
327 |
if (!is_array($sender)) {
|
328 |
+
$this->setSenderName(Mage::getStoreConfig('trans_email/ident_' . $sender . '/name', $storeId));
|
329 |
+
$this->setSenderEmail(Mage::getStoreConfig('trans_email/ident_' . $sender . '/email', $storeId));
|
330 |
} else {
|
331 |
$this->setSenderName($sender['name']);
|
332 |
$this->setSenderEmail($sender['email']);
|
335 |
if (!isset($vars['store'])) {
|
336 |
$vars['store'] = Mage::app()->getStore($storeId);
|
337 |
}
|
338 |
+
|
339 |
$this->setSentSuccess($this->send($email, $name, $vars));
|
340 |
+
|
341 |
return $this;
|
342 |
}
|
343 |
|
344 |
/**
|
345 |
* @param string $deliveryId
|
346 |
*
|
347 |
+
* @return Bronto_Common_Model_Email_Template
|
348 |
*/
|
349 |
public function setLastDeliveryId($deliveryId)
|
350 |
{
|
369 |
}
|
370 |
|
371 |
/**
|
372 |
+
* @param int $success
|
373 |
+
* @param string $error
|
374 |
* @param Bronto_Api_Delivery_Row $delivery
|
375 |
*/
|
376 |
protected function _afterSend($success, $error = null, Bronto_Api_Delivery_Row $delivery = null)
|
app/code/community/Bronto/Common/Model/Email/{Message → Template}/Filter.php
RENAMED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* @package Bronto\
|
5 |
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
-
* @version 1.6
|
7 |
*/
|
8 |
-
class
|
9 |
{
|
10 |
/**
|
11 |
* @var Bronto_Api_Delivery_Row
|
@@ -27,6 +27,11 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
27 |
*/
|
28 |
protected $_messageId;
|
29 |
|
|
|
|
|
|
|
|
|
|
|
30 |
/**
|
31 |
* Assigned template variables
|
32 |
*
|
@@ -104,14 +109,14 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
104 |
}
|
105 |
|
106 |
/**
|
107 |
-
* @return
|
108 |
*/
|
109 |
protected function _processQueryParams()
|
110 |
{
|
111 |
$this->_queryParams = array();
|
112 |
|
113 |
// Add rule_id (if available)
|
114 |
-
if (isset($this->_variables['rule'])){
|
115 |
if (class_exists('Bronto_Reminder_Model_Rule', false) && $this->_variables['rule'] instanceOf Bronto_Reminder_Model_Rule) {
|
116 |
$this->_queryParams['rule_id'] = $this->_variables['rule']->getId();
|
117 |
}
|
@@ -129,8 +134,12 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
129 |
* @param Bronto_Api_Delivery_Row $delivery
|
130 |
* @return Bronto_Api_Delivery_Row
|
131 |
*/
|
132 |
-
public function filter(
|
133 |
{
|
|
|
|
|
|
|
|
|
134 |
$this->_filteredObjects = array();
|
135 |
$this->_delivery = $delivery;
|
136 |
|
@@ -180,6 +189,11 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
180 |
$this->_filterAdmin($value);
|
181 |
}
|
182 |
|
|
|
|
|
|
|
|
|
|
|
183 |
// Customer
|
184 |
if ($value instanceOf Mage_Customer_Model_Customer) {
|
185 |
$this->_filterCustomer($value);
|
@@ -232,21 +246,21 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
232 |
}
|
233 |
|
234 |
/**
|
235 |
-
* @param Mage_Core_Model_Store
|
236 |
-
* @return
|
237 |
*/
|
238 |
protected function _filterStore(Mage_Core_Model_Store $store)
|
239 |
{
|
240 |
if (!in_array('store', $this->_filteredObjects)) {
|
241 |
$this->setStore($store);
|
242 |
-
$this->setField('storeName',
|
243 |
$this->setField('storeFrontendName', $store->getFrontendName());
|
244 |
-
$this->setField('storeURL',
|
245 |
-
$this->setField('cartURL',
|
246 |
-
$this->setField('customerURL',
|
247 |
-
$this->setField('supportEmail',
|
248 |
-
$this->setField('supportPhone',
|
249 |
-
$this->setField('salesEmail',
|
250 |
|
251 |
// if the theme is not set at all (not a likely occurrence in a real site)
|
252 |
// then it returns the theme for the Find (RSS feed).
|
@@ -264,13 +278,13 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
264 |
}
|
265 |
|
266 |
/**
|
267 |
-
* @param Mage_Admin_Model_User
|
268 |
-
* @return
|
269 |
*/
|
270 |
protected function _filterAdmin(Mage_Admin_Model_User $user)
|
271 |
{
|
272 |
if (!in_array('admin', $this->_filteredObjects)) {
|
273 |
-
$this->setField('adminName',
|
274 |
$this->setField('adminPassword', $user->getPlainPassword());
|
275 |
$this->setField('adminLoginURL', Mage::helper('adminhtml')->getUrl('adminhtml/system_account/'));
|
276 |
if (version_compare(Mage::getVersion(), '1.6.1.0', '>=')) {
|
@@ -284,22 +298,38 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
284 |
}
|
285 |
|
286 |
/**
|
287 |
-
* @param
|
288 |
-
* @return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
289 |
*/
|
290 |
protected function _filterCustomer(Mage_Customer_Model_Customer $customer)
|
291 |
{
|
292 |
if (!in_array('customer', $this->_filteredObjects)) {
|
293 |
-
$this->setField('customerName',
|
294 |
-
$this->setField('customerEmail',
|
295 |
$this->setField('customerPassword', $customer->getPassword());
|
296 |
-
if ($store = $
|
297 |
-
$this->setField('confirmationLink', $store->getUrl('customer/account/confirm', array('_query'=>array('id'
|
298 |
if (version_compare(Mage::getVersion(), '1.6.1.0', '>=')) {
|
299 |
$this->setField('passwordResetLink', $store->getUrl('customer/account/resetpassword', array('_query' => array('id' => $customer->getId(), 'token' => $customer->getRpToken()))));
|
300 |
}
|
301 |
} else {
|
302 |
-
$this->setField('confirmationLink', Mage::getUrl('customer/account/confirm', array('_query'=>array('id'
|
303 |
if (version_compare(Mage::getVersion(), '1.6.1.0', '>=')) {
|
304 |
$this->setField('passwordResetLink', Mage::getUrl('customer/account/resetpassword', array('_query' => array('id' => $customer->getId(), 'token' => $customer->getRpToken()))));
|
305 |
}
|
@@ -312,31 +342,33 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
312 |
}
|
313 |
|
314 |
/**
|
315 |
-
* @param Mage_Sales_Model_Order
|
316 |
-
* @return
|
317 |
*/
|
318 |
protected function _filterOrder(Mage_Sales_Model_Order $order, $type = 'order')
|
319 |
{
|
320 |
if (!in_array('order', $this->_filteredObjects)) {
|
|
|
|
|
321 |
// Order may not be a shippable order
|
322 |
-
$shipAddress
|
323 |
$shipDescription = 'N/A';
|
324 |
if ($order->getIsNotVirtual()) {
|
325 |
-
$shipAddress
|
326 |
$shipDescription = $order->getShippingDescription();
|
327 |
}
|
328 |
|
329 |
// Check for guest orders
|
330 |
$customerName = $order->getCustomerIsGuest() ? $order->getBillingAddress()->getName() : $order->getCustomerName();
|
331 |
|
332 |
-
$this->setField('orderIncrementId',
|
333 |
-
$this->setField('orderCreatedAt',
|
334 |
-
$this->setField('orderBillingAddress',
|
335 |
-
$this->setField('orderShippingAddress',
|
336 |
$this->setField('orderShippingDescription', $shipDescription);
|
337 |
-
$this->setField('orderCustomerName',
|
338 |
-
$this->setField('orderStatusLabel',
|
339 |
-
$this->setField('orderItems',
|
340 |
|
341 |
$this->_filteredObjects[] = 'order';
|
342 |
}
|
@@ -348,21 +380,21 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
348 |
{
|
349 |
if (!in_array('address', $this->_filteredObjects)) {
|
350 |
|
351 |
-
$this->setField('billingName',
|
352 |
$this->_filteredObjects[] = 'address';
|
353 |
}
|
354 |
return $this;
|
355 |
}
|
356 |
|
357 |
/**
|
358 |
-
* @param Mage_Sales_Model_Order_Invoice
|
359 |
-
* @return
|
360 |
*/
|
361 |
protected function _filterInvoice(Mage_Sales_Model_Order_Invoice $invoice)
|
362 |
{
|
363 |
if (!in_array('invoice', $this->_filteredObjects)) {
|
364 |
$this->setField('invoiceIncrementId', $invoice->getIncrementId());
|
365 |
-
$this->setField('invoiceItems',
|
366 |
|
367 |
$this->_filteredObjects[] = 'invoice';
|
368 |
}
|
@@ -371,16 +403,16 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
371 |
}
|
372 |
|
373 |
/**
|
374 |
-
* @param Mage_Sales_Model_Order_Shipment
|
375 |
-
* @return
|
376 |
*/
|
377 |
protected function _filterShipment(Mage_Sales_Model_Order_Shipment $shipment)
|
378 |
{
|
379 |
if (!in_array('shipment', $this->_filteredObjects)) {
|
380 |
$this->setField('shipmentIncrementId', $shipment->getIncrementId());
|
381 |
-
$this->setField('shipmentCreatedAt',
|
382 |
-
$this->setField('shipmentItems',
|
383 |
-
$this->setField('shipmentTracking',
|
384 |
|
385 |
$this->_filteredObjects[] = 'shipment';
|
386 |
}
|
@@ -389,15 +421,15 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
389 |
}
|
390 |
|
391 |
/**
|
392 |
-
* @param Mage_Sales_Model_Order_Creditmemo
|
393 |
-
* @return
|
394 |
*/
|
395 |
protected function _filterCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo)
|
396 |
{
|
397 |
if (!in_array('creditmemo', $this->_filteredObjects)) {
|
398 |
$this->setField('creditmemoIncrementId', $creditmemo->getIncrementId());
|
399 |
-
$this->setField('creditmemoCreatedAt',
|
400 |
-
$this->setField('creditmemoItems',
|
401 |
|
402 |
$this->_filteredObjects[] = 'creditmemo';
|
403 |
}
|
@@ -405,24 +437,27 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
405 |
}
|
406 |
|
407 |
/**
|
408 |
-
* @param Mage_Sales_Model_Quote
|
409 |
-
* @return
|
410 |
*/
|
411 |
protected function _filterQuote(Mage_Sales_Model_Quote $quote)
|
412 |
{
|
413 |
if (!in_array('quote', $this->_filteredObjects)) {
|
414 |
-
$this->
|
415 |
-
$
|
|
|
|
|
|
|
416 |
|
417 |
$index = 1;
|
418 |
-
foreach ($quote->getAllItems() as $item
|
419 |
if (!$item->getParentItem()) {
|
420 |
$this->_filterQuoteItem($item, $index);
|
421 |
$index++;
|
422 |
}
|
423 |
}
|
424 |
-
|
425 |
-
$queryParams
|
426 |
$queryParams['id'] = urlencode(base64_encode(Mage::helper('core')->encrypt($quote->getId())));
|
427 |
if ($store = $this->getStore()) {
|
428 |
$this->setField('quoteURL', $store->getUrl('reminder/load/index', $queryParams));
|
@@ -450,8 +485,8 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
450 |
}
|
451 |
|
452 |
/**
|
453 |
-
* @param Mage_Sales_Model_Quote_Item
|
454 |
-
* @return
|
455 |
*/
|
456 |
protected function _filterQuoteItem($item, $index = null)
|
457 |
{
|
@@ -459,12 +494,12 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
459 |
return $this;
|
460 |
}
|
461 |
|
462 |
-
$this->setField("productName_{$index}",
|
463 |
-
$this->setField("productSku_{$index}",
|
464 |
-
$this->setField("productPrice_{$index}",
|
465 |
-
$this->setField("productTotal_{$index}",
|
466 |
-
$this->setField("productQty_{$index}",
|
467 |
-
$this->setField("productUrl_{$index}",
|
468 |
|
469 |
/* @var $product Mage_Catalog_Model_Product */
|
470 |
$product = $item->getProduct();
|
@@ -477,21 +512,21 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
477 |
}
|
478 |
|
479 |
/**
|
480 |
-
* @param Mage_Wishlist_Model_Wishlist
|
481 |
-
* @return
|
482 |
*/
|
483 |
protected function _filterWishlist(Mage_Wishlist_Model_Wishlist $wishlist)
|
484 |
{
|
485 |
if (!in_array('wishlist', $this->_filteredObjects)) {
|
486 |
$index = 1;
|
487 |
-
foreach ($wishlist->getItemCollection() as $item
|
488 |
if (!$item->getParentItem()) {
|
489 |
$this->_filterWishlistItem($item, $index);
|
490 |
$index++;
|
491 |
}
|
492 |
}
|
493 |
|
494 |
-
$queryParams
|
495 |
$queryParams['wishlist_id'] = urlencode(base64_encode(Mage::helper('core')->encrypt($wishlist->getId())));
|
496 |
if ($store = $this->getStore()) {
|
497 |
$this->setField('wishlistURL', $store->getUrl('reminder/load/index', $queryParams));
|
@@ -519,27 +554,28 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
519 |
}
|
520 |
|
521 |
/**
|
522 |
-
* @param Mage_Wishlist_Model_Item
|
523 |
-
* @return
|
524 |
*/
|
525 |
protected function _filterWishlistItem(Mage_Wishlist_Model_Item $item, $index = null)
|
526 |
{
|
527 |
if ($item->getParentItem()) {
|
528 |
return $this;
|
529 |
}
|
530 |
-
|
531 |
-
$this->
|
532 |
-
$this->setField("
|
533 |
-
$this->setField("
|
534 |
-
$this->setField("
|
|
|
535 |
|
536 |
/* @var $product Mage_Catalog_Model_Product */
|
537 |
$product = $item->getProduct();
|
538 |
if (!$product) {
|
539 |
$product = Mage::getModel('catalog/product')->load($item->getProductId());
|
540 |
}
|
541 |
-
$this->setField("productSku_{$index}",
|
542 |
-
|
543 |
$this->_filterProduct($product, $index);
|
544 |
|
545 |
return $this;
|
@@ -578,7 +614,7 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
578 |
*/
|
579 |
protected function _filterInvoiceItems(Mage_Sales_Model_Order_Invoice $invoice)
|
580 |
{
|
581 |
-
$order
|
582 |
$layout = Mage::getSingleton('core/layout');
|
583 |
|
584 |
/* @var $items Mage_Sales_Block_Items_Abstract */
|
@@ -631,12 +667,12 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
631 |
* Get the shipment tracking info.
|
632 |
*
|
633 |
* @param Mage_Sales_Model_Order_Shipment $shipment
|
634 |
-
* @param Mage_Sales_Model_Order
|
635 |
*/
|
636 |
protected function _getShipmentTrackingNumber(Mage_Sales_Model_Order_Shipment $shipment, Mage_Sales_Model_Order $order)
|
637 |
{
|
638 |
$layout = Mage::getSingleton('core/layout');
|
639 |
-
$block
|
640 |
$block->setOrder($order);
|
641 |
$block->setShipment($shipment);
|
642 |
$block->setArea('frontend');
|
@@ -650,7 +686,7 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
650 |
*/
|
651 |
protected function _filterCreditmemoItems(Mage_Sales_Model_Order_Creditmemo $creditmemo)
|
652 |
{
|
653 |
-
$order
|
654 |
$layout = Mage::getSingleton('core/layout');
|
655 |
|
656 |
/* @var $items Mage_Sales_Block_Items_Abstract */
|
@@ -676,10 +712,10 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
676 |
/**
|
677 |
* Get the totals block for order-style emails.
|
678 |
*
|
679 |
-
* @param Mage_Core_Model_Layout
|
680 |
-
* @param Mage_Sales_Model_Order
|
681 |
-
* @param String
|
682 |
-
* @param String
|
683 |
* @return Mage_Core_Block_Template
|
684 |
*/
|
685 |
protected function _getTotalsBlock($layout, $order, $totals_block_type, $totals_block_name)
|
@@ -700,20 +736,26 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
700 |
}
|
701 |
|
702 |
/**
|
703 |
-
* @param Mage_Catalog_Model_Product
|
704 |
-
* @param int
|
705 |
-
* @return
|
706 |
*/
|
707 |
protected function _filterProduct(Mage_Catalog_Model_Product $product, $index = null)
|
708 |
{
|
|
|
|
|
|
|
|
|
|
|
709 |
if ($index !== null) {
|
710 |
try {
|
711 |
-
$
|
|
|
712 |
} catch (Exception $e) {
|
713 |
Mage::log('Error loading image: ' . $e);
|
714 |
}
|
715 |
} else {
|
716 |
-
$this->setField('productUrl',
|
717 |
$this->setField('productName', $product->getName());
|
718 |
}
|
719 |
|
@@ -730,13 +772,7 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
730 |
return $item->getRedirectUrl();
|
731 |
}
|
732 |
|
733 |
-
|
734 |
-
$option = $item->getOptionByCode('product_type');
|
735 |
-
if ($option) {
|
736 |
-
$product = $option->getProduct();
|
737 |
-
}
|
738 |
-
|
739 |
-
return $product->getUrlModel()->getUrl($product);
|
740 |
}
|
741 |
|
742 |
/**
|
@@ -749,19 +785,13 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
749 |
return $item->getRedirectUrl();
|
750 |
}
|
751 |
|
752 |
-
|
753 |
-
$option = $item->getOptionByCode('product_type');
|
754 |
-
if ($option) {
|
755 |
-
$product = $option->getProduct();
|
756 |
-
}
|
757 |
-
|
758 |
-
return $product->getUrlModel()->getUrl($product);
|
759 |
}
|
760 |
|
761 |
/**
|
762 |
-
* @param string
|
763 |
-
* @param string|array
|
764 |
-
* @return
|
765 |
*/
|
766 |
public function setField($key, $value, $type = 'html')
|
767 |
{
|
@@ -773,7 +803,7 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
773 |
// Address objects come in as an array on payment failed emails
|
774 |
$delim = $type == 'html' ? '<br/>' : "\n\r";
|
775 |
if (isset($value['address_id'])) {
|
776 |
-
$new_value
|
777 |
$new_value .= $value['city'] . $delim;
|
778 |
$new_value .= $value['region'] . $delim;
|
779 |
$new_value .= $value['postcode'] . $delim;
|
@@ -802,8 +832,8 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
802 |
/**
|
803 |
* Setter
|
804 |
*
|
805 |
-
* @param integer
|
806 |
-
* @return
|
807 |
*/
|
808 |
public function setStoreId($storeId)
|
809 |
{
|
@@ -827,11 +857,12 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
827 |
|
828 |
/**
|
829 |
* @param Mage_Core_Model_Store $store
|
830 |
-
* @return
|
831 |
*/
|
832 |
public function setStore(Mage_Core_Model_Store $store)
|
833 |
{
|
834 |
$this->_store = $store;
|
|
|
835 |
return $this;
|
836 |
}
|
837 |
|
@@ -840,12 +871,20 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
840 |
*/
|
841 |
public function getStore()
|
842 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
843 |
return $this->_store;
|
844 |
}
|
845 |
|
846 |
/**
|
847 |
* @param string $messageId
|
848 |
-
* @return
|
849 |
*/
|
850 |
public function setMessageId($messageId)
|
851 |
{
|
@@ -862,14 +901,11 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
862 |
}
|
863 |
|
864 |
/**
|
865 |
-
* @param array
|
866 |
-
* @return
|
867 |
*/
|
868 |
-
public function setVariables($variables
|
869 |
{
|
870 |
-
if (!is_array($variables)) {
|
871 |
-
$variables = array();
|
872 |
-
}
|
873 |
foreach ($variables as $name => $value) {
|
874 |
$this->_variables[$name] = $value;
|
875 |
}
|
@@ -877,8 +913,8 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
877 |
}
|
878 |
|
879 |
/**
|
880 |
-
* @param array
|
881 |
-
* @return
|
882 |
*/
|
883 |
public function setAvailable($variables = array())
|
884 |
{
|
@@ -929,4 +965,30 @@ class Bronto_Common_Model_Email_Message_Filter
|
|
929 |
}
|
930 |
return $string;
|
931 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
932 |
}
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* @package Bronto\Email
|
5 |
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
+
* @version 1.1.6
|
7 |
*/
|
8 |
+
class Bronto_Common_Model_Email_Template_Filter extends Mage_Core_Model_Email_Template_Filter
|
9 |
{
|
10 |
/**
|
11 |
* @var Bronto_Api_Delivery_Row
|
27 |
*/
|
28 |
protected $_messageId;
|
29 |
|
30 |
+
/**
|
31 |
+
* @var Mage_Core_Helper_Data
|
32 |
+
*/
|
33 |
+
protected $_currency;
|
34 |
+
|
35 |
/**
|
36 |
* Assigned template variables
|
37 |
*
|
109 |
}
|
110 |
|
111 |
/**
|
112 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
113 |
*/
|
114 |
protected function _processQueryParams()
|
115 |
{
|
116 |
$this->_queryParams = array();
|
117 |
|
118 |
// Add rule_id (if available)
|
119 |
+
if (isset($this->_variables['rule'])) {
|
120 |
if (class_exists('Bronto_Reminder_Model_Rule', false) && $this->_variables['rule'] instanceOf Bronto_Reminder_Model_Rule) {
|
121 |
$this->_queryParams['rule_id'] = $this->_variables['rule']->getId();
|
122 |
}
|
134 |
* @param Bronto_Api_Delivery_Row $delivery
|
135 |
* @return Bronto_Api_Delivery_Row
|
136 |
*/
|
137 |
+
public function filter($delivery)
|
138 |
{
|
139 |
+
if (!$delivery instanceof Bronto_Api_Delivery_Row) {
|
140 |
+
return parent::filter($delivery);
|
141 |
+
}
|
142 |
+
|
143 |
$this->_filteredObjects = array();
|
144 |
$this->_delivery = $delivery;
|
145 |
|
189 |
$this->_filterAdmin($value);
|
190 |
}
|
191 |
|
192 |
+
// Subscriber
|
193 |
+
if ($value instanceOf Mage_Newsletter_Model_Subscriber) {
|
194 |
+
$this->_filterSubscriber($value);
|
195 |
+
}
|
196 |
+
|
197 |
// Customer
|
198 |
if ($value instanceOf Mage_Customer_Model_Customer) {
|
199 |
$this->_filterCustomer($value);
|
246 |
}
|
247 |
|
248 |
/**
|
249 |
+
* @param Mage_Core_Model_Store $store
|
250 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
251 |
*/
|
252 |
protected function _filterStore(Mage_Core_Model_Store $store)
|
253 |
{
|
254 |
if (!in_array('store', $this->_filteredObjects)) {
|
255 |
$this->setStore($store);
|
256 |
+
$this->setField('storeName', $store->getName());
|
257 |
$this->setField('storeFrontendName', $store->getFrontendName());
|
258 |
+
$this->setField('storeURL', $store->getUrl('cms', $this->getQueryParams()));
|
259 |
+
$this->setField('cartURL', $store->getUrl('checkout/cart', $this->getQueryParams()));
|
260 |
+
$this->setField('customerURL', $store->getUrl('customer/account', $this->getQueryParams()));
|
261 |
+
$this->setField('supportEmail', $store->getConfig('trans_email/ident_support/email'));
|
262 |
+
$this->setField('supportPhone', $store->getConfig('general/store_information/phone'));
|
263 |
+
$this->setField('salesEmail', $store->getConfig('trans_email/ident_sales/email'));
|
264 |
|
265 |
// if the theme is not set at all (not a likely occurrence in a real site)
|
266 |
// then it returns the theme for the Find (RSS feed).
|
278 |
}
|
279 |
|
280 |
/**
|
281 |
+
* @param Mage_Admin_Model_User $user
|
282 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
283 |
*/
|
284 |
protected function _filterAdmin(Mage_Admin_Model_User $user)
|
285 |
{
|
286 |
if (!in_array('admin', $this->_filteredObjects)) {
|
287 |
+
$this->setField('adminName', $user->getUsername());
|
288 |
$this->setField('adminPassword', $user->getPlainPassword());
|
289 |
$this->setField('adminLoginURL', Mage::helper('adminhtml')->getUrl('adminhtml/system_account/'));
|
290 |
if (version_compare(Mage::getVersion(), '1.6.1.0', '>=')) {
|
298 |
}
|
299 |
|
300 |
/**
|
301 |
+
* @param Mage_Newsletter_Model_Subscriber $subscriber
|
302 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
303 |
+
*/
|
304 |
+
protected function _filterSubscriber(Mage_Newsletter_Model_Subscriber $subscriber)
|
305 |
+
{
|
306 |
+
if (!in_array('subscriber', $this->_filteredObjects)) {
|
307 |
+
$customer = Mage::getModel('customer/customer')->load($subscriber->getCustomerId());
|
308 |
+
|
309 |
+
$this->_filterCustomer($customer);
|
310 |
+
$this->_filteredObjects[] = 'subscriber';
|
311 |
+
}
|
312 |
+
|
313 |
+
return $this;
|
314 |
+
}
|
315 |
+
|
316 |
+
/**
|
317 |
+
* @param Mage_Customer_Model_Customer $customer
|
318 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
319 |
*/
|
320 |
protected function _filterCustomer(Mage_Customer_Model_Customer $customer)
|
321 |
{
|
322 |
if (!in_array('customer', $this->_filteredObjects)) {
|
323 |
+
$this->setField('customerName', $customer->getName());
|
324 |
+
$this->setField('customerEmail', $customer->getEmail());
|
325 |
$this->setField('customerPassword', $customer->getPassword());
|
326 |
+
if ($store = $customer->getStore()) {
|
327 |
+
$this->setField('confirmationLink', $store->getUrl('customer/account/confirm', array('_query' => array('id' => $customer->getId(), 'key' => $customer->getConfirmation()))));
|
328 |
if (version_compare(Mage::getVersion(), '1.6.1.0', '>=')) {
|
329 |
$this->setField('passwordResetLink', $store->getUrl('customer/account/resetpassword', array('_query' => array('id' => $customer->getId(), 'token' => $customer->getRpToken()))));
|
330 |
}
|
331 |
} else {
|
332 |
+
$this->setField('confirmationLink', Mage::getUrl('customer/account/confirm', array('_query' => array('id' => $customer->getId(), 'key' => $customer->getConfirmation()))));
|
333 |
if (version_compare(Mage::getVersion(), '1.6.1.0', '>=')) {
|
334 |
$this->setField('passwordResetLink', Mage::getUrl('customer/account/resetpassword', array('_query' => array('id' => $customer->getId(), 'token' => $customer->getRpToken()))));
|
335 |
}
|
342 |
}
|
343 |
|
344 |
/**
|
345 |
+
* @param Mage_Sales_Model_Order $order
|
346 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
347 |
*/
|
348 |
protected function _filterOrder(Mage_Sales_Model_Order $order, $type = 'order')
|
349 |
{
|
350 |
if (!in_array('order', $this->_filteredObjects)) {
|
351 |
+
$this->setStoreId($order->getStoreId());
|
352 |
+
|
353 |
// Order may not be a shippable order
|
354 |
+
$shipAddress = 'N/A';
|
355 |
$shipDescription = 'N/A';
|
356 |
if ($order->getIsNotVirtual()) {
|
357 |
+
$shipAddress = $order->getShippingAddress()->format('html');
|
358 |
$shipDescription = $order->getShippingDescription();
|
359 |
}
|
360 |
|
361 |
// Check for guest orders
|
362 |
$customerName = $order->getCustomerIsGuest() ? $order->getBillingAddress()->getName() : $order->getCustomerName();
|
363 |
|
364 |
+
$this->setField('orderIncrementId', $order->getIncrementId());
|
365 |
+
$this->setField('orderCreatedAt', $order->getCreatedAtFormated('long'));
|
366 |
+
$this->setField('orderBillingAddress', $order->getBillingAddress()->format('html'));
|
367 |
+
$this->setField('orderShippingAddress', $shipAddress);
|
368 |
$this->setField('orderShippingDescription', $shipDescription);
|
369 |
+
$this->setField('orderCustomerName', $customerName);
|
370 |
+
$this->setField('orderStatusLabel', $order->getStatusLabel());
|
371 |
+
$this->setField('orderItems', $this->_filterOrderItems($order));
|
372 |
|
373 |
$this->_filteredObjects[] = 'order';
|
374 |
}
|
380 |
{
|
381 |
if (!in_array('address', $this->_filteredObjects)) {
|
382 |
|
383 |
+
$this->setField('billingName', $address->getName());
|
384 |
$this->_filteredObjects[] = 'address';
|
385 |
}
|
386 |
return $this;
|
387 |
}
|
388 |
|
389 |
/**
|
390 |
+
* @param Mage_Sales_Model_Order_Invoice $invoice
|
391 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
392 |
*/
|
393 |
protected function _filterInvoice(Mage_Sales_Model_Order_Invoice $invoice)
|
394 |
{
|
395 |
if (!in_array('invoice', $this->_filteredObjects)) {
|
396 |
$this->setField('invoiceIncrementId', $invoice->getIncrementId());
|
397 |
+
$this->setField('invoiceItems', $this->_filterInvoiceItems($invoice));
|
398 |
|
399 |
$this->_filteredObjects[] = 'invoice';
|
400 |
}
|
403 |
}
|
404 |
|
405 |
/**
|
406 |
+
* @param Mage_Sales_Model_Order_Shipment $shipment
|
407 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
408 |
*/
|
409 |
protected function _filterShipment(Mage_Sales_Model_Order_Shipment $shipment)
|
410 |
{
|
411 |
if (!in_array('shipment', $this->_filteredObjects)) {
|
412 |
$this->setField('shipmentIncrementId', $shipment->getIncrementId());
|
413 |
+
$this->setField('shipmentCreatedAt', Mage::helper('core')->formatDate($shipment->getCreatedAtStoreDate(), 'long', true)); // TODO: needed?
|
414 |
+
$this->setField('shipmentItems', $this->_filterShipmentItems($shipment));
|
415 |
+
$this->setField('shipmentTracking', $this->_getShipmentTrackingNumber($shipment, $shipment->getOrder()));
|
416 |
|
417 |
$this->_filteredObjects[] = 'shipment';
|
418 |
}
|
421 |
}
|
422 |
|
423 |
/**
|
424 |
+
* @param Mage_Sales_Model_Order_Creditmemo $creditmemo
|
425 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
426 |
*/
|
427 |
protected function _filterCreditmemo(Mage_Sales_Model_Order_Creditmemo $creditmemo)
|
428 |
{
|
429 |
if (!in_array('creditmemo', $this->_filteredObjects)) {
|
430 |
$this->setField('creditmemoIncrementId', $creditmemo->getIncrementId());
|
431 |
+
$this->setField('creditmemoCreatedAt', Mage::helper('core')->formatDate($creditmemo->getCreatedAtStoreDate(), 'long', true)); // TODO: needed?
|
432 |
+
$this->setField('creditmemoItems', $this->_filterCreditmemoItems($creditmemo));
|
433 |
|
434 |
$this->_filteredObjects[] = 'creditmemo';
|
435 |
}
|
437 |
}
|
438 |
|
439 |
/**
|
440 |
+
* @param Mage_Sales_Model_Quote $order
|
441 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
442 |
*/
|
443 |
protected function _filterQuote(Mage_Sales_Model_Quote $quote)
|
444 |
{
|
445 |
if (!in_array('quote', $this->_filteredObjects)) {
|
446 |
+
$this->setStoreId($quote->getStoreId());
|
447 |
+
$currencyCode = $quote->getQuoteCurrencyCode();
|
448 |
+
|
449 |
+
$this->setField('subtotal', $this->formatPrice($quote->getSubtotal(), $currencyCode));
|
450 |
+
$this->setField('grandTotal', $this->formatPrice($quote->getGrandTotal(), $currencyCode));
|
451 |
|
452 |
$index = 1;
|
453 |
+
foreach ($quote->getAllItems() as $item/* @var $item Mage_Sales_Model_Quote_Item */) {
|
454 |
if (!$item->getParentItem()) {
|
455 |
$this->_filterQuoteItem($item, $index);
|
456 |
$index++;
|
457 |
}
|
458 |
}
|
459 |
+
|
460 |
+
$queryParams = $this->getQueryParams();
|
461 |
$queryParams['id'] = urlencode(base64_encode(Mage::helper('core')->encrypt($quote->getId())));
|
462 |
if ($store = $this->getStore()) {
|
463 |
$this->setField('quoteURL', $store->getUrl('reminder/load/index', $queryParams));
|
485 |
}
|
486 |
|
487 |
/**
|
488 |
+
* @param Mage_Sales_Model_Quote_Item $item
|
489 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
490 |
*/
|
491 |
protected function _filterQuoteItem($item, $index = null)
|
492 |
{
|
494 |
return $this;
|
495 |
}
|
496 |
|
497 |
+
$this->setField("productName_{$index}", $item->getName());
|
498 |
+
$this->setField("productSku_{$index}", $item->getSku());
|
499 |
+
$this->setField("productPrice_{$index}", $this->formatPrice($item->getConvertedPrice()));
|
500 |
+
$this->setField("productTotal_{$index}", $this->formatPrice($item->calcRowTotal()->getRowTotal()));
|
501 |
+
$this->setField("productQty_{$index}", $item->getQty());
|
502 |
+
$this->setField("productUrl_{$index}", $this->_getQuoteItemUrl($item));
|
503 |
|
504 |
/* @var $product Mage_Catalog_Model_Product */
|
505 |
$product = $item->getProduct();
|
512 |
}
|
513 |
|
514 |
/**
|
515 |
+
* @param Mage_Wishlist_Model_Wishlist $wishlist
|
516 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
517 |
*/
|
518 |
protected function _filterWishlist(Mage_Wishlist_Model_Wishlist $wishlist)
|
519 |
{
|
520 |
if (!in_array('wishlist', $this->_filteredObjects)) {
|
521 |
$index = 1;
|
522 |
+
foreach ($wishlist->getItemCollection() as $item/* @var $item Mage_Wishlist_Model_Item */) {
|
523 |
if (!$item->getParentItem()) {
|
524 |
$this->_filterWishlistItem($item, $index);
|
525 |
$index++;
|
526 |
}
|
527 |
}
|
528 |
|
529 |
+
$queryParams = $this->getQueryParams();
|
530 |
$queryParams['wishlist_id'] = urlencode(base64_encode(Mage::helper('core')->encrypt($wishlist->getId())));
|
531 |
if ($store = $this->getStore()) {
|
532 |
$this->setField('wishlistURL', $store->getUrl('reminder/load/index', $queryParams));
|
554 |
}
|
555 |
|
556 |
/**
|
557 |
+
* @param Mage_Wishlist_Model_Item $item
|
558 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
559 |
*/
|
560 |
protected function _filterWishlistItem(Mage_Wishlist_Model_Item $item, $index = null)
|
561 |
{
|
562 |
if ($item->getParentItem()) {
|
563 |
return $this;
|
564 |
}
|
565 |
+
|
566 |
+
$this->setStoreId($item->getStoreId());
|
567 |
+
$this->setField("productName_{$index}", $item->getName());
|
568 |
+
$this->setField("productPrice_{$index}", $this->formatPrice($item->getPrice()));
|
569 |
+
$this->setField("productQty_{$index}", $item->getQty());
|
570 |
+
$this->setField("productUrl_{$index}", $this->_getWishlistItemUrl($item));
|
571 |
|
572 |
/* @var $product Mage_Catalog_Model_Product */
|
573 |
$product = $item->getProduct();
|
574 |
if (!$product) {
|
575 |
$product = Mage::getModel('catalog/product')->load($item->getProductId());
|
576 |
}
|
577 |
+
$this->setField("productSku_{$index}", $product->getSku());
|
578 |
+
|
579 |
$this->_filterProduct($product, $index);
|
580 |
|
581 |
return $this;
|
614 |
*/
|
615 |
protected function _filterInvoiceItems(Mage_Sales_Model_Order_Invoice $invoice)
|
616 |
{
|
617 |
+
$order = $invoice->getOrder();
|
618 |
$layout = Mage::getSingleton('core/layout');
|
619 |
|
620 |
/* @var $items Mage_Sales_Block_Items_Abstract */
|
667 |
* Get the shipment tracking info.
|
668 |
*
|
669 |
* @param Mage_Sales_Model_Order_Shipment $shipment
|
670 |
+
* @param Mage_Sales_Model_Order $order
|
671 |
*/
|
672 |
protected function _getShipmentTrackingNumber(Mage_Sales_Model_Order_Shipment $shipment, Mage_Sales_Model_Order $order)
|
673 |
{
|
674 |
$layout = Mage::getSingleton('core/layout');
|
675 |
+
$block = $layout->createBlock('core/template')->setTemplate('email/order/shipment/track.phtml');
|
676 |
$block->setOrder($order);
|
677 |
$block->setShipment($shipment);
|
678 |
$block->setArea('frontend');
|
686 |
*/
|
687 |
protected function _filterCreditmemoItems(Mage_Sales_Model_Order_Creditmemo $creditmemo)
|
688 |
{
|
689 |
+
$order = $creditmemo->getOrder();
|
690 |
$layout = Mage::getSingleton('core/layout');
|
691 |
|
692 |
/* @var $items Mage_Sales_Block_Items_Abstract */
|
712 |
/**
|
713 |
* Get the totals block for order-style emails.
|
714 |
*
|
715 |
+
* @param Mage_Core_Model_Layout $layout
|
716 |
+
* @param Mage_Sales_Model_Order $order
|
717 |
+
* @param String $totals_block_type
|
718 |
+
* @param String $totals_block_name
|
719 |
* @return Mage_Core_Block_Template
|
720 |
*/
|
721 |
protected function _getTotalsBlock($layout, $order, $totals_block_type, $totals_block_name)
|
736 |
}
|
737 |
|
738 |
/**
|
739 |
+
* @param Mage_Catalog_Model_Product $product
|
740 |
+
* @param int $index
|
741 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
742 |
*/
|
743 |
protected function _filterProduct(Mage_Catalog_Model_Product $product, $index = null)
|
744 |
{
|
745 |
+
// Load full product
|
746 |
+
$product = Mage::getModel('catalog/product')
|
747 |
+
->setStoreId($product->getStoreId())
|
748 |
+
->load($product->getId());
|
749 |
+
|
750 |
if ($index !== null) {
|
751 |
try {
|
752 |
+
$imageUrl = Mage::helper('bronto_common')->getProductImageUrl($product);
|
753 |
+
$this->setField("productImgUrl_{$index}", $imageUrl);
|
754 |
} catch (Exception $e) {
|
755 |
Mage::log('Error loading image: ' . $e);
|
756 |
}
|
757 |
} else {
|
758 |
+
$this->setField('productUrl', $product->getUrl());
|
759 |
$this->setField('productName', $product->getName());
|
760 |
}
|
761 |
|
772 |
return $item->getRedirectUrl();
|
773 |
}
|
774 |
|
775 |
+
return $item->getProduct()->getProductUrl();
|
|
|
|
|
|
|
|
|
|
|
|
|
776 |
}
|
777 |
|
778 |
/**
|
785 |
return $item->getRedirectUrl();
|
786 |
}
|
787 |
|
788 |
+
return $item->getProduct()->getProductUrl();
|
|
|
|
|
|
|
|
|
|
|
|
|
789 |
}
|
790 |
|
791 |
/**
|
792 |
+
* @param string $key
|
793 |
+
* @param string|array $value
|
794 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
795 |
*/
|
796 |
public function setField($key, $value, $type = 'html')
|
797 |
{
|
803 |
// Address objects come in as an array on payment failed emails
|
804 |
$delim = $type == 'html' ? '<br/>' : "\n\r";
|
805 |
if (isset($value['address_id'])) {
|
806 |
+
$new_value = $value['street'] . $delim;
|
807 |
$new_value .= $value['city'] . $delim;
|
808 |
$new_value .= $value['region'] . $delim;
|
809 |
$new_value .= $value['postcode'] . $delim;
|
832 |
/**
|
833 |
* Setter
|
834 |
*
|
835 |
+
* @param integer $storeId
|
836 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
837 |
*/
|
838 |
public function setStoreId($storeId)
|
839 |
{
|
857 |
|
858 |
/**
|
859 |
* @param Mage_Core_Model_Store $store
|
860 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
861 |
*/
|
862 |
public function setStore(Mage_Core_Model_Store $store)
|
863 |
{
|
864 |
$this->_store = $store;
|
865 |
+
$this->setStoreId($store->getId());
|
866 |
return $this;
|
867 |
}
|
868 |
|
871 |
*/
|
872 |
public function getStore()
|
873 |
{
|
874 |
+
// Only attempt to load the store if a storeId is present
|
875 |
+
if ($this->_storeId) {
|
876 |
+
if (is_null($this->_store) || $this->_store->getId() != $this->_storeId) {
|
877 |
+
$this->_store = Mage::getModel('core/store')->load($this->_storeId);
|
878 |
+
}
|
879 |
+
} else if (is_null($this->_store)) {
|
880 |
+
$this->_store = Mage::app()->getStore();
|
881 |
+
}
|
882 |
return $this->_store;
|
883 |
}
|
884 |
|
885 |
/**
|
886 |
* @param string $messageId
|
887 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
888 |
*/
|
889 |
public function setMessageId($messageId)
|
890 |
{
|
901 |
}
|
902 |
|
903 |
/**
|
904 |
+
* @param array $variables
|
905 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
906 |
*/
|
907 |
+
public function setVariables(array $variables)
|
908 |
{
|
|
|
|
|
|
|
909 |
foreach ($variables as $name => $value) {
|
910 |
$this->_variables[$name] = $value;
|
911 |
}
|
913 |
}
|
914 |
|
915 |
/**
|
916 |
+
* @param array $variables
|
917 |
+
* @return Bronto_Common_Model_Email_Template_Filter
|
918 |
*/
|
919 |
public function setAvailable($variables = array())
|
920 |
{
|
965 |
}
|
966 |
return $string;
|
967 |
}
|
968 |
+
|
969 |
+
/**
|
970 |
+
* Convenience method for formatting currency values
|
971 |
+
*
|
972 |
+
* @param float $price
|
973 |
+
* @param string $currency (Optional)
|
974 |
+
* @return string
|
975 |
+
*/
|
976 |
+
protected function formatPrice($price, $currencyCode = null)
|
977 |
+
{
|
978 |
+
$options = array(
|
979 |
+
'precision' => 2,
|
980 |
+
'display' => Zend_Currency::NO_SYMBOL,
|
981 |
+
);
|
982 |
+
|
983 |
+
if (Mage::helper('bronto_common')->useCurrenySymbol($this->getStore()->getId())) {
|
984 |
+
unset($options['display']);
|
985 |
+
}
|
986 |
+
|
987 |
+
$currencyCode = $currencyCode ? $currencyCode : $this->getStore()->getDefaultCurrencyCode();
|
988 |
+
if (is_null($this->_currency) || $this->_currency->getCode() != $currencyCode) {
|
989 |
+
$this->_currency = Mage::getModel('directory/currency')->load($currencyCode);
|
990 |
+
}
|
991 |
+
|
992 |
+
return $this->_currency->formatTxt($price, $options);
|
993 |
+
}
|
994 |
}
|
app/code/community/Bronto/Common/Model/Email/{Message → Template}/Templatefilter.php
RENAMED
@@ -1,19 +1,19 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
class
|
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 |
/**
|
@@ -23,24 +23,24 @@ class Bronto_Common_Model_Email_Message_Templatefilter extends Mage_Core_Model_E
|
|
23 |
*/
|
24 |
public function layoutDirective($construction)
|
25 |
{
|
26 |
-
$params = $this->_getIncludeParameters($construction[2]);
|
27 |
switch ($params['handle']) {
|
28 |
case 'sales_email_order_shipment_items':
|
29 |
-
$return = 'shipmentItems';
|
30 |
-
break;
|
31 |
case 'sales_email_order_items':
|
32 |
$return = 'orderItems';
|
33 |
-
break;
|
34 |
case 'sales_email_order_creditmemo_items':
|
35 |
$return = 'creditmemoItems';
|
36 |
-
break;
|
37 |
case 'sales_email_order_invoice_items':
|
38 |
$return = 'invoiceItems';
|
39 |
-
break;
|
40 |
default:
|
41 |
return '';
|
42 |
break;
|
43 |
-
}
|
44 |
return $this->_addBrontoStyle($return);
|
45 |
}
|
46 |
|
@@ -58,28 +58,6 @@ class Bronto_Common_Model_Email_Message_Templatefilter extends Mage_Core_Model_E
|
|
58 |
return $tokenizer->tokenize();
|
59 |
}
|
60 |
|
61 |
-
/**
|
62 |
-
* Retrieve Skin URL directive
|
63 |
-
*
|
64 |
-
* @param array $construction
|
65 |
-
* @return string
|
66 |
-
*/
|
67 |
-
public function skinDirective($construction)
|
68 |
-
{
|
69 |
-
return '';
|
70 |
-
}
|
71 |
-
|
72 |
-
/**
|
73 |
-
* Retrieve media file URL directive
|
74 |
-
*
|
75 |
-
* @param array $construction
|
76 |
-
* @return string
|
77 |
-
*/
|
78 |
-
public function mediaDirective($construction)
|
79 |
-
{
|
80 |
-
return '';
|
81 |
-
}
|
82 |
-
|
83 |
/**
|
84 |
* Retrieve store URL directive
|
85 |
* Support url and direct_url properties
|
@@ -90,11 +68,11 @@ class Bronto_Common_Model_Email_Message_Templatefilter extends Mage_Core_Model_E
|
|
90 |
public function storeDirective($construction)
|
91 |
{
|
92 |
$params = $this->_getIncludeParameters($construction[2]);
|
93 |
-
|
94 |
if (isset($params['direct_url'])) {
|
95 |
return $this->_addBrontoStyle('storeurl_' . str_replace('/', '_', $params['direct_url']));
|
96 |
} elseif (isset($params['url'])) {
|
97 |
-
switch (trim($params['url'],'/')) {
|
98 |
case 'checkout/cart':
|
99 |
return $this->_addBrontoStyle('cartURL');
|
100 |
case 'wishlist/wishlist':
|
@@ -112,7 +90,7 @@ class Bronto_Common_Model_Email_Message_Templatefilter extends Mage_Core_Model_E
|
|
112 |
return $this->_addBrontoStyle('confirmationLink');
|
113 |
case '':
|
114 |
return $this->_addBrontoStyle('storeURL');
|
115 |
-
default:
|
116 |
return $this->_addBrontoStyle('storeurl_' . str_replace('/', '_', $params['url']));
|
117 |
}
|
118 |
} else {
|
@@ -131,11 +109,11 @@ class Bronto_Common_Model_Email_Message_Templatefilter extends Mage_Core_Model_E
|
|
131 |
public function htmlescapeDirective($construction)
|
132 |
{
|
133 |
$params = $this->_getIncludeParameters($construction[2]);
|
134 |
-
|
135 |
-
if (strstr($construction[2],'var') === FALSE) {
|
136 |
return '';
|
137 |
}
|
138 |
-
$returnVariable = $this->processVariable(str_replace('var=$',''
|
139 |
return $this->_addBrontoStyle($returnVariable);
|
140 |
}
|
141 |
|
@@ -146,23 +124,25 @@ class Bronto_Common_Model_Email_Message_Templatefilter extends Mage_Core_Model_E
|
|
146 |
* @return string
|
147 |
*/
|
148 |
public function varDirective($construction)
|
149 |
-
{
|
150 |
$returnVariable = $this->processVariable($construction[2]);
|
151 |
return $this->_addBrontoStyle($returnVariable);
|
152 |
}
|
153 |
-
|
154 |
-
protected function processVariable($variable)
|
155 |
{
|
156 |
-
|
157 |
switch (trim($variable)) {
|
158 |
case "order.getCreatedAtFormated('long')":
|
159 |
return 'orderCreatedAt';
|
160 |
case "rma.getCreatedAtFormated('long')":
|
161 |
return 'rmaCreatedAt';
|
162 |
case "logo_url":
|
163 |
-
return 'emailLogo';
|
164 |
case "user.name":
|
165 |
return 'adminName';
|
|
|
|
|
166 |
}
|
167 |
$parts = explode('|', $variable, 2);
|
168 |
if (2 === count($parts)) {
|
@@ -210,7 +190,7 @@ class Bronto_Common_Model_Email_Message_Templatefilter extends Mage_Core_Model_E
|
|
210 |
{
|
211 |
$configValue = '';
|
212 |
$params = $this->_getIncludeParameters($construction[2]);
|
213 |
-
|
214 |
switch ($params['path']) {
|
215 |
case 'trans_email/ident_support/email':
|
216 |
$returnValue = 'supportEmail';
|
@@ -222,23 +202,12 @@ class Bronto_Common_Model_Email_Message_Templatefilter extends Mage_Core_Model_E
|
|
222 |
$returnValue = 'salesEmail';
|
223 |
break;
|
224 |
default:
|
225 |
-
$returnValue = str_replace('/','_'
|
226 |
break;
|
227 |
}
|
228 |
return $this->_addBrontoStyle($returnValue);
|
229 |
}
|
230 |
|
231 |
-
/**
|
232 |
-
* Custom Variable directive
|
233 |
-
*
|
234 |
-
* @param array $construction
|
235 |
-
* @return string
|
236 |
-
*/
|
237 |
-
public function customvarDirective($construction)
|
238 |
-
{
|
239 |
-
return '';
|
240 |
-
}
|
241 |
-
|
242 |
/**
|
243 |
* Filter the string as template.
|
244 |
* Rewrited for logging exceptions
|
@@ -251,7 +220,7 @@ class Bronto_Common_Model_Email_Message_Templatefilter extends Mage_Core_Model_E
|
|
251 |
try {
|
252 |
$value = parent::filter($value);
|
253 |
} catch (Exception $e) {
|
254 |
-
$value = '';
|
255 |
Mage::logException($e);
|
256 |
}
|
257 |
return $value;
|
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 |
/**
|
23 |
*/
|
24 |
public function layoutDirective($construction)
|
25 |
{
|
26 |
+
$params = $this->_getIncludeParameters($construction[2]);
|
27 |
switch ($params['handle']) {
|
28 |
case 'sales_email_order_shipment_items':
|
29 |
+
$return = 'shipmentItems';
|
30 |
+
break;
|
31 |
case 'sales_email_order_items':
|
32 |
$return = 'orderItems';
|
33 |
+
break;
|
34 |
case 'sales_email_order_creditmemo_items':
|
35 |
$return = 'creditmemoItems';
|
36 |
+
break;
|
37 |
case 'sales_email_order_invoice_items':
|
38 |
$return = 'invoiceItems';
|
39 |
+
break;
|
40 |
default:
|
41 |
return '';
|
42 |
break;
|
43 |
+
}
|
44 |
return $this->_addBrontoStyle($return);
|
45 |
}
|
46 |
|
58 |
return $tokenizer->tokenize();
|
59 |
}
|
60 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
/**
|
62 |
* Retrieve store URL directive
|
63 |
* Support url and direct_url properties
|
68 |
public function storeDirective($construction)
|
69 |
{
|
70 |
$params = $this->_getIncludeParameters($construction[2]);
|
71 |
+
|
72 |
if (isset($params['direct_url'])) {
|
73 |
return $this->_addBrontoStyle('storeurl_' . str_replace('/', '_', $params['direct_url']));
|
74 |
} elseif (isset($params['url'])) {
|
75 |
+
switch (trim($params['url'], '/')) {
|
76 |
case 'checkout/cart':
|
77 |
return $this->_addBrontoStyle('cartURL');
|
78 |
case 'wishlist/wishlist':
|
90 |
return $this->_addBrontoStyle('confirmationLink');
|
91 |
case '':
|
92 |
return $this->_addBrontoStyle('storeURL');
|
93 |
+
default:
|
94 |
return $this->_addBrontoStyle('storeurl_' . str_replace('/', '_', $params['url']));
|
95 |
}
|
96 |
} else {
|
109 |
public function htmlescapeDirective($construction)
|
110 |
{
|
111 |
$params = $this->_getIncludeParameters($construction[2]);
|
112 |
+
|
113 |
+
if (strstr($construction[2], 'var') === FALSE) {
|
114 |
return '';
|
115 |
}
|
116 |
+
$returnVariable = $this->processVariable(str_replace('var=$', '', $construction[2]));
|
117 |
return $this->_addBrontoStyle($returnVariable);
|
118 |
}
|
119 |
|
124 |
* @return string
|
125 |
*/
|
126 |
public function varDirective($construction)
|
127 |
+
{
|
128 |
$returnVariable = $this->processVariable($construction[2]);
|
129 |
return $this->_addBrontoStyle($returnVariable);
|
130 |
}
|
131 |
+
|
132 |
+
protected function processVariable($variable)
|
133 |
{
|
134 |
+
|
135 |
switch (trim($variable)) {
|
136 |
case "order.getCreatedAtFormated('long')":
|
137 |
return 'orderCreatedAt';
|
138 |
case "rma.getCreatedAtFormated('long')":
|
139 |
return 'rmaCreatedAt';
|
140 |
case "logo_url":
|
141 |
+
return 'emailLogo';
|
142 |
case "user.name":
|
143 |
return 'adminName';
|
144 |
+
case "subscriber.getConfirmationLink()":
|
145 |
+
return 'subConfirmationLink';
|
146 |
}
|
147 |
$parts = explode('|', $variable, 2);
|
148 |
if (2 === count($parts)) {
|
190 |
{
|
191 |
$configValue = '';
|
192 |
$params = $this->_getIncludeParameters($construction[2]);
|
193 |
+
|
194 |
switch ($params['path']) {
|
195 |
case 'trans_email/ident_support/email':
|
196 |
$returnValue = 'supportEmail';
|
202 |
$returnValue = 'salesEmail';
|
203 |
break;
|
204 |
default:
|
205 |
+
$returnValue = str_replace('/', '_', $params['path']);
|
206 |
break;
|
207 |
}
|
208 |
return $this->_addBrontoStyle($returnValue);
|
209 |
}
|
210 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
211 |
/**
|
212 |
* Filter the string as template.
|
213 |
* Rewrited for logging exceptions
|
220 |
try {
|
221 |
$value = parent::filter($value);
|
222 |
} catch (Exception $e) {
|
223 |
+
$value = '';
|
224 |
Mage::logException($e);
|
225 |
}
|
226 |
return $value;
|
app/code/community/Bronto/Common/Model/Keysentry.php
CHANGED
@@ -8,59 +8,89 @@
|
|
8 |
class Bronto_Common_Model_Keysentry extends Mage_Core_Model_Abstract
|
9 |
{
|
10 |
/**
|
11 |
-
* Bronto
|
12 |
*/
|
13 |
-
const
|
14 |
|
15 |
/**
|
16 |
-
* Bronto
|
17 |
*/
|
18 |
-
const
|
19 |
|
20 |
/**
|
21 |
-
* Bronto
|
22 |
*/
|
23 |
-
const
|
24 |
|
25 |
/**
|
26 |
* Bronto newsletter module alias
|
27 |
*/
|
28 |
const NEWSLETTER = 'bronto_newsletter';
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
/**
|
31 |
* Disable all the defined modules for the scope
|
32 |
*
|
33 |
-
* @param mixed
|
34 |
* @param integer $scopeId Site scope id
|
35 |
*/
|
36 |
public function disableModules($scope, $scopeId)
|
37 |
{
|
|
|
38 |
Mage::helper(self::EMAIL)->disableModule($scope, $scopeId);
|
|
|
|
|
39 |
Mage::helper(self::ORDER)->disableModule($scope, $scopeId);
|
40 |
Mage::helper(self::REMINDER)->disableModule($scope, $scopeId);
|
41 |
-
|
|
|
|
|
42 |
}
|
43 |
|
44 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
{
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
|
51 |
-
//
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
|
56 |
-
|
57 |
-
|
58 |
-
|
|
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
$
|
63 |
}
|
64 |
-
*/
|
65 |
}
|
66 |
}
|
8 |
class Bronto_Common_Model_Keysentry extends Mage_Core_Model_Abstract
|
9 |
{
|
10 |
/**
|
11 |
+
* Bronto customer module alias
|
12 |
*/
|
13 |
+
const CUSTOMER = 'bronto_customer';
|
14 |
|
15 |
/**
|
16 |
+
* Bronto email module alias
|
17 |
*/
|
18 |
+
const EMAIL = 'bronto_email';
|
19 |
|
20 |
/**
|
21 |
+
* Bronto newsletter module alias
|
22 |
*/
|
23 |
+
const NEWS = 'bronto_news';
|
24 |
|
25 |
/**
|
26 |
* Bronto newsletter module alias
|
27 |
*/
|
28 |
const NEWSLETTER = 'bronto_newsletter';
|
29 |
|
30 |
+
/**
|
31 |
+
* Bronto order module alias
|
32 |
+
*/
|
33 |
+
const ORDER = 'bronto_order';
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Bronto reminder module alias
|
37 |
+
*/
|
38 |
+
const REMINDER = 'bronto_reminder';
|
39 |
+
|
40 |
/**
|
41 |
* Disable all the defined modules for the scope
|
42 |
*
|
43 |
+
* @param mixed $scope Site scope
|
44 |
* @param integer $scopeId Site scope id
|
45 |
*/
|
46 |
public function disableModules($scope, $scopeId)
|
47 |
{
|
48 |
+
Mage::helper(self::CUSTOMER)->disableModule($scope, $scopeId);
|
49 |
Mage::helper(self::EMAIL)->disableModule($scope, $scopeId);
|
50 |
+
Mage::helper(self::NEWS)->disableModule($scope, $scopeId);
|
51 |
+
Mage::helper(self::NEWSLETTER)->disableModule($scope, $scopeId);
|
52 |
Mage::helper(self::ORDER)->disableModule($scope, $scopeId);
|
53 |
Mage::helper(self::REMINDER)->disableModule($scope, $scopeId);
|
54 |
+
|
55 |
+
Mage::getConfig()->reinit();
|
56 |
+
Mage::app()->reinitStores();
|
57 |
}
|
58 |
|
59 |
+
/**
|
60 |
+
* Remove Bronto Message Connection for Template
|
61 |
+
*
|
62 |
+
* @param Varien_Data_Collection_Db $collection
|
63 |
+
* @param $scopeId Store ID
|
64 |
+
*/
|
65 |
+
public function unlinkEmails(Varien_Data_Collection_Db $collection, $scope, $scopeId)
|
66 |
{
|
67 |
+
switch ($scope) {
|
68 |
+
case 'stores':
|
69 |
+
case 'store':
|
70 |
+
$storeId = $scopeId;
|
71 |
+
break;
|
72 |
+
case 'websites':
|
73 |
+
case 'website':
|
74 |
+
$storeId = Mage::app()->getWebsite($scopeId)->getStoreIds();
|
75 |
+
break;
|
76 |
+
default:
|
77 |
+
$storeId = false;
|
78 |
+
break;
|
79 |
+
}
|
80 |
|
81 |
+
// create filter
|
82 |
+
if ($storeId) {
|
83 |
+
if (is_array($storeId)) {
|
84 |
+
$filter = array('in' => $storeId);
|
85 |
+
} else {
|
86 |
+
$filter = array('eq' => $storeId);
|
87 |
+
}
|
88 |
+
$collection->addFieldToFilter('store_id', $filter);
|
89 |
+
}
|
90 |
|
91 |
+
// Delete Bronto Message connection to template
|
92 |
+
foreach ($collection as $message) {
|
93 |
+
$message->delete();
|
94 |
}
|
|
|
95 |
}
|
96 |
}
|
app/code/community/Bronto/Common/Model/Observer.php
CHANGED
@@ -7,29 +7,171 @@
|
|
7 |
class Bronto_Common_Model_Observer
|
8 |
{
|
9 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
/**
|
11 |
* Description for const
|
12 |
*/
|
13 |
const NOTICE_IDENTIFER = 'bronto_common';
|
14 |
|
|
|
|
|
15 |
/**
|
|
|
16 |
* @param Varien_Event_Observer $observer
|
17 |
-
* @return mixed
|
18 |
*/
|
19 |
public function checkBrontoRequirements(Varien_Event_Observer $observer)
|
20 |
{
|
21 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
22 |
return;
|
23 |
}
|
24 |
|
|
|
|
|
25 |
// Verify Requirements
|
26 |
-
if (
|
27 |
return;
|
28 |
}
|
29 |
|
30 |
// Verify API tokens are valid
|
31 |
-
if (
|
32 |
return false;
|
33 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
}
|
35 |
}
|
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_IDENTIFER = 'bronto_common';
|
23 |
|
24 |
+
const SUPPORT_IDENTIFIER = 'bronto_common/support';
|
25 |
+
|
26 |
/**
|
27 |
+
* events: controller_action_predispatch
|
28 |
* @param Varien_Event_Observer $observer
|
29 |
+
* @return mixed
|
30 |
*/
|
31 |
public function checkBrontoRequirements(Varien_Event_Observer $observer)
|
32 |
{
|
33 |
+
|
34 |
+
$action = $observer->getEvent()->getControllerAction();
|
35 |
+
// In session, not Ajax, not POST
|
36 |
+
if (
|
37 |
+
!Mage::getSingleton('admin/session')->isLoggedIn() ||
|
38 |
+
$action->getRequest()->isAjax() ||
|
39 |
+
$action->getRequest()->isPost()
|
40 |
+
) {
|
41 |
return;
|
42 |
}
|
43 |
|
44 |
+
$helper = Mage::helper(self::NOTICE_IDENTIFER);
|
45 |
+
|
46 |
// Verify Requirements
|
47 |
+
if (!$helper->varifyRequirements(self::NOTICE_IDENTIFER, array('soap', 'openssl'))) {
|
48 |
return;
|
49 |
}
|
50 |
|
51 |
// Verify API tokens are valid
|
52 |
+
if ($helper->isEnabled() && !$helper->validApiTokens(self::NOTICE_IDENTIFER)) {
|
53 |
return false;
|
54 |
}
|
55 |
+
|
56 |
+
// Bug user about registration, only once
|
57 |
+
if (!Mage::helper(self::SUPPORT_IDENTIFIER)->isRegistered()) {
|
58 |
+
$appendix = '<a href="#bronto_support-head">below</a>.';
|
59 |
+
if ($action->getRequest()->getParam('section') != 'bronto') {
|
60 |
+
$registerUrl = Mage::getSingleton('adminhtml/url')
|
61 |
+
->getUrl('*/system_config/edit', array('section' => 'bronto'));
|
62 |
+
$appendix = '<a href="' . $registerUrl . '">here</a>.';
|
63 |
+
}
|
64 |
+
|
65 |
+
$message = Mage::getSingleton('core/message')
|
66 |
+
->warning($helper->__('Please register your Bronto extension ' . $appendix));
|
67 |
+
$message->setIdentifier(self::NOTICE_IDENTIFER);
|
68 |
+
$session = Mage::getSingleton('adminhtml/session');
|
69 |
+
foreach ($session->getMessages()->getItemsByType('warning') as $setMessage) {
|
70 |
+
if ($setMessage->getIdentifier() == $message->getIdentifier()) {
|
71 |
+
$exists = true;
|
72 |
+
break;
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
if (empty($exists)) {
|
77 |
+
$session->addMessage($message);
|
78 |
+
}
|
79 |
+
}
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Cron to clear downloaded zips
|
84 |
+
*/
|
85 |
+
public function clearArchives($cron) {
|
86 |
+
Mage::helper(self::SUPPORT_IDENTIFIER)->clearArchiveDirectory();
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Validates that certain fields are not empty
|
91 |
+
*
|
92 |
+
* @param array $config
|
93 |
+
* @param boolean $formatWeb (Optional)
|
94 |
+
* @throws Mage_Exception
|
95 |
+
*/
|
96 |
+
protected function _validateSupportForm($groups, $formatWeb = true) {
|
97 |
+
$helper = Mage::helper(self::NOTICE_IDENTIFER);
|
98 |
+
|
99 |
+
$errors = array();
|
100 |
+
foreach ($this->_validatedFields as $field => $label) {
|
101 |
+
if ($groups['support']['fields'][$field]['inherit']) {
|
102 |
+
continue;
|
103 |
+
}
|
104 |
+
|
105 |
+
if (empty($groups['support']['fields'][$field]['value'])) {
|
106 |
+
$errors[] = $helper->__("Please enter your $label.");
|
107 |
+
}
|
108 |
+
}
|
109 |
+
|
110 |
+
if (!empty($groups['support']['fields']['using_solution_partner']['value'])) {
|
111 |
+
if ($groups['support']['fields']['partner']['inherit']) {
|
112 |
+
continue;
|
113 |
+
}
|
114 |
+
|
115 |
+
if (empty($groups['support']['fields']['partner']['value'])) {
|
116 |
+
$errors[] = $helper->__('Please enter your Solution Partner or SI Name.');
|
117 |
+
}
|
118 |
+
}
|
119 |
+
|
120 |
+
if ($errors) {
|
121 |
+
Mage::throwException(implode($formatWeb ? '<br/>' : "\n", $errors));
|
122 |
+
}
|
123 |
+
}
|
124 |
+
|
125 |
+
/**
|
126 |
+
* Save registration from from admin save config button
|
127 |
+
* events: model_config_data_save_before
|
128 |
+
*
|
129 |
+
* @param Varien_Event_Observer $observer
|
130 |
+
* @return boolean
|
131 |
+
*/
|
132 |
+
public function registerExtension(Varien_Event_Observer $observer) {
|
133 |
+
$action = $observer->getEvent()->getControllerAction();
|
134 |
+
$session = Mage::getSingleton('admin/session');
|
135 |
+
$support = Mage::helper(self::SUPPORT_IDENTIFIER);
|
136 |
+
|
137 |
+
if (
|
138 |
+
$session->isLoggedIn() &&
|
139 |
+
!$action->getRequest()->isAjax() &&
|
140 |
+
$action->getRequest()->isPost() &&
|
141 |
+
$action->getRequest()->getParam('section') == 'bronto'
|
142 |
+
) {
|
143 |
+
|
144 |
+
$groups = $action->getRequest()->getParam('groups');
|
145 |
+
$apiToken = $groups['settings']['fields']['api_token']['value'];
|
146 |
+
|
147 |
+
if (empty($apiToken)) {
|
148 |
+
return false;
|
149 |
+
}
|
150 |
+
|
151 |
+
try {
|
152 |
+
$this->_validateSupportForm($groups);
|
153 |
+
|
154 |
+
$postFields = array();
|
155 |
+
foreach ($groups['support']['fields'] as $field => $values) {
|
156 |
+
if ($groups['support']['fields'][$field]['inherit']) {
|
157 |
+
continue;
|
158 |
+
}
|
159 |
+
$postFields[$field] = $values['value'];
|
160 |
+
}
|
161 |
+
|
162 |
+
return $support->submitSupportForm($postFields);
|
163 |
+
} catch (Exception $e) {
|
164 |
+
Mage::getSingleton('adminhtml/session')
|
165 |
+
->addMessage(
|
166 |
+
Mage::getSingleton('core/message')
|
167 |
+
->error($e->getMessage())
|
168 |
+
->setIdentifier(self::NOTICE_IDENTIFER)
|
169 |
+
);
|
170 |
+
|
171 |
+
Mage::helper(self::NOTICE_IDENTIFER)->writeError($e->getMessage());
|
172 |
+
}
|
173 |
+
}
|
174 |
+
|
175 |
+
return false;
|
176 |
}
|
177 |
}
|
app/code/community/Bronto/Common/Model/Resource/Setup.php
CHANGED
@@ -10,7 +10,7 @@ class Bronto_Common_Model_Resource_Setup extends Mage_Sales_Model_Mysql4_Setup
|
|
10 |
public function handleOld()
|
11 |
{
|
12 |
// Look if Bronto folder exists in local codepool and recursively remove if it is
|
13 |
-
$source
|
14 |
$destination = Mage::getBaseDir('base') . DS . 'var' . DS . 'bronto_backup' . DS;
|
15 |
if (file_exists($source)) {
|
16 |
$this->rcopy($source, $destination);
|
10 |
public function handleOld()
|
11 |
{
|
12 |
// Look if Bronto folder exists in local codepool and recursively remove if it is
|
13 |
+
$source = Mage::getBaseDir('base') . DS . 'app' . DS . 'code' . DS . 'local' . DS . 'Bronto' . DS;
|
14 |
$destination = Mage::getBaseDir('base') . DS . 'var' . DS . 'bronto_backup' . DS;
|
15 |
if (file_exists($source)) {
|
16 |
$this->rcopy($source, $destination);
|
app/code/community/Bronto/Common/Model/System/Config/Backend/Cron.php
CHANGED
@@ -5,7 +5,8 @@
|
|
5 |
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
* @version 1.6.7
|
7 |
*/
|
8 |
-
abstract class Bronto_Common_Model_System_Config_Backend_Cron
|
|
|
9 |
{
|
10 |
/**
|
11 |
* @var string
|
@@ -38,19 +39,27 @@ abstract class Bronto_Common_Model_System_Config_Backend_Cron extends Mage_Core_
|
|
38 |
$frequency = $this->getFieldsetDataValue('frequency');
|
39 |
|
40 |
if ($frequency == $minutely) {
|
41 |
-
$interval
|
42 |
$cronExprString = "*/{$interval} * * * *";
|
43 |
-
}
|
|
|
44 |
$minutes = (int) $this->getFieldsetDataValue('minutes');
|
45 |
if ($minutes >= 0 && $minutes <= 59) {
|
46 |
$cronExprString = "{$minutes} * * * *";
|
47 |
-
}
|
|
|
48 |
Mage::throwException(Mage::helper('bronto_common')->__('Please, specify correct minutes of hour.'));
|
49 |
}
|
50 |
-
}
|
51 |
-
|
52 |
-
$
|
53 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
$cronExprString = "{$timeMinutes} {$timeHours} * * *";
|
55 |
}
|
56 |
}
|
@@ -60,9 +69,13 @@ abstract class Bronto_Common_Model_System_Config_Backend_Cron extends Mage_Core_
|
|
60 |
$this->_saveConfigData($this->_cron_string_path, $cronExprString);
|
61 |
}
|
62 |
if (!empty($this->_cron_model_path)) {
|
63 |
-
$this->_saveConfigData(
|
|
|
|
|
|
|
64 |
}
|
65 |
-
}
|
|
|
66 |
Mage::throwException(Mage::helper('adminhtml')->__('Unable to save Cron expression'));
|
67 |
}
|
68 |
}
|
@@ -85,7 +98,7 @@ abstract class Bronto_Common_Model_System_Config_Backend_Cron extends Mage_Core_
|
|
85 |
}
|
86 |
|
87 |
$data = $this->getData();
|
88 |
-
$groups = isset($data['groups'])
|
89 |
$groupId = isset($data['group_id']) ? $data['group_id'] : array();
|
90 |
foreach ($groups as $group => $fields) {
|
91 |
$fields = isset($fields['fields']) ? $fields['fields'] : $fields;
|
@@ -96,21 +109,22 @@ abstract class Bronto_Common_Model_System_Config_Backend_Cron extends Mage_Core_
|
|
96 |
}
|
97 |
}
|
98 |
|
99 |
-
return
|
100 |
}
|
101 |
|
102 |
/**
|
103 |
-
* @param type
|
104 |
-
* @param type
|
|
|
105 |
* @return Bronto_Common_Model_System_Config_Backend_Cron
|
106 |
*/
|
107 |
protected function _saveConfigData($path, $value)
|
108 |
{
|
109 |
Mage::getModel('core/config_data')
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
|
115 |
return $this;
|
116 |
}
|
5 |
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
* @version 1.6.7
|
7 |
*/
|
8 |
+
abstract class Bronto_Common_Model_System_Config_Backend_Cron
|
9 |
+
extends Mage_Core_Model_Config_Data
|
10 |
{
|
11 |
/**
|
12 |
* @var string
|
39 |
$frequency = $this->getFieldsetDataValue('frequency');
|
40 |
|
41 |
if ($frequency == $minutely) {
|
42 |
+
$interval = (int) $this->getFieldsetDataValue('interval');
|
43 |
$cronExprString = "*/{$interval} * * * *";
|
44 |
+
}
|
45 |
+
elseif ($frequency == $hourly) {
|
46 |
$minutes = (int) $this->getFieldsetDataValue('minutes');
|
47 |
if ($minutes >= 0 && $minutes <= 59) {
|
48 |
$cronExprString = "{$minutes} * * * *";
|
49 |
+
}
|
50 |
+
else {
|
51 |
Mage::throwException(Mage::helper('bronto_common')->__('Please, specify correct minutes of hour.'));
|
52 |
}
|
53 |
+
}
|
54 |
+
elseif ($frequency == $daily) {
|
55 |
+
$time = $this->getFieldsetDataValue('time');
|
56 |
+
$timeMinutes = $time[1];
|
57 |
+
$timeHours = $time[0];
|
58 |
+
// Fix Midnight Issue
|
59 |
+
if ('00' == $timeMinutes && '00' == $timeHours) {
|
60 |
+
$timeMinutes = '59';
|
61 |
+
$timeHours = '23';
|
62 |
+
}
|
63 |
$cronExprString = "{$timeMinutes} {$timeHours} * * *";
|
64 |
}
|
65 |
}
|
69 |
$this->_saveConfigData($this->_cron_string_path, $cronExprString);
|
70 |
}
|
71 |
if (!empty($this->_cron_model_path)) {
|
72 |
+
$this->_saveConfigData(
|
73 |
+
$this->_cron_model_path,
|
74 |
+
(string) Mage::getConfig()->getNode($this->_cron_model_path)
|
75 |
+
);
|
76 |
}
|
77 |
+
}
|
78 |
+
catch (Exception $e) {
|
79 |
Mage::throwException(Mage::helper('adminhtml')->__('Unable to save Cron expression'));
|
80 |
}
|
81 |
}
|
98 |
}
|
99 |
|
100 |
$data = $this->getData();
|
101 |
+
$groups = isset($data['groups']) ? $data['groups'] : array();
|
102 |
$groupId = isset($data['group_id']) ? $data['group_id'] : array();
|
103 |
foreach ($groups as $group => $fields) {
|
104 |
$fields = isset($fields['fields']) ? $fields['fields'] : $fields;
|
109 |
}
|
110 |
}
|
111 |
|
112 |
+
return NULL;
|
113 |
}
|
114 |
|
115 |
/**
|
116 |
+
* @param type $path
|
117 |
+
* @param type $value
|
118 |
+
*
|
119 |
* @return Bronto_Common_Model_System_Config_Backend_Cron
|
120 |
*/
|
121 |
protected function _saveConfigData($path, $value)
|
122 |
{
|
123 |
Mage::getModel('core/config_data')
|
124 |
+
->load($path, 'path')
|
125 |
+
->setValue($value)
|
126 |
+
->setPath($path)
|
127 |
+
->save();
|
128 |
|
129 |
return $this;
|
130 |
}
|
app/code/community/Bronto/Common/Model/System/Config/Backend/Enable.php
ADDED
@@ -0,0 +1,32 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @package Bronto\Common
|
5 |
+
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
+
* @version 1.6.7
|
7 |
+
*/
|
8 |
+
class Bronto_Common_Model_System_Config_Backend_Enable
|
9 |
+
extends Mage_Core_Model_Config_Data
|
10 |
+
{
|
11 |
+
|
12 |
+
protected $_eventPrefix = 'bronto_enable';
|
13 |
+
|
14 |
+
/**
|
15 |
+
* @return Bronto_Common_Model_System_Config_Backend_Enable
|
16 |
+
*/
|
17 |
+
protected function _beforeSave()
|
18 |
+
{
|
19 |
+
if ($this->isValueChanged()) {
|
20 |
+
// Build Event from section and method
|
21 |
+
$pathParts = explode('/', $this->getPath());
|
22 |
+
$section = array_shift($pathParts);
|
23 |
+
$method = ($this->getValue() == "0") ? 'disable' : 'enable';
|
24 |
+
$event = $section . '_' . $method;
|
25 |
+
|
26 |
+
// Trigger section/method specific event
|
27 |
+
Mage::dispatchEvent($event, $this->getData());
|
28 |
+
}
|
29 |
+
|
30 |
+
return parent::_beforeSave();
|
31 |
+
}
|
32 |
+
}
|
app/code/community/Bronto/Common/Model/System/Config/Backend/Token.php
CHANGED
@@ -7,6 +7,9 @@
|
|
7 |
*/
|
8 |
class Bronto_Common_Model_System_Config_Backend_Token extends Mage_Core_Model_Config_Data
|
9 |
{
|
|
|
|
|
|
|
10 |
/**
|
11 |
* @return Bronto_Common_Model_System_Config_Backend_Token
|
12 |
*/
|
@@ -21,9 +24,14 @@ class Bronto_Common_Model_System_Config_Backend_Token extends Mage_Core_Model_Co
|
|
21 |
// API key is new and doesn't match existing API key
|
22 |
$currentApiKey = Mage::helper('bronto_common')->getApiToken();
|
23 |
if ($currentApiKey !== $value) {
|
|
|
|
|
|
|
|
|
|
|
24 |
// reset the verified status
|
25 |
-
Mage::helper('
|
26 |
-
Mage::helper('
|
27 |
'2',
|
28 |
$this->getScope(),
|
29 |
$this->getScopeId()
|
@@ -31,17 +39,18 @@ class Bronto_Common_Model_System_Config_Backend_Token extends Mage_Core_Model_Co
|
|
31 |
|
32 |
$sentry = Mage::getModel('bronto_common/keysentry');
|
33 |
$sentry->disableModules($this->getScope(), $this->getScopeId());
|
34 |
-
|
35 |
-
if (
|
36 |
$sentry->unlinkEmails(
|
37 |
-
Mage::
|
|
|
38 |
$this->getScopeId()
|
39 |
);
|
40 |
}
|
41 |
}
|
42 |
} else {
|
43 |
-
Mage::helper('
|
44 |
-
Mage::helper('
|
45 |
'2'
|
46 |
);
|
47 |
}
|
7 |
*/
|
8 |
class Bronto_Common_Model_System_Config_Backend_Token extends Mage_Core_Model_Config_Data
|
9 |
{
|
10 |
+
|
11 |
+
protected $_eventPrefix = 'bronto_token_model';
|
12 |
+
|
13 |
/**
|
14 |
* @return Bronto_Common_Model_System_Config_Backend_Token
|
15 |
*/
|
24 |
// API key is new and doesn't match existing API key
|
25 |
$currentApiKey = Mage::helper('bronto_common')->getApiToken();
|
26 |
if ($currentApiKey !== $value) {
|
27 |
+
Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('bronto_common')->__(
|
28 |
+
'You have changed your Bronto API Token so all Bronto modules have been disabled for this configuration scope.' .
|
29 |
+
'<br />Please proceed to each module and reconfigure all available options to avoid undesired behavior.'
|
30 |
+
));
|
31 |
+
|
32 |
// reset the verified status
|
33 |
+
Mage::helper('bronto_verify/roundtrip')->setStatus(
|
34 |
+
Mage::helper('bronto_verify/roundtrip')->getPath('status'),
|
35 |
'2',
|
36 |
$this->getScope(),
|
37 |
$this->getScopeId()
|
39 |
|
40 |
$sentry = Mage::getModel('bronto_common/keysentry');
|
41 |
$sentry->disableModules($this->getScope(), $this->getScopeId());
|
42 |
+
|
43 |
+
if (!Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, 9)) {
|
44 |
$sentry->unlinkEmails(
|
45 |
+
Mage::getModel('bronto_email/message')->getCollection(),
|
46 |
+
$this->getScope(),
|
47 |
$this->getScopeId()
|
48 |
);
|
49 |
}
|
50 |
}
|
51 |
} else {
|
52 |
+
Mage::helper('bronto_verify/roundtrip')->setStatus(
|
53 |
+
Mage::helper('bronto_verify/roundtrip')->getPath('status'),
|
54 |
'2'
|
55 |
);
|
56 |
}
|
app/code/community/Bronto/Common/Model/System/Config/Source/Contact/Status.php
CHANGED
@@ -9,16 +9,16 @@ class Bronto_Common_Model_System_Config_Source_Contact_Status
|
|
9 |
|
10 |
/**
|
11 |
* Description for protected
|
12 |
-
* @var array
|
13 |
* @access protected
|
14 |
*/
|
15 |
protected $_options = array();
|
16 |
|
17 |
/**
|
18 |
* Short description for function
|
19 |
-
*
|
20 |
* Long description (if any) ...
|
21 |
-
*
|
22 |
* @return array Return description (if any) ...
|
23 |
* @access public
|
24 |
*/
|
9 |
|
10 |
/**
|
11 |
* Description for protected
|
12 |
+
* @var array
|
13 |
* @access protected
|
14 |
*/
|
15 |
protected $_options = array();
|
16 |
|
17 |
/**
|
18 |
* Short description for function
|
19 |
+
*
|
20 |
* Long description (if any) ...
|
21 |
+
*
|
22 |
* @return array Return description (if any) ...
|
23 |
* @access public
|
24 |
*/
|
app/code/community/Bronto/Common/Model/System/Config/Source/Cron/Frequency.php
CHANGED
@@ -15,18 +15,18 @@ class Bronto_Common_Model_System_Config_Source_Cron_Frequency
|
|
15 |
/**
|
16 |
* Description for const
|
17 |
*/
|
18 |
-
const CRON_HOURLY
|
19 |
|
20 |
/**
|
21 |
* Description for const
|
22 |
*/
|
23 |
-
const CRON_DAILY
|
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 |
*/
|
@@ -34,8 +34,8 @@ class Bronto_Common_Model_System_Config_Source_Cron_Frequency
|
|
34 |
{
|
35 |
return array(
|
36 |
self::CRON_MINUTELY => Mage::helper('cron')->__('Minute Intervals'),
|
37 |
-
self::CRON_HOURLY
|
38 |
-
self::CRON_DAILY
|
39 |
);
|
40 |
}
|
41 |
}
|
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 |
*/
|
34 |
{
|
35 |
return array(
|
36 |
self::CRON_MINUTELY => Mage::helper('cron')->__('Minute Intervals'),
|
37 |
+
self::CRON_HOURLY => Mage::helper('cron')->__('Hourly'),
|
38 |
+
self::CRON_DAILY => Mage::helper('cron')->__('Daily'),
|
39 |
);
|
40 |
}
|
41 |
}
|
app/code/community/Bronto/Common/Model/System/Config/Source/Cron/Minutes.php
CHANGED
@@ -9,16 +9,16 @@ class Bronto_Common_Model_System_Config_Source_Cron_Minutes
|
|
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
|
22 |
10 => Mage::helper('cron')->__('10 minutes'),
|
23 |
15 => Mage::helper('cron')->__('15 minutes'),
|
24 |
20 => Mage::helper('cron')->__('20 minutes'),
|
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'),
|
app/code/community/Bronto/Common/Model/System/Config/Source/Field.php
CHANGED
@@ -24,11 +24,11 @@ class Bronto_Common_Model_System_Config_Source_Field
|
|
24 |
if ($api = Mage::helper('bronto_common')->getApi()) {
|
25 |
/* @var $fieldObject Bronto_Api_Field */
|
26 |
$fieldObject = $api->getFieldObject();
|
27 |
-
foreach ($fieldObject->readAll()->iterate() as $field
|
28 |
$this->_options[] = array(
|
29 |
'value' => $field->id,
|
30 |
'label' => $field->label,
|
31 |
-
);
|
32 |
}
|
33 |
}
|
34 |
} catch (Exception $e) {
|
@@ -47,7 +47,7 @@ class Bronto_Common_Model_System_Config_Source_Field
|
|
47 |
|
48 |
return $this->_options;
|
49 |
}
|
50 |
-
|
51 |
/**
|
52 |
* Get Field Object by ID
|
53 |
* @param string $id
|
@@ -59,16 +59,16 @@ class Bronto_Common_Model_System_Config_Source_Field
|
|
59 |
if ($api = Mage::helper('bronto_common')->getApi()) {
|
60 |
/* @var $fieldObject Bronto_Api_Field */
|
61 |
$fieldObject = $api->getFieldObject();
|
62 |
-
foreach ($fieldObject->readAll()->iterate() as $field
|
63 |
if ($field->id == $id) {
|
64 |
return $field;
|
65 |
-
}
|
66 |
}
|
67 |
}
|
68 |
} catch (Exception $e) {
|
69 |
Mage::helper('bronto_common')->writeError($e);
|
70 |
}
|
71 |
-
|
72 |
return false;
|
73 |
}
|
74 |
}
|
24 |
if ($api = Mage::helper('bronto_common')->getApi()) {
|
25 |
/* @var $fieldObject Bronto_Api_Field */
|
26 |
$fieldObject = $api->getFieldObject();
|
27 |
+
foreach ($fieldObject->readAll()->iterate() as $field/* @var $field Bronto_Api_Field_Row */) {
|
28 |
$this->_options[] = array(
|
29 |
'value' => $field->id,
|
30 |
'label' => $field->label,
|
31 |
+
);
|
32 |
}
|
33 |
}
|
34 |
} catch (Exception $e) {
|
47 |
|
48 |
return $this->_options;
|
49 |
}
|
50 |
+
|
51 |
/**
|
52 |
* Get Field Object by ID
|
53 |
* @param string $id
|
59 |
if ($api = Mage::helper('bronto_common')->getApi()) {
|
60 |
/* @var $fieldObject Bronto_Api_Field */
|
61 |
$fieldObject = $api->getFieldObject();
|
62 |
+
foreach ($fieldObject->readAll()->iterate() as $field/* @var $field Bronto_Api_Field_Row */) {
|
63 |
if ($field->id == $id) {
|
64 |
return $field;
|
65 |
+
}
|
66 |
}
|
67 |
}
|
68 |
} catch (Exception $e) {
|
69 |
Mage::helper('bronto_common')->writeError($e);
|
70 |
}
|
71 |
+
|
72 |
return false;
|
73 |
}
|
74 |
}
|
app/code/community/Bronto/Common/Model/System/Config/Source/Image.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/{Order → Common}/Model/System/Config/Source/Limit.php
RENAMED
@@ -1,11 +1,11 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* @package Bronto\
|
5 |
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
* @version 1.1.5
|
7 |
*/
|
8 |
-
class
|
9 |
{
|
10 |
/**
|
11 |
* @return array
|
@@ -13,10 +13,10 @@ class Bronto_Order_Model_System_Config_Source_Limit
|
|
13 |
public function toOptionArray()
|
14 |
{
|
15 |
return array(
|
16 |
-
50
|
17 |
-
100
|
18 |
-
250
|
19 |
-
500
|
20 |
1000 => 1000,
|
21 |
);
|
22 |
}
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* @package Bronto\Common
|
5 |
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
* @version 1.1.5
|
7 |
*/
|
8 |
+
class Bronto_Common_Model_System_Config_Source_Limit
|
9 |
{
|
10 |
/**
|
11 |
* @return array
|
13 |
public function toOptionArray()
|
14 |
{
|
15 |
return array(
|
16 |
+
50 => 50,
|
17 |
+
100 => 100,
|
18 |
+
250 => 250,
|
19 |
+
500 => 500,
|
20 |
1000 => 1000,
|
21 |
);
|
22 |
}
|
app/code/community/Bronto/Common/Model/System/Config/Source/List.php
CHANGED
@@ -24,7 +24,7 @@ class Bronto_Common_Model_System_Config_Source_List
|
|
24 |
if ($api = Mage::helper('bronto_common')->getApi()) {
|
25 |
/* @var $listObject Bronto_Api_List */
|
26 |
$listObject = $api->getListObject();
|
27 |
-
foreach ($listObject->readAll()->iterate() as $list
|
28 |
$this->_options[] = array(
|
29 |
'value' => $list->id,
|
30 |
'label' => $list->label,
|
@@ -32,7 +32,7 @@ class Bronto_Common_Model_System_Config_Source_List
|
|
32 |
}
|
33 |
}
|
34 |
} catch (Exception $e) {
|
35 |
-
Mage::helper('bronto_common')->writeError($e);
|
36 |
}
|
37 |
|
38 |
return $this->_options;
|
24 |
if ($api = Mage::helper('bronto_common')->getApi()) {
|
25 |
/* @var $listObject Bronto_Api_List */
|
26 |
$listObject = $api->getListObject();
|
27 |
+
foreach ($listObject->readAll()->iterate() as $list/* @var $list Bronto_Api_List_Row */) {
|
28 |
$this->_options[] = array(
|
29 |
'value' => $list->id,
|
30 |
'label' => $list->label,
|
32 |
}
|
33 |
}
|
34 |
} catch (Exception $e) {
|
35 |
+
Mage::helper('bronto_common')->writeError('Unable to get Mailing List options: ' . $e->getMessage());
|
36 |
}
|
37 |
|
38 |
return $this->_options;
|
app/code/community/Bronto/Common/Model/System/Config/Source/Message.php
CHANGED
@@ -24,7 +24,7 @@ class Bronto_Common_Model_System_Config_Source_Message
|
|
24 |
if ($api = Mage::helper('bronto_common')->getApi($token)) {
|
25 |
/* @var $messageObject Bronto_Api_Message */
|
26 |
$messageObject = $api->getMessageObject();
|
27 |
-
foreach ($messageObject->readAll()->iterate() as $message
|
28 |
$_option = array(
|
29 |
'label' => $message->name,
|
30 |
'value' => $message->id,
|
24 |
if ($api = Mage::helper('bronto_common')->getApi($token)) {
|
25 |
/* @var $messageObject Bronto_Api_Message */
|
26 |
$messageObject = $api->getMessageObject();
|
27 |
+
foreach ($messageObject->readAll()->iterate() as $message/* @var $message Bronto_Api_Message_Row */) {
|
28 |
$_option = array(
|
29 |
'label' => $message->name,
|
30 |
'value' => $message->id,
|
app/code/community/Bronto/Common/Model/System/Config/Source/Role.php
ADDED
@@ -0,0 +1,31 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/Synclimit.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @package Bronto\Common
|
5 |
+
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
+
* @version 1.1.5
|
7 |
+
*/
|
8 |
+
class Bronto_Common_Model_System_Config_Source_Synclimit
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* @return array
|
12 |
+
*/
|
13 |
+
public function toOptionArray()
|
14 |
+
{
|
15 |
+
return array(
|
16 |
+
250 => 250,
|
17 |
+
500 => 500,
|
18 |
+
1000 => 1000,
|
19 |
+
5000 => 5000,
|
20 |
+
10000 => 10000,
|
21 |
+
);
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Bronto/Common/Test/Config/Config.php
DELETED
@@ -1,171 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Bronto_Common_Test_Config_Config
|
3 |
-
extends EcomDev_PHPUnit_Test_Case_Config
|
4 |
-
{
|
5 |
-
public function blocksProvider()
|
6 |
-
{
|
7 |
-
return array(
|
8 |
-
array('bronto_common/adminhtml_system_config_about', 'Bronto_Common_Block_Adminhtml_System_Config_About'),
|
9 |
-
array('bronto_common/adminhtml_system_config_cron', 'Bronto_Common_Block_Adminhtml_System_Config_Cron'),
|
10 |
-
array('bronto_common/adminhtml_system_config_form_field', 'Bronto_Common_Block_Adminhtml_System_Config_Form_Field'),
|
11 |
-
array('bronto_common/adminhtml_system_config_form_field_apitoken', 'Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Apitoken'),
|
12 |
-
array('bronto_common/adminhtml_system_config_form_field_hidden', 'Bronto_Common_Block_Adminhtml_System_Config_Form_Field_Hidden'),
|
13 |
-
array('bronto_common/adminhtml_system_config_form_field_list', 'Bronto_Common_Block_Adminhtml_System_Config_Form_Field_List'),
|
14 |
-
);
|
15 |
-
}
|
16 |
-
|
17 |
-
public function modelsProvider()
|
18 |
-
{
|
19 |
-
return array(
|
20 |
-
array('bronto_common/api', 'Bronto_Common_Model_Api'),
|
21 |
-
array('bronto_common/email_message', 'Bronto_Common_Model_Email_Message'),
|
22 |
-
array('bronto_common/email_message_filter', 'Bronto_Common_Model_Email_Message_Filter'),
|
23 |
-
array('bronto_common/system_config_backend_cron', 'Bronto_Common_Model_System_Config_Backend_Cron'),
|
24 |
-
array('bronto_common/system_config_backend_token', 'Bronto_Common_Model_System_Config_Backend_Token'),
|
25 |
-
array('bronto_common/system_config_source_fields', 'Bronto_Common_Model_System_Config_Source_Fields'),
|
26 |
-
array('bronto_common/system_config_source_list', 'Bronto_Common_Model_System_Config_Source_List'),
|
27 |
-
array('bronto_common/system_config_source_contact_status', 'Bronto_Common_Model_System_Config_Source_Contact_Status'),
|
28 |
-
array('bronto_common/system_config_source_cron_frequency', 'Bronto_Common_Model_System_Config_Source_Cron_Frequency'),
|
29 |
-
array('bronto_common/system_config_source_cron_minutes', 'Bronto_Common_Model_System_Config_Source_Cron_Minutes',),
|
30 |
-
);
|
31 |
-
}
|
32 |
-
|
33 |
-
public function resourceModelProvider()
|
34 |
-
{
|
35 |
-
return array(
|
36 |
-
array('bronto_common/resource_setup', 'Bronto_Common_Model_Resource_Setup'),
|
37 |
-
);
|
38 |
-
}
|
39 |
-
|
40 |
-
public function observersProvider()
|
41 |
-
{
|
42 |
-
return array(
|
43 |
-
array('adminhtml', 'controller_action_predispatch', 'bronto_common/observer', 'checkBrontoRequirements')
|
44 |
-
);
|
45 |
-
}
|
46 |
-
|
47 |
-
public function helpersProvider()
|
48 |
-
{
|
49 |
-
return array(
|
50 |
-
array('bronto_common/data', 'Bronto_Common_Helper_Data'),
|
51 |
-
array('bronto_common/message', 'Bronto_Common_Helper_Message'),
|
52 |
-
array('bronto_common/contact', 'Bronto_Common_Helper_Contact'),
|
53 |
-
array('bronto_common/field', 'Bronto_Common_Helper_Field'),
|
54 |
-
array('bronto_common/product', 'Bronto_Common_Helper_Product'),
|
55 |
-
);
|
56 |
-
}
|
57 |
-
|
58 |
-
public function dependsProvider()
|
59 |
-
{
|
60 |
-
return array(
|
61 |
-
array('Mage_Adminhtml'),
|
62 |
-
array('Mage_Customer'),
|
63 |
-
array('Mage_Checkout'),
|
64 |
-
array('Mage_Sales'),
|
65 |
-
);
|
66 |
-
}
|
67 |
-
|
68 |
-
/**
|
69 |
-
* @test
|
70 |
-
* @group amd
|
71 |
-
* @group config
|
72 |
-
*/
|
73 |
-
public function assertCommonModuleVersionGreaterThanOrEquals()
|
74 |
-
{
|
75 |
-
$this->assertModuleVersionGreaterThanOrEquals('1.7.0');
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* @test
|
80 |
-
* @group amd
|
81 |
-
* @group config
|
82 |
-
*/
|
83 |
-
public function assertCommonModuleInCommunityCodePool()
|
84 |
-
{
|
85 |
-
$this->assertModuleCodePool('community');
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* @test
|
90 |
-
* @group amd
|
91 |
-
* @group config
|
92 |
-
* @dataProvider dependsProvider
|
93 |
-
*/
|
94 |
-
public function assertCommonModuleDepends(
|
95 |
-
$requiredModuleName
|
96 |
-
) {
|
97 |
-
$this->assertModuleDepends($requiredModuleName);
|
98 |
-
}
|
99 |
-
|
100 |
-
/**
|
101 |
-
* @test
|
102 |
-
* @group amd
|
103 |
-
* @group config
|
104 |
-
* @dataProvider modelsProvider
|
105 |
-
*/
|
106 |
-
public function assertCommonModelAliases(
|
107 |
-
$classAlias,
|
108 |
-
$expectedClassName
|
109 |
-
) {
|
110 |
-
$this->assertModelAlias($classAlias, $expectedClassName);
|
111 |
-
}
|
112 |
-
|
113 |
-
/**
|
114 |
-
* @test
|
115 |
-
* @group amd
|
116 |
-
* @group config
|
117 |
-
* @dataProvider resourceModelProvider
|
118 |
-
*/
|
119 |
-
public function assertCommonResourceModelAliases(
|
120 |
-
$classAlias,
|
121 |
-
$expectedClassName
|
122 |
-
) {
|
123 |
-
$this->assertResourceModelAlias($classAlias, $expectedClassName);
|
124 |
-
}
|
125 |
-
|
126 |
-
/**
|
127 |
-
* @test
|
128 |
-
* @group amd
|
129 |
-
* @group config
|
130 |
-
* @dataProvider observersProvider
|
131 |
-
*/
|
132 |
-
public function assertCommonEventObserversDefined(
|
133 |
-
$area,
|
134 |
-
$eventName,
|
135 |
-
$observerClassAlias,
|
136 |
-
$observerMethod
|
137 |
-
) {
|
138 |
-
$this->assertEventObserverDefined(
|
139 |
-
$area,
|
140 |
-
$eventName,
|
141 |
-
$observerClassAlias,
|
142 |
-
$observerMethod
|
143 |
-
);
|
144 |
-
}
|
145 |
-
|
146 |
-
/**
|
147 |
-
* @test
|
148 |
-
* @group amd
|
149 |
-
* @group config
|
150 |
-
* @dataProvider blocksProvider
|
151 |
-
*/
|
152 |
-
public function assertCommonBlockAliases(
|
153 |
-
$classAlias,
|
154 |
-
$expectedClassName
|
155 |
-
) {
|
156 |
-
$this->assertBlockAlias($classAlias, $expectedClassName);
|
157 |
-
}
|
158 |
-
|
159 |
-
/**
|
160 |
-
* @test
|
161 |
-
* @group amd
|
162 |
-
* @group config
|
163 |
-
* @dataProvider helpersProvider
|
164 |
-
*/
|
165 |
-
public function assertCommonHelperAliases(
|
166 |
-
$classAlias,
|
167 |
-
$expectedClassName
|
168 |
-
) {
|
169 |
-
$this->assertHelperAlias($classAlias, $expectedClassName);
|
170 |
-
}
|
171 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/Common/Test/Model/Checkout.php
DELETED
@@ -1,187 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
abstract class Bronto_Common_Test_Model_Checkout extends EcomDev_PHPUnit_Test_Case
|
4 |
-
{
|
5 |
-
/**
|
6 |
-
* @return Mage_Sales_Model_Order
|
7 |
-
*/
|
8 |
-
public function createRandomGuestOrder()
|
9 |
-
{
|
10 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
11 |
-
$quote = $this->_queryOrder();
|
12 |
-
|
13 |
-
/* @var $service Mage_Sales_Model_Service_Quote */
|
14 |
-
$service = Mage::getModel('sales/service_quote', $quote);
|
15 |
-
$service->submitAll();
|
16 |
-
|
17 |
-
$order = $service->getOrder();
|
18 |
-
$order->sendNewOrderEmail();
|
19 |
-
return $order;
|
20 |
-
}
|
21 |
-
|
22 |
-
/**
|
23 |
-
* @param Mage_Sales_Model_Order $order
|
24 |
-
* @return boolean
|
25 |
-
*/
|
26 |
-
public function createInvoiceForOrder(Mage_Sales_Model_Order $order)
|
27 |
-
{
|
28 |
-
if ($order->canInvoice()) {
|
29 |
-
$invoiceId = Mage::getModel('sales/order_invoice_api')
|
30 |
-
->create($order->getIncrementId(), array());
|
31 |
-
|
32 |
-
return Mage::getModel('sales/order_invoice')
|
33 |
-
->loadByIncrementId($invoiceId)
|
34 |
-
->capture()
|
35 |
-
->save();
|
36 |
-
}
|
37 |
-
|
38 |
-
return false;
|
39 |
-
}
|
40 |
-
|
41 |
-
/**
|
42 |
-
* @param Mage_Sales_Model_Order $order
|
43 |
-
* @return boolean
|
44 |
-
*/
|
45 |
-
public function createShipmentForOrder(Mage_Sales_Model_Order $order)
|
46 |
-
{
|
47 |
-
if ($order->canShip()) {
|
48 |
-
$shipmentId = Mage::getModel('sales/order_shipment_api')
|
49 |
-
->create($order->getIncrementId(), array(), 'Test Shipment Created', true);
|
50 |
-
|
51 |
-
return Mage::getModel('sales/order_shipment_api')
|
52 |
-
->addTrack($shipmentId, 'ups', 'UPS Test Shipment', rand(1000000000, 9999999999));
|
53 |
-
}
|
54 |
-
|
55 |
-
return false;
|
56 |
-
}
|
57 |
-
|
58 |
-
/**
|
59 |
-
* @param array $orderData
|
60 |
-
* @return Mage_Sales_Model_Quote
|
61 |
-
*/
|
62 |
-
protected function _queryOrder()
|
63 |
-
{
|
64 |
-
/* @var $quote Mage_Sales_Model_Quote */
|
65 |
-
$quote = Mage::getModel('sales/quote');
|
66 |
-
|
67 |
-
foreach (array(166, 156, 149) as $productId) {
|
68 |
-
/* @var $product Mage_Catalog_Model_Product */
|
69 |
-
$product = Mage::getModel('catalog/product')->load($productId);
|
70 |
-
$quote->addProduct($product, 1);
|
71 |
-
}
|
72 |
-
|
73 |
-
$this->_addBillingAddress($quote);
|
74 |
-
$this->_addShippingAddress($quote);
|
75 |
-
$this->_addShippingMethod($quote);
|
76 |
-
$this->_addPayment($quote);
|
77 |
-
|
78 |
-
$quote = $this->_prepareGuestQuote($quote);
|
79 |
-
$quote->collectTotals()->save();
|
80 |
-
return $quote;
|
81 |
-
}
|
82 |
-
|
83 |
-
/**
|
84 |
-
* @param string $regionCode
|
85 |
-
* @param string $countryCode
|
86 |
-
* @return null
|
87 |
-
*/
|
88 |
-
protected function _getIdByRegionCode($regionCode, $countryCode)
|
89 |
-
{
|
90 |
-
$region = Mage::getModel('directory/region')->loadByCode($regionCode, $countryCode);
|
91 |
-
if (!!$region && !!$region->getId()) {
|
92 |
-
return $region->getId();
|
93 |
-
}
|
94 |
-
return null;
|
95 |
-
}
|
96 |
-
|
97 |
-
/**
|
98 |
-
* @param Mage_Sales_Model_Quote $quote
|
99 |
-
*/
|
100 |
-
protected function _addBillingAddress(Mage_Sales_Model_Quote $quote)
|
101 |
-
{
|
102 |
-
$billingAddress = $quote->getBillingAddress();
|
103 |
-
$billingAddress
|
104 |
-
->setData('firstname', 'John')
|
105 |
-
->setData('lastname', 'Doe ' . rand(0, 99))
|
106 |
-
->setData('street', '123 Main St')
|
107 |
-
->setData('city', 'Monroe')
|
108 |
-
->setData('postcode', '28110')
|
109 |
-
->setData('region_id', $this->_getIdByRegionCode('NC', 'US'))
|
110 |
-
->setData('region', 'NC')
|
111 |
-
->setData('country_id', 'US')
|
112 |
-
->setData('telephone', '7045555555');
|
113 |
-
}
|
114 |
-
|
115 |
-
/**
|
116 |
-
* @param Mage_Sales_Model_Quote $quote
|
117 |
-
*/
|
118 |
-
protected function _addShippingAddress(Mage_Sales_Model_Quote $quote)
|
119 |
-
{
|
120 |
-
$shippingAddress = $quote->getShippingAddress();
|
121 |
-
$shippingAddress
|
122 |
-
->setData('firstname', 'John')
|
123 |
-
->setData('lastname', 'Doe ' . rand(0, 99))
|
124 |
-
->setData('street', '123 Main St')
|
125 |
-
->setData('city', 'Monroe')
|
126 |
-
->setData('postcode', '28110')
|
127 |
-
->setData('region_id', $this->_getIdByRegionCode('NC', 'US'))
|
128 |
-
->setData('region', 'NC')
|
129 |
-
->setData('country_id', 'US')
|
130 |
-
->setData('telephone', '7045555555');
|
131 |
-
}
|
132 |
-
|
133 |
-
/**
|
134 |
-
* @param Mage_Sales_Model_Quote $quote
|
135 |
-
*/
|
136 |
-
protected function _addShippingMethod(Mage_Sales_Model_Quote $quote)
|
137 |
-
{
|
138 |
-
$shippingAddress = $quote->getShippingAddress();
|
139 |
-
$shippingAddress->setShippingMethod('flatrate_flatrate');
|
140 |
-
}
|
141 |
-
|
142 |
-
/**
|
143 |
-
* @param Mage_Sales_Model_Quote $quote
|
144 |
-
*/
|
145 |
-
protected function _addPayment(Mage_Sales_Model_Quote $quote)
|
146 |
-
{
|
147 |
-
if ($quote->isVirtual()) {
|
148 |
-
$quote->getBillingAddress()->setPaymentMethod('checkmo');
|
149 |
-
} else {
|
150 |
-
$quote->getShippingAddress()->setPaymentMethod('checkmo');
|
151 |
-
}
|
152 |
-
|
153 |
-
if (!$quote->isVirtual() && $quote->getShippingAddress()) {
|
154 |
-
$quote->getShippingAddress()->setCollectShippingRates(true);
|
155 |
-
}
|
156 |
-
|
157 |
-
/* @var $payment Mage_Sales_Model_Quote_Payment */
|
158 |
-
$payment = $quote->getPayment();
|
159 |
-
$payment->importData(array('method' => 'checkmo'));
|
160 |
-
$quote->setPayment($payment);
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* @param Mage_Sales_Model_Quote $quote
|
165 |
-
* @return Mage_Sales_Model_Quote
|
166 |
-
*/
|
167 |
-
protected function _prepareGuestQuote(Mage_Sales_Model_Quote $quote)
|
168 |
-
{
|
169 |
-
$quote->setCustomerId(null);
|
170 |
-
$quote->setCustomerEmail('j.doe+' . date('YmdHis') . '@bronto.com');
|
171 |
-
$quote->setCustomerIsGuest(true);
|
172 |
-
$quote->setCustomerGroupId(Mage_Customer_Model_Group::NOT_LOGGED_IN_ID);
|
173 |
-
return $quote;
|
174 |
-
}
|
175 |
-
|
176 |
-
/**
|
177 |
-
* @param Mage_Sales_Model_Quote $quote
|
178 |
-
* @param type $customerId
|
179 |
-
* @return Mage_Sales_Model_Quote
|
180 |
-
*/
|
181 |
-
protected function _prepareCustomerQuote(Mage_Sales_Model_Quote $quote, $customerId)
|
182 |
-
{
|
183 |
-
$customer = Mage::getModel('customer/customer')->load($customerId);
|
184 |
-
$quote->setCustomer($customer);
|
185 |
-
return $quote;
|
186 |
-
}
|
187 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/Common/Test/Model/Keysentry.php
DELETED
@@ -1,70 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Bronto_Common_Test_Model_Keysentry extends EcomDev_PHPUnit_Test_Case
|
4 |
-
{
|
5 |
-
public function configDataProvider()
|
6 |
-
{
|
7 |
-
$data = array(
|
8 |
-
'field' => 'api_token',
|
9 |
-
'group_id' => 'settings',
|
10 |
-
'store_code' => '',
|
11 |
-
'website_code' => '',
|
12 |
-
'scope' => 'default',
|
13 |
-
'scope_id' => 0,
|
14 |
-
'fieldset_data' => array(
|
15 |
-
'api_token' => '',
|
16 |
-
'debug' => '',
|
17 |
-
'verbose' => '',
|
18 |
-
'test' => '',
|
19 |
-
'notices' => '',
|
20 |
-
),
|
21 |
-
'path' => 'bronto/settings/api_token',
|
22 |
-
'value' => '53873730-F77B-4B0D-9840-43F21846F991',
|
23 |
-
);
|
24 |
-
$defaultConfig = Mage::getModel('bronto_common/system_config_backend_token');
|
25 |
-
$defaultConfig->setData($data);
|
26 |
-
|
27 |
-
$data['website_code'] = 'base';
|
28 |
-
$data['scope'] = 'websites';
|
29 |
-
$data['scope_id'] = 1;
|
30 |
-
$websiteConfig = Mage::getModel('bronto_common/system_config_backend_token');
|
31 |
-
$websiteConfig->setData($data);
|
32 |
-
|
33 |
-
$data['store_code'] = 'default';
|
34 |
-
$data['scope'] = 'stores';
|
35 |
-
$data['scope_id'] = 1;
|
36 |
-
$englishConfig = Mage::getModel('bronto_common/system_config_backend_token');
|
37 |
-
$englishConfig->setData($data);
|
38 |
-
|
39 |
-
$data['store_code'] = 'french';
|
40 |
-
$data['scope'] = 'stores';
|
41 |
-
$data['scope_id'] = 3;
|
42 |
-
$frenchConfig = Mage::getModel('bronto_common/system_config_backend_token');
|
43 |
-
$frenchConfig->setData($data);
|
44 |
-
|
45 |
-
$data['store_code'] = 'german';
|
46 |
-
$data['scope'] = 'stores';
|
47 |
-
$data['scope_id'] = 2;
|
48 |
-
$germanConfig = Mage::getModel('bronto_common/system_config_backend_token');
|
49 |
-
$germanConfig->setData($data);
|
50 |
-
|
51 |
-
return array(
|
52 |
-
array($defaultConfig),
|
53 |
-
array($websiteConfig),
|
54 |
-
array($englishConfig),
|
55 |
-
array($frenchConfig),
|
56 |
-
array($germanConfig),
|
57 |
-
);
|
58 |
-
}
|
59 |
-
|
60 |
-
/**
|
61 |
-
* @test
|
62 |
-
* @group jmk
|
63 |
-
* @group model
|
64 |
-
* @dataProvider configDataProvider
|
65 |
-
*/
|
66 |
-
public function getMatchingScopes($configuration)
|
67 |
-
{
|
68 |
-
$config = Mage::getStoreConfig('bronto/settings/api_token');
|
69 |
-
}
|
70 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/Common/Test/Model/Keysentry/fixtures/seed.yaml
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
scope:
|
2 |
-
website:
|
3 |
-
- website_id:
|
|
|
|
|
|
app/code/community/Bronto/Common/controllers/Adminhtml/DebugController.php
ADDED
@@ -0,0 +1,88 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bronto_Common_Adminhtml_DebugController extends Mage_Adminhtml_Controller_Action {
|
4 |
+
|
5 |
+
protected $_helper;
|
6 |
+
|
7 |
+
/**
|
8 |
+
* @return Mage_Core_Helper_Data
|
9 |
+
*/
|
10 |
+
protected function _getHelper() {
|
11 |
+
if (is_null($this->_helper)) {
|
12 |
+
$this->_helper = Mage::helper('bronto_common/support');
|
13 |
+
}
|
14 |
+
return $this->_helper;
|
15 |
+
}
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Sets this helper
|
19 |
+
*
|
20 |
+
* @param Mage_Core_Helper_Data $helper
|
21 |
+
* @return Bronto_Common_Adminhtml_DebugController
|
22 |
+
*/
|
23 |
+
public function setHelper(Mage_Core_Helper_Data $helper) {
|
24 |
+
$this->_helper = $helper;
|
25 |
+
return $this;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Retrieves the system information in JSON via ajax request
|
30 |
+
*/
|
31 |
+
public function collectAction() {
|
32 |
+
$debug = $this->_getHelper()->getDebugInformation();
|
33 |
+
|
34 |
+
// Magento 1.4, 1.5, and 1.9 chokes on the json encoding array values
|
35 |
+
// PHP json_encode exists on the server, then use it
|
36 |
+
if (function_exists('json_encode')) {
|
37 |
+
$json = json_encode($debug);
|
38 |
+
} else {
|
39 |
+
$json = Mage::helper('core')->jsonEncode($debug);
|
40 |
+
}
|
41 |
+
|
42 |
+
$this
|
43 |
+
->getResponse()
|
44 |
+
->setHeader('Content-Type', 'application/json')
|
45 |
+
->setBody($json);
|
46 |
+
}
|
47 |
+
|
48 |
+
/**
|
49 |
+
* Sends an archive to the browser
|
50 |
+
*/
|
51 |
+
public function archiveAction() {
|
52 |
+
$zip = basename($this->_getHelper()->getLogArchive()->getFilename());
|
53 |
+
$json = Mage::helper('core')->jsonEncode(array(
|
54 |
+
'name' => $zip,
|
55 |
+
'link' => $this->getUrl('*/*/download', array('file' => $zip)),
|
56 |
+
));
|
57 |
+
|
58 |
+
$this
|
59 |
+
->getResponse()
|
60 |
+
->setHeader('Content-Type', 'application/json')
|
61 |
+
->setBody($json);
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* Sends the zip to the browser
|
66 |
+
*/
|
67 |
+
public function downloadAction() {
|
68 |
+
$file = $this->getRequest()->getParam('file');
|
69 |
+
$baseArchiveDir = $this->_getHelper()->getArchiveDirectory();
|
70 |
+
|
71 |
+
if (!file_exists($baseArchiveDir . DS . $file)) {
|
72 |
+
Mage::getSingleton('adminhtml/session')->addError("Archive '$file' does not exist.");
|
73 |
+
return $this->_redirect('*/system_config/edit', array('section' => 'bronto'));
|
74 |
+
} else {
|
75 |
+
$this
|
76 |
+
->getResponse()
|
77 |
+
->setHeader('Content-Description', 'File Transfer')
|
78 |
+
->setHeader('Content-Type', 'application/zip')
|
79 |
+
->setHeader('Content-Disposition', 'attachment; filename="bronto_logs_' . time() . '.zip"')
|
80 |
+
->clearBody();
|
81 |
+
|
82 |
+
$this->getResponse()->sendHeaders();
|
83 |
+
ob_end_flush();
|
84 |
+
readfile($baseArchiveDir . DS . $file);
|
85 |
+
exit;
|
86 |
+
}
|
87 |
+
}
|
88 |
+
}
|
app/code/community/Bronto/Common/controllers/LogController.php
CHANGED
@@ -26,7 +26,7 @@ class Bronto_Common_LogController extends Mage_Core_Controller_Front_Action
|
|
26 |
// Requirements for this controller require that Bronto's
|
27 |
// Debug mode be enabled for any log file to be available
|
28 |
// for download
|
29 |
-
if(!Mage::helper('bronto_common')->isDebugEnabled())
|
30 |
return $this->norouteAction();
|
31 |
|
32 |
// Add dyndns
|
@@ -50,7 +50,7 @@ class Bronto_Common_LogController extends Mage_Core_Controller_Front_Action
|
|
50 |
|
51 |
/* @var $httpHelper Mage_Core_Helper_Http */
|
52 |
$httpHelper = Mage::helper('core/http');
|
53 |
-
$ipAddress
|
54 |
|
55 |
if (!in_array($ipAddress, $this->_allowedIps)) {
|
56 |
if (!Mage::getSingleton('admin/session')->isLoggedIn()) {
|
@@ -73,7 +73,7 @@ class Bronto_Common_LogController extends Mage_Core_Controller_Front_Action
|
|
73 |
}
|
74 |
|
75 |
if (!$print) {
|
76 |
-
$this->getResponse()->setHeader('Content-Disposition', 'attachment; filename="'
|
77 |
}
|
78 |
|
79 |
$this->getResponse()->clearBody();
|
@@ -95,7 +95,7 @@ class Bronto_Common_LogController extends Mage_Core_Controller_Front_Action
|
|
95 |
private function _readfileChunked($filePath, $returnBytes = true)
|
96 |
{
|
97 |
$buffer = '';
|
98 |
-
$cnt
|
99 |
$handle = @fopen($filePath, 'rb');
|
100 |
if ($handle === false) {
|
101 |
return false;
|
26 |
// Requirements for this controller require that Bronto's
|
27 |
// Debug mode be enabled for any log file to be available
|
28 |
// for download
|
29 |
+
if (!Mage::helper('bronto_common')->isDebugEnabled())
|
30 |
return $this->norouteAction();
|
31 |
|
32 |
// Add dyndns
|
50 |
|
51 |
/* @var $httpHelper Mage_Core_Helper_Http */
|
52 |
$httpHelper = Mage::helper('core/http');
|
53 |
+
$ipAddress = $httpHelper->getRemoteAddr();
|
54 |
|
55 |
if (!in_array($ipAddress, $this->_allowedIps)) {
|
56 |
if (!Mage::getSingleton('admin/session')->isLoggedIn()) {
|
73 |
}
|
74 |
|
75 |
if (!$print) {
|
76 |
+
$this->getResponse()->setHeader('Content-Disposition', 'attachment; filename="' . $fileName . '"');
|
77 |
}
|
78 |
|
79 |
$this->getResponse()->clearBody();
|
95 |
private function _readfileChunked($filePath, $returnBytes = true)
|
96 |
{
|
97 |
$buffer = '';
|
98 |
+
$cnt = 0;
|
99 |
$handle = @fopen($filePath, 'rb');
|
100 |
if ($handle === false) {
|
101 |
return false;
|
app/code/community/Bronto/Common/etc/adminhtml.xml
CHANGED
@@ -10,6 +10,7 @@
|
|
10 |
<children>
|
11 |
<bronto module="bronto_common">
|
12 |
<title>Bronto General Section</title>
|
|
|
13 |
</bronto>
|
14 |
</children>
|
15 |
</config>
|
@@ -19,4 +20,4 @@
|
|
19 |
</admin>
|
20 |
</resources>
|
21 |
</acl>
|
22 |
-
</config>
|
10 |
<children>
|
11 |
<bronto module="bronto_common">
|
12 |
<title>Bronto General Section</title>
|
13 |
+
<sort_order>9993</sort_order>
|
14 |
</bronto>
|
15 |
</children>
|
16 |
</config>
|
20 |
</admin>
|
21 |
</resources>
|
22 |
</acl>
|
23 |
+
</config>
|
app/code/community/Bronto/Common/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Bronto_Common>
|
5 |
-
<version>2.0
|
6 |
</Bronto_Common>
|
7 |
</modules>
|
8 |
<global>
|
@@ -44,7 +44,25 @@
|
|
44 |
</bronto_common>
|
45 |
</routers>
|
46 |
</frontend>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
<adminhtml>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
<events>
|
49 |
<controller_action_predispatch>
|
50 |
<observers>
|
@@ -54,27 +72,25 @@
|
|
54 |
</bronto_common_controller_action_predispatch>
|
55 |
</observers>
|
56 |
</controller_action_predispatch>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
</events>
|
58 |
-
<acl>
|
59 |
-
<resources>
|
60 |
-
<admin>
|
61 |
-
<children>
|
62 |
-
<system>
|
63 |
-
<children>
|
64 |
-
<config>
|
65 |
-
<children>
|
66 |
-
<bronto>
|
67 |
-
<title>Bronto General Section</title>
|
68 |
-
</bronto>
|
69 |
-
</children>
|
70 |
-
</config>
|
71 |
-
</children>
|
72 |
-
</system>
|
73 |
-
</children>
|
74 |
-
</admin>
|
75 |
-
</resources>
|
76 |
-
</acl>
|
77 |
</adminhtml>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
78 |
<default>
|
79 |
<bronto>
|
80 |
<settings>
|
@@ -83,12 +99,21 @@
|
|
83 |
<test>0</test>
|
84 |
<notices>0</notices>
|
85 |
</settings>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
86 |
</bronto>
|
87 |
</default>
|
88 |
<phpunit>
|
89 |
<suite>
|
90 |
<modules>
|
91 |
-
<Bronto_Common
|
92 |
</modules>
|
93 |
</suite>
|
94 |
</phpunit>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Bronto_Common>
|
5 |
+
<version>2.1.0</version>
|
6 |
</Bronto_Common>
|
7 |
</modules>
|
8 |
<global>
|
44 |
</bronto_common>
|
45 |
</routers>
|
46 |
</frontend>
|
47 |
+
<admin>
|
48 |
+
<routers>
|
49 |
+
<adminhtml>
|
50 |
+
<args>
|
51 |
+
<modules>
|
52 |
+
<bronto_common before="Mage_Adminhtml">Bronto_Common_Adminhtml</bronto_common>
|
53 |
+
</modules>
|
54 |
+
</args>
|
55 |
+
</adminhtml>
|
56 |
+
</routers>
|
57 |
+
</admin>
|
58 |
<adminhtml>
|
59 |
+
<layout>
|
60 |
+
<updates>
|
61 |
+
<bronto_common>
|
62 |
+
<file>bronto/common.xml</file>
|
63 |
+
</bronto_common>
|
64 |
+
</updates>
|
65 |
+
</layout>
|
66 |
<events>
|
67 |
<controller_action_predispatch>
|
68 |
<observers>
|
72 |
</bronto_common_controller_action_predispatch>
|
73 |
</observers>
|
74 |
</controller_action_predispatch>
|
75 |
+
<controller_action_predispatch_adminhtml>
|
76 |
+
<observers>
|
77 |
+
<bronto_common_registration_form_submit>
|
78 |
+
<class>bronto_common/observer</class>
|
79 |
+
<method>registerExtension</method>
|
80 |
+
</bronto_common_registration_form_submit>
|
81 |
+
</observers>
|
82 |
+
</controller_action_predispatch_adminhtml>
|
83 |
</events>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
</adminhtml>
|
85 |
+
<crontab>
|
86 |
+
<jobs>
|
87 |
+
<bronto_common_delete_archives>
|
88 |
+
<!-- Run once a day -->
|
89 |
+
<schedule><cron_expr>0 0 * * *</cron_expr></schedule>
|
90 |
+
<run><model>bronto_common/observer::clearArchives</model></run>
|
91 |
+
</bronto_common_delete_archives>
|
92 |
+
</jobs>
|
93 |
+
</crontab>
|
94 |
<default>
|
95 |
<bronto>
|
96 |
<settings>
|
99 |
<test>0</test>
|
100 |
<notices>0</notices>
|
101 |
</settings>
|
102 |
+
<format>
|
103 |
+
<image_type>small_image</image_type>
|
104 |
+
<image_width>88</image_width>
|
105 |
+
<image_height>77</image_height>
|
106 |
+
</format>
|
107 |
+
<support>
|
108 |
+
<registered>0</registered>
|
109 |
+
<using_solution_partner>1</using_solution_partner>
|
110 |
+
</support>
|
111 |
</bronto>
|
112 |
</default>
|
113 |
<phpunit>
|
114 |
<suite>
|
115 |
<modules>
|
116 |
+
<Bronto_Common/>
|
117 |
</modules>
|
118 |
</suite>
|
119 |
</phpunit>
|
app/code/community/Bronto/Common/etc/system.xml
CHANGED
@@ -2,7 +2,8 @@
|
|
2 |
<config>
|
3 |
<tabs>
|
4 |
<bronto module="bronto_common">
|
5 |
-
<label>Bronto</label>
|
|
|
6 |
<sort_order>999</sort_order>
|
7 |
</bronto>
|
8 |
</tabs>
|
@@ -41,8 +42,9 @@
|
|
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>
|
45 |
<validate>validate-length minimum-length-36</validate>
|
|
|
46 |
</api_token>
|
47 |
<debug>
|
48 |
<label>Debug</label>
|
@@ -87,10 +89,190 @@
|
|
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
|
91 |
</notices>
|
92 |
</fields>
|
93 |
</settings>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
94 |
</groups>
|
95 |
</bronto>
|
96 |
</sections>
|
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>
|
42 |
<sort_order>10</sort_order>
|
43 |
<show_in_default>1</show_in_default>
|
44 |
<show_in_website>1</show_in_website>
|
45 |
+
<show_in_store>1</show_in_store>
|
46 |
<validate>validate-length minimum-length-36</validate>
|
47 |
+
<comment><![CDATA[<span style="color: red; font-weight:bold;">Warning!</span> Changing your API Token will require you to reconfigure all Bronto modules and reimport your data.]]></comment>
|
48 |
</api_token>
|
49 |
<debug>
|
50 |
<label>Debug</label>
|
89 |
<show_in_default>1</show_in_default>
|
90 |
<show_in_website>1</show_in_website>
|
91 |
<show_in_store>1</show_in_store>
|
92 |
+
<comment><![CDATA[Show warnings/errors as site notices.<br /><strong>Note:</strong> Site notices can be customer-facing.]]></comment>
|
93 |
</notices>
|
94 |
</fields>
|
95 |
</settings>
|
96 |
+
<support>
|
97 |
+
<label>Registration</label>
|
98 |
+
<frontend_type>text</frontend_type>
|
99 |
+
<frontend_model>bronto_common/adminhtml_system_config_support</frontend_model>
|
100 |
+
<sort_order>2</sort_order>
|
101 |
+
<show_in_default>1</show_in_default>
|
102 |
+
<show_in_website>1</show_in_website>
|
103 |
+
<show_in_store>1</show_in_store>
|
104 |
+
<fields>
|
105 |
+
<site_name>
|
106 |
+
<label>Bronto Site Name</label>
|
107 |
+
<frontend_type>text</frontend_type>
|
108 |
+
<frontend_model>bronto_common/adminhtml_system_config_form_field_support_site</frontend_model>
|
109 |
+
<sort_order>1</sort_order>
|
110 |
+
<show_in_default>1</show_in_default>
|
111 |
+
<show_in_website>1</show_in_website>
|
112 |
+
<show_in_store>1</show_in_store>
|
113 |
+
</site_name>
|
114 |
+
<firstname>
|
115 |
+
<label>First Name</label>
|
116 |
+
<frontend_type>text</frontend_type>
|
117 |
+
<frontend_model>bronto_common/adminhtml_system_config_form_field_support</frontend_model>
|
118 |
+
<validate>validate-length</validate>
|
119 |
+
<sort_order>1</sort_order>
|
120 |
+
<show_in_default>1</show_in_default>
|
121 |
+
<show_in_website>1</show_in_website>
|
122 |
+
<show_in_store>1</show_in_store>
|
123 |
+
</firstname>
|
124 |
+
<lastname>
|
125 |
+
<label>Last Name</label>
|
126 |
+
<frontend_type>text</frontend_type>
|
127 |
+
<frontend_model>bronto_common/adminhtml_system_config_form_field_support</frontend_model>
|
128 |
+
<validate>validate-length</validate>
|
129 |
+
<sort_order>2</sort_order>
|
130 |
+
<show_in_default>1</show_in_default>
|
131 |
+
<show_in_website>1</show_in_website>
|
132 |
+
<show_in_store>1</show_in_store>
|
133 |
+
</lastname>
|
134 |
+
<title>
|
135 |
+
<label>Title</label>
|
136 |
+
<frontend_type>text</frontend_type>
|
137 |
+
<frontend_model>bronto_common/adminhtml_system_config_form_field_support</frontend_model>
|
138 |
+
<validate>validate-length</validate>
|
139 |
+
<sort_order>3</sort_order>
|
140 |
+
<show_in_default>1</show_in_default>
|
141 |
+
<show_in_website>1</show_in_website>
|
142 |
+
<show_in_store>1</show_in_store>
|
143 |
+
</title>
|
144 |
+
<email>
|
145 |
+
<label>Email</label>
|
146 |
+
<frontend_type>text</frontend_type>
|
147 |
+
<backend_model>adminhtml/system_config_backend_email_address</backend_model>
|
148 |
+
<frontend_model>bronto_common/adminhtml_system_config_form_field_support</frontend_model>
|
149 |
+
<validate>validate-email</validate>
|
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 |
+
</email>
|
155 |
+
<number>
|
156 |
+
<label>Phone Number</label>
|
157 |
+
<frontend_type>text</frontend_type>
|
158 |
+
<frontend_model>bronto_common/adminhtml_system_config_form_field_support</frontend_model>
|
159 |
+
<validate>validate-phone</validate>
|
160 |
+
<sort_order>6</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 |
+
</number>
|
165 |
+
<using_solution_partner>
|
166 |
+
<label>Working with a Magento Solution Partner or Systems Integrator?</label>
|
167 |
+
<frontend_type>select</frontend_type>
|
168 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
169 |
+
<frontend_model>bronto_common/adminhtml_system_config_form_field_support</frontend_model>
|
170 |
+
<sort_order>7</sort_order>
|
171 |
+
<default_value>1</default_value>
|
172 |
+
<show_in_default>1</show_in_default>
|
173 |
+
<show_in_website>1</show_in_website>
|
174 |
+
<show_in_store>1</show_in_store>
|
175 |
+
</using_solution_partner>
|
176 |
+
<partner>
|
177 |
+
<depends><using_solution_partner>1</using_solution_partner></depends>
|
178 |
+
<label>Name of Solution Partner or SI</label>
|
179 |
+
<frontend_type>text</frontend_type>
|
180 |
+
<frontend_model>bronto_common/adminhtml_system_config_form_field_support</frontend_model>
|
181 |
+
<sort_order>8</sort_order>
|
182 |
+
<show_in_default>1</show_in_default>
|
183 |
+
<show_in_website>1</show_in_website>
|
184 |
+
<show_in_store>1</show_in_store>
|
185 |
+
</partner>
|
186 |
+
</fields>
|
187 |
+
</support>
|
188 |
+
<format>
|
189 |
+
<label>Formatting Options</label>
|
190 |
+
<frontend_type>text</frontend_type>
|
191 |
+
<frontend_model>bronto_common/adminhtml_system_config_form_fieldset</frontend_model>
|
192 |
+
<sort_order>3</sort_order>
|
193 |
+
<show_in_default>1</show_in_default>
|
194 |
+
<show_in_website>1</show_in_website>
|
195 |
+
<show_in_store>1</show_in_store>
|
196 |
+
<comment><![CDATA[These formatting options apply to product images and any price variables within Reminder Emails. Leave image width <em>or</em> height blank to resize according to aspect ratio. Leave both width <em>and</em> height blank to use the full image size. You can always set width and height values within the HTML of your message too.<br/><br/><strong style="color: red">Warning!</strong> Changing any formatting options will immediately affect future emails. Make sure your corresponding messages are ready to accept the newly formatted content.<br/><br/>]]></comment>
|
197 |
+
<fields>
|
198 |
+
<image_type>
|
199 |
+
<label>Image Type</label>
|
200 |
+
<frontend_type>select</frontend_type>
|
201 |
+
<frontend_model>bronto_common/adminhtml_system_config_form_field_image</frontend_model>
|
202 |
+
<source_model>bronto_common/system_config_source_image</source_model>
|
203 |
+
<sort_order>1</sort_order>
|
204 |
+
<show_in_default>1</show_in_default>
|
205 |
+
<show_in_website>1</show_in_website>
|
206 |
+
<show_in_store>1</show_in_store>
|
207 |
+
<default_value>small_image</default_value>
|
208 |
+
<comment>The product image to use.</comment>
|
209 |
+
</image_type>
|
210 |
+
<image_width>
|
211 |
+
<label>Image Width</label>
|
212 |
+
<frontend_type>text</frontend_type>
|
213 |
+
<frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
|
214 |
+
<sort_order>10</sort_order>
|
215 |
+
<show_in_default>1</show_in_default>
|
216 |
+
<show_in_website>1</show_in_website>
|
217 |
+
<show_in_store>1</show_in_store>
|
218 |
+
<default_value>88</default_value>
|
219 |
+
<comment>Product image width in pixels.</comment>
|
220 |
+
</image_width>
|
221 |
+
<image_height>
|
222 |
+
<label>Image Height</label>
|
223 |
+
<frontend_type>text</frontend_type>
|
224 |
+
<frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
|
225 |
+
<sort_order>20</sort_order>
|
226 |
+
<show_in_default>1</show_in_default>
|
227 |
+
<show_in_website>1</show_in_website>
|
228 |
+
<show_in_store>1</show_in_store>
|
229 |
+
<default_value>77</default_value>
|
230 |
+
<comment>Product image height in pixels.</comment>
|
231 |
+
</image_height>
|
232 |
+
<use_symbol>
|
233 |
+
<label>Include Currency Symbol</label>
|
234 |
+
<frontend_type>select</frontend_type>
|
235 |
+
<frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
|
236 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
237 |
+
<sort_order>30</sort_order>
|
238 |
+
<show_in_default>1</show_in_default>
|
239 |
+
<show_in_website>1</show_in_website>
|
240 |
+
<show_in_store>1</show_in_store>
|
241 |
+
<comment>
|
242 |
+
<![CDATA[Pass Default Display Currency symbol into email (located in "General" > "Currency Setup" > "Default Display Currency").]]></comment>
|
243 |
+
</use_symbol>
|
244 |
+
</fields>
|
245 |
+
</format>
|
246 |
+
<information>
|
247 |
+
<label>Support Information</label>
|
248 |
+
<comment><![CDATA[Most questions can easily be answered by thoroughly reviewing the Bronto <a style="color:#ea7601" target="_blank" href="http://a.bron.to/magento" title="Magento Resource Center | Bronto Developers">Magento Resource Center</a> so please consult that first. The next best resource is the <a style="color:#ea7601" target="_blank" href="http://dev.bronto.com/questions" title="Questions | Bronto Developers">Questions</a> forum where you can post the question if it has not been asked yet.<br/><br/><strong>Disclaimer:</strong> The Bronto Extension for Magento was tested in clean Magento environments and Bronto cannot guarantee compatibility with third-party extensions or other site customizations.<br/><br/>If you believe you have encountered an actual issue with the extension itself then you may file a support case. Please note that regular Bronto Support hours are between 8am-8pm ET, Monday through Friday, excluding holidays.<br/><br/><span style="padding-left: 30px;">To contact the Bronto Support team, please perform the following steps:</span><br/><ul><li style="padding-left: 60px;"><strong>Step 1: </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: </strong>After creating a case, please add a comment and paste in all of the debug information that is generated after clicking the <em>Generate Debug Information</em> button below:<ul style="padding-left: 85px;list-style-type:lower-alpha;"><li>Click on the <a style="color:#ea7601" target="_blank" title="Tehnical Support | Bronto Marketing Platform" href="https://app.bronto.com/shared/support/index">Support</a> link located in the top right of the page.</li><li>Click on the case you want to comment on.</li><li>Paste in the debug information and click <em>Post Response</em>.</li></ul></li><li style="padding-left: 60px;"><strong>Step 3: </strong>Optionally, if more information is needed, your Support representative may request log files. Simply click the <em>Create Log Archive</em> button below and then click the link that is generated and displayed below the button to download an archive of log files to send to the location designated by your Support representative.</li></ul><br/>]]></comment>
|
249 |
+
<frontend_type>text</frontend_type>
|
250 |
+
<frontend_model>bronto_common/adminhtml_system_config_form_fieldset</frontend_model>
|
251 |
+
<sort_order>4</sort_order>
|
252 |
+
<show_in_default>1</show_in_default>
|
253 |
+
<show_in_website>0</show_in_website>
|
254 |
+
<show_in_store>0</show_in_store>
|
255 |
+
<fields>
|
256 |
+
<download>
|
257 |
+
<label>Create Log Archive</label>
|
258 |
+
<frontend_type>text</frontend_type>
|
259 |
+
<frontend_model>bronto_common/adminhtml_system_config_form_field_download</frontend_model>
|
260 |
+
<sort_order>7</sort_order>
|
261 |
+
<show_in_default>1</show_in_default>
|
262 |
+
<show_in_website>1</show_in_website>
|
263 |
+
<show_in_store>1</show_in_store>
|
264 |
+
</download>
|
265 |
+
<debug>
|
266 |
+
<label>Debug Information</label>
|
267 |
+
<frontend_type>text</frontend_type>
|
268 |
+
<frontend_model>bronto_common/adminhtml_system_config_form_field_debug</frontend_model>
|
269 |
+
<sort_order>8</sort_order>
|
270 |
+
<show_in_default>1</show_in_default>
|
271 |
+
<show_in_website>0</show_in_website>
|
272 |
+
<show_in_store>0</show_in_store>
|
273 |
+
</debug>
|
274 |
+
</fields>
|
275 |
+
</information>
|
276 |
</groups>
|
277 |
</bronto>
|
278 |
</sections>
|
app/code/community/Bronto/ConflictChecker/Block/Adminhtml/System/Config/About.php
DELETED
@@ -1,54 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* About header for admin module config
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package ConflictChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
|
21 |
-
/**
|
22 |
-
* About header for admin module config
|
23 |
-
*
|
24 |
-
* @category Bronto
|
25 |
-
* @package ConflictChecker
|
26 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
27 |
-
* @copyright 2012 Atlantic BT
|
28 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
29 |
-
* @version Release: @package_version@
|
30 |
-
* @link <>
|
31 |
-
* @see References to other sections (if any)...
|
32 |
-
*/
|
33 |
-
class Bronto_ConflictChecker_Block_Adminhtml_System_Config_About
|
34 |
-
extends Bronto_Common_Block_Adminhtml_System_Config_About
|
35 |
-
{
|
36 |
-
// {{{ properties
|
37 |
-
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Module name
|
41 |
-
* @var string
|
42 |
-
* @access protected
|
43 |
-
*/
|
44 |
-
protected $_module = 'bronto_conflictchecker';
|
45 |
-
|
46 |
-
/**
|
47 |
-
* User descriptive module name
|
48 |
-
* @var string
|
49 |
-
* @access protected
|
50 |
-
*/
|
51 |
-
protected $_name = 'Bronto Rewrite Conflict Checker Module';
|
52 |
-
|
53 |
-
// }}}
|
54 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Block/Adminhtml/System/Config/Conflictchecker.php
DELETED
@@ -1,88 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Conflict checker
|
5 |
-
*
|
6 |
-
* This is the heart of the conflict checker that glues together and fires
|
7 |
-
* the Chain of responsibility
|
8 |
-
*
|
9 |
-
* PHP version 5
|
10 |
-
*
|
11 |
-
* The license text...
|
12 |
-
*
|
13 |
-
* @category Bronto
|
14 |
-
* @package ConflictChecker
|
15 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
16 |
-
* @copyright 2012 Atlantic BT
|
17 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
18 |
-
* @version CVS: $Id:$
|
19 |
-
* @link <>
|
20 |
-
* @see References to other sections (if any)...
|
21 |
-
*/
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Conflict checker
|
25 |
-
*
|
26 |
-
* This is the heart of the conflict checker that glues together and fires
|
27 |
-
* the Chain of responsibility
|
28 |
-
*
|
29 |
-
* @category Bronto
|
30 |
-
* @package ConflictChecker
|
31 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
32 |
-
* @copyright 2012 Atlantic BT
|
33 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
34 |
-
* @version Release: @package_version@
|
35 |
-
* @link <>
|
36 |
-
* @see References to other sections (if any)...
|
37 |
-
*/
|
38 |
-
class Bronto_ConflictChecker_Block_Adminhtml_System_Config_Conflictchecker
|
39 |
-
extends Mage_Adminhtml_Block_Abstract
|
40 |
-
implements Varien_Data_Form_Element_Renderer_Interface
|
41 |
-
{
|
42 |
-
// {{{ properties
|
43 |
-
|
44 |
-
|
45 |
-
/**
|
46 |
-
* rewritten xml nodes
|
47 |
-
* @var array
|
48 |
-
* @access protected
|
49 |
-
*/
|
50 |
-
protected $_rewrittenConfigs = array();
|
51 |
-
|
52 |
-
// }}}
|
53 |
-
// {{{ render()
|
54 |
-
|
55 |
-
|
56 |
-
/**
|
57 |
-
* Render all xml names that conflict
|
58 |
-
*
|
59 |
-
* @param Varien_Data_Form_Element_Abstract $element Form element
|
60 |
-
*
|
61 |
-
* @return string
|
62 |
-
* @access public
|
63 |
-
*/
|
64 |
-
public function render(Varien_Data_Form_Element_Abstract $element)
|
65 |
-
{
|
66 |
-
$globalDataStore = Mage::getModel('bronto_conflictchecker/config_datastore');
|
67 |
-
Mage::register('conflict_datastore', $globalDataStore);
|
68 |
-
$config = Mage::getModel('bronto_conflictchecker/core_config');
|
69 |
-
$config->reinit();
|
70 |
-
|
71 |
-
// Chain of Responsibility
|
72 |
-
// each checker looks through its designated area for rewrites
|
73 |
-
$blocks = Mage::getModel('bronto_conflictchecker/config_blocks');
|
74 |
-
$models = Mage::getModel('bronto_conflictchecker/config_models', array($blocks));
|
75 |
-
$helpers = Mage::getModel('bronto_conflictchecker/config_helpers', array($models));
|
76 |
-
$resources = Mage::getModel('bronto_conflictchecker/config_resources', array($helpers));
|
77 |
-
$checker = Mage::getModel('bronto_conflictchecker/config_checker', array($resources));
|
78 |
-
|
79 |
-
$conflicts = $checker->getConflicts($config->getNode('frontend'));
|
80 |
-
|
81 |
-
$globalDataStore->getRewriteConflicts();
|
82 |
-
|
83 |
-
$printer = new Bronto_ConflictChecker_Model_Config_Printer();
|
84 |
-
return $printer->render($globalDataStore, 'XML configurations rewritten more than once');
|
85 |
-
}
|
86 |
-
|
87 |
-
// }}}
|
88 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Block/Printer.php
DELETED
@@ -1,77 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Table generator
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package ConflictChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Table generator
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package ConflictChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
class Bronto_ConflictChecker_Block_Printer
|
33 |
-
extends Mage_Adminhtml_Block_Template
|
34 |
-
{
|
35 |
-
// {{{ properties
|
36 |
-
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Parity bit
|
40 |
-
* @var integer
|
41 |
-
* @access protected
|
42 |
-
*/
|
43 |
-
protected $_i = 0;
|
44 |
-
|
45 |
-
// }}}
|
46 |
-
// {{{ _construct()
|
47 |
-
|
48 |
-
|
49 |
-
/**
|
50 |
-
* psuedo constructor
|
51 |
-
*
|
52 |
-
* @return void
|
53 |
-
* @access public
|
54 |
-
*/
|
55 |
-
public function _construct()
|
56 |
-
{
|
57 |
-
parent::_construct();
|
58 |
-
$this->setTemplate('bronto/conflictchecker/errors.phtml');
|
59 |
-
}
|
60 |
-
|
61 |
-
// }}}
|
62 |
-
// {{{ getParity()
|
63 |
-
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Get if even or ordd
|
67 |
-
*
|
68 |
-
* @return mixed Return description (if any) ...
|
69 |
-
* @access public
|
70 |
-
*/
|
71 |
-
public function getParity()
|
72 |
-
{
|
73 |
-
return $this->_i++ % 2 ? 'even' : '';
|
74 |
-
}
|
75 |
-
|
76 |
-
// }}}
|
77 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Helper/Data.php
DELETED
@@ -1,34 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Helper
|
5 |
-
*
|
6 |
-
* PHP versions 4 and 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package ConflictChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Helper
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package ConflictChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
class Bronto_ConflictChecker_Helper_Data extends Bronto_Common_Helper_Data
|
33 |
-
{
|
34 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Model/Config/Blocks.php
DELETED
@@ -1,69 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Block config checker
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package ConflictChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Block config checker
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package ConflictChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
class Bronto_ConflictChecker_Model_Config_Blocks
|
33 |
-
extends Bronto_ConflictChecker_Model_Config_ConfigAbstract
|
34 |
-
{
|
35 |
-
// {{{ properties
|
36 |
-
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Type of rewrite
|
40 |
-
* @var string
|
41 |
-
* @access protected
|
42 |
-
*/
|
43 |
-
protected $_type = 'blocks';
|
44 |
-
|
45 |
-
// }}}
|
46 |
-
// {{{ getRewrites()
|
47 |
-
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Check block section for rewrites
|
51 |
-
*
|
52 |
-
* @param Bronto_ConflictChecker_Model_Core_Config_Element $config Config node
|
53 |
-
* @param array $rewrites Existing rewrites
|
54 |
-
*
|
55 |
-
* @return array rewrites
|
56 |
-
* @access public
|
57 |
-
*/
|
58 |
-
public function getRewrites(
|
59 |
-
Bronto_ConflictChecker_Model_Core_Config_Element $config,
|
60 |
-
$rewrites = array()
|
61 |
-
) {
|
62 |
-
$blocks = $config->blocks;
|
63 |
-
$this->_findRewrites($blocks, $rewrites);
|
64 |
-
|
65 |
-
return parent::getRewrites($config, $rewrites);
|
66 |
-
}
|
67 |
-
|
68 |
-
// }}}
|
69 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Model/Config/Checker.php
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Conflict checker
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package ConflictChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Conflict checker
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package ConflictChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
class Bronto_ConflictChecker_Model_Config_Checker
|
33 |
-
extends Bronto_ConflictChecker_Model_Config_ConfigAbstract
|
34 |
-
{
|
35 |
-
// {{{ getConflicts()
|
36 |
-
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Get the conflicts
|
40 |
-
*
|
41 |
-
* @param Bronto_ConflictChecker_Model_Core_Config_Element $config Parameter description (if any) ...
|
42 |
-
*
|
43 |
-
* @return unknown Return description (if any) ...
|
44 |
-
* @access public
|
45 |
-
*/
|
46 |
-
public function getConflicts(
|
47 |
-
Bronto_ConflictChecker_Model_Core_Config_Element $config
|
48 |
-
) {
|
49 |
-
$rewrites = $this->getRewrites($config);
|
50 |
-
foreach ($rewrites as $type => $modules) {
|
51 |
-
foreach ($modules as $module => $classes) {
|
52 |
-
foreach ($classes as $class => $conflicts) {
|
53 |
-
if (count($classes[$class]) > 1) {
|
54 |
-
echo "$type : $module : $class is rewrite multiple times by";
|
55 |
-
var_dump($conflicts);
|
56 |
-
}
|
57 |
-
}
|
58 |
-
}
|
59 |
-
}
|
60 |
-
return $this->getRewrites($config);
|
61 |
-
}
|
62 |
-
|
63 |
-
// }}}
|
64 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Model/Config/ConfigAbstract.php
DELETED
@@ -1,125 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Rewrite config checker
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package ConflictChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Rewrite config checker
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package ConflictChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
abstract class Bronto_ConflictChecker_Model_Config_ConfigAbstract
|
33 |
-
extends Mage_Core_Model_Abstract
|
34 |
-
implements Bronto_ConflictChecker_Model_Config_ConfigInterface
|
35 |
-
{
|
36 |
-
// {{{ properties
|
37 |
-
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Chain of Responsibility link
|
41 |
-
* @var object
|
42 |
-
* @access protected
|
43 |
-
*/
|
44 |
-
protected $_nextHandler = NULL;
|
45 |
-
|
46 |
-
// }}}
|
47 |
-
// {{{ _construct()
|
48 |
-
|
49 |
-
|
50 |
-
/**
|
51 |
-
* psuedo constructor
|
52 |
-
*
|
53 |
-
* If a handler is passed into the constructor then set it as the next link
|
54 |
-
*
|
55 |
-
* @return void
|
56 |
-
* @access public
|
57 |
-
*/
|
58 |
-
public function _construct()
|
59 |
-
{
|
60 |
-
if (isset($this->_data[0])) {
|
61 |
-
$this->_nextHandler = $this->_data[0];
|
62 |
-
}
|
63 |
-
}
|
64 |
-
|
65 |
-
// }}}
|
66 |
-
// {{{ getRewrites()
|
67 |
-
|
68 |
-
|
69 |
-
/**
|
70 |
-
* Check if there are more handlers and if so get the rewrites from them
|
71 |
-
|
72 |
-
* @param Bronto_ConflictChecker_Model_Core_Config_Element $config XML node
|
73 |
-
* @param array $rewrites existing rewrites
|
74 |
-
|
75 |
-
* @return array rewrites
|
76 |
-
* @access public
|
77 |
-
*/
|
78 |
-
public function getRewrites(
|
79 |
-
Bronto_ConflictChecker_Model_Core_Config_Element $config,
|
80 |
-
$rewrites = array()
|
81 |
-
) {
|
82 |
-
if (!is_null($this->_nextHandler)) {
|
83 |
-
return $this->_nextHandler->getRewrites($config, $rewrites);
|
84 |
-
} else {
|
85 |
-
return $rewrites;
|
86 |
-
}
|
87 |
-
}
|
88 |
-
|
89 |
-
// }}}
|
90 |
-
// {{{ _findRewrites()
|
91 |
-
|
92 |
-
|
93 |
-
/**
|
94 |
-
* Find if XML node has any rewrites and if so append them into list
|
95 |
-
*
|
96 |
-
* @param Bronto_ConflictChecker_Model_Core_Config_Element $config XML Node
|
97 |
-
* @param array &$rewrites existing rewrites
|
98 |
-
*
|
99 |
-
* @return void
|
100 |
-
* @access protected
|
101 |
-
*/
|
102 |
-
protected function _findRewrites(
|
103 |
-
Bronto_ConflictChecker_Model_Core_Config_Element $config,
|
104 |
-
&$rewrites = array()
|
105 |
-
) {
|
106 |
-
$reflect = new ReflectionObject($config);
|
107 |
-
$props = $reflect->getProperties(ReflectionProperty::IS_PUBLIC);
|
108 |
-
|
109 |
-
foreach ($props as $prop) {
|
110 |
-
$module = $prop->getName();
|
111 |
-
$reflect = new ReflectionObject($config->$module);
|
112 |
-
if ($reflect->hasProperty('rewrite')) {
|
113 |
-
$rewrite = new ReflectionObject($config->$module->rewrite);
|
114 |
-
$properties = $rewrite->getProperties(ReflectionProperty::IS_PUBLIC);
|
115 |
-
foreach ($properties as $property) {
|
116 |
-
$class = $property->name;
|
117 |
-
$rewrites[$this->_type][$module][$class][]
|
118 |
-
= (string) $config->$module->rewrite->$class;
|
119 |
-
}
|
120 |
-
}
|
121 |
-
}
|
122 |
-
}
|
123 |
-
|
124 |
-
// }}}
|
125 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Model/Config/ConfigInterface.php
DELETED
@@ -1,46 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Rewrite checker interface
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package ConflictChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Rewrite checker interface
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package ConflictChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
interface Bronto_ConflictChecker_Model_Config_ConfigInterface
|
33 |
-
{
|
34 |
-
// {{{ getRewrites()
|
35 |
-
|
36 |
-
|
37 |
-
/**
|
38 |
-
* find all rewrites on XML node elements
|
39 |
-
*
|
40 |
-
* @param Bronto_ConflictChecker_Model_Core_Config_Element $config XML node
|
41 |
-
* @access public
|
42 |
-
*/
|
43 |
-
public function getRewrites(Bronto_ConflictChecker_Model_Core_Config_Element $config);
|
44 |
-
|
45 |
-
// }}}
|
46 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Model/Config/Helpers.php
DELETED
@@ -1,69 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Helper config checker
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package ConflictChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Helper config checker
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package ConflictChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
class Bronto_ConflictChecker_Model_Config_Helpers
|
33 |
-
extends Bronto_ConflictChecker_Model_Config_ConfigAbstract
|
34 |
-
{
|
35 |
-
// {{{ properties
|
36 |
-
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Type of rewrite
|
40 |
-
* @var string
|
41 |
-
* @access protected
|
42 |
-
*/
|
43 |
-
protected $_type = 'helpers';
|
44 |
-
|
45 |
-
// }}}
|
46 |
-
// {{{ getRewrites()
|
47 |
-
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Check helper section for rewrites
|
51 |
-
*
|
52 |
-
* @param Bronto_ConflictChecker_Model_Core_Config_Element $config Config node
|
53 |
-
* @param array $rewrites Existing rewrites
|
54 |
-
*
|
55 |
-
* @return array rewrites
|
56 |
-
* @access public
|
57 |
-
*/
|
58 |
-
public function getRewrites(
|
59 |
-
Bronto_ConflictChecker_Model_Core_Config_Element $config,
|
60 |
-
$rewrites = array()
|
61 |
-
) {
|
62 |
-
$helpers = $config->helpers;
|
63 |
-
$this->_findRewrites($helpers, $rewrites);
|
64 |
-
|
65 |
-
return parent::getRewrites($config, $rewrites);
|
66 |
-
}
|
67 |
-
|
68 |
-
// }}}
|
69 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Model/Config/Models.php
DELETED
@@ -1,68 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Model config checker
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package ConflictChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Model config checker
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package ConflictChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
class Bronto_ConflictChecker_Model_Config_Models
|
33 |
-
extends Bronto_ConflictChecker_Model_Config_ConfigAbstract
|
34 |
-
{
|
35 |
-
// {{{ properties
|
36 |
-
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Type of rewrite
|
40 |
-
* @var string
|
41 |
-
* @access protected
|
42 |
-
*/
|
43 |
-
protected $_type = 'models';
|
44 |
-
|
45 |
-
// }}}
|
46 |
-
// {{{ getRewrites()
|
47 |
-
|
48 |
-
/**
|
49 |
-
* Check models section for rewrites
|
50 |
-
*
|
51 |
-
* @param Bronto_ConflictChecker_Model_Core_Config_Element $config Config node
|
52 |
-
* @param array $rewrites Existing rewrites
|
53 |
-
*
|
54 |
-
* @return array rewrites
|
55 |
-
* @access public
|
56 |
-
*/
|
57 |
-
public function getRewrites(
|
58 |
-
Bronto_ConflictChecker_Model_Core_Config_Element $config,
|
59 |
-
$rewrites = array()
|
60 |
-
) {
|
61 |
-
$models = $config->models;
|
62 |
-
$this->_findRewrites($models, $rewrites);
|
63 |
-
|
64 |
-
return parent::getRewrites($config, $rewrites);
|
65 |
-
}
|
66 |
-
|
67 |
-
// }}}
|
68 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Model/Config/Printer.php
DELETED
@@ -1,58 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Datastore printer
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package ConflictChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Datastore printer
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package ConflictChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
class Bronto_ConflictChecker_Model_Config_Printer
|
33 |
-
{
|
34 |
-
// {{{ render()
|
35 |
-
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Rewrite printer
|
39 |
-
*
|
40 |
-
* @param Bronto_ConflictChecker_Model_Config_Datastore $datastore Datastore to print from
|
41 |
-
* @param string $title Title to print
|
42 |
-
|
43 |
-
* @return string
|
44 |
-
* @access public
|
45 |
-
*/
|
46 |
-
public function render(
|
47 |
-
Bronto_ConflictChecker_Model_Config_Datastore $datastore,
|
48 |
-
$title
|
49 |
-
) {
|
50 |
-
$block = Mage::app()->getLayout()->createBlock('bronto_conflictchecker/printer');
|
51 |
-
$block->setRewrites($datastore->getRewriteConflicts());
|
52 |
-
$block->setTitle($title);
|
53 |
-
|
54 |
-
return $block->toHtml();
|
55 |
-
}
|
56 |
-
|
57 |
-
// }}}
|
58 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Model/Config/Resources.php
DELETED
@@ -1,69 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Helper config checker
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package ConflictChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Helper config checker
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package ConflictChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
class Bronto_ConflictChecker_Model_Config_Resources
|
33 |
-
extends Bronto_ConflictChecker_Model_Config_ConfigAbstract
|
34 |
-
{
|
35 |
-
// {{{ properties
|
36 |
-
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Type of rewrite
|
40 |
-
* @var string
|
41 |
-
* @access protected
|
42 |
-
*/
|
43 |
-
protected $_type = 'resources';
|
44 |
-
|
45 |
-
// }}}
|
46 |
-
// {{{ getRewrites()
|
47 |
-
|
48 |
-
|
49 |
-
/**
|
50 |
-
* Check resources section for rewrites
|
51 |
-
*
|
52 |
-
* @param Bronto_ConflictChecker_Model_Core_Config_Element $config Config node
|
53 |
-
* @param array $rewrites Existing rewrites
|
54 |
-
*
|
55 |
-
* @return array rewrites
|
56 |
-
* @access public
|
57 |
-
*/
|
58 |
-
public function getRewrites(
|
59 |
-
Bronto_ConflictChecker_Model_Core_Config_Element $config,
|
60 |
-
$rewrites = array()
|
61 |
-
) {
|
62 |
-
$resources = $config->resources;
|
63 |
-
$this->_findRewrites($resources, $rewrites);
|
64 |
-
|
65 |
-
return parent::getRewrites($config, $rewrites);
|
66 |
-
}
|
67 |
-
|
68 |
-
// }}}
|
69 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Model/Core/Config/Base.php
DELETED
@@ -1,50 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* XML configuration base
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package ConflictChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* XML configuration base
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package ConflictChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
class Bronto_ConflictChecker_Model_Core_Config_Base
|
33 |
-
extends Bronto_ConflictChecker_Model_Lib_Varien_Simplexml_Config
|
34 |
-
{
|
35 |
-
// {{{ __construct()
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Constructor
|
39 |
-
*
|
40 |
-
* @return void
|
41 |
-
* @access public
|
42 |
-
*/
|
43 |
-
public function __construct($sourceData = null)
|
44 |
-
{
|
45 |
-
$this->_elementClass = 'Bronto_ConflictChecker_Model_Core_Config_Element';
|
46 |
-
parent::__construct($sourceData);
|
47 |
-
}
|
48 |
-
|
49 |
-
// }}}
|
50 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Model/Lib/Varien/Simplexml/Config.php
DELETED
@@ -1,46 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* SimpleXML Config element
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package ConflictChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* SimpleXML Config element
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package ConflictChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
class Bronto_ConflictChecker_Model_Lib_Varien_Simplexml_Config
|
33 |
-
extends Varien_Simplexml_Config
|
34 |
-
{
|
35 |
-
// {{{ properties
|
36 |
-
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Description for protected
|
40 |
-
* @var string
|
41 |
-
* @access protected
|
42 |
-
*/
|
43 |
-
protected $_elementClass = 'Bronto_ConflictChecker_Model_Lib_Varien_Simplexml_Element';
|
44 |
-
|
45 |
-
// }}}
|
46 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Model/Mysql4/Core/Config.php
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Mysql config
|
5 |
-
*
|
6 |
-
* PHP versions 4 and 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package ConflictChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Mysql config
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package ConflictChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
class Bronto_ConflictChecker_Model_Mysql4_Core_Config
|
33 |
-
extends Bronto_ConflictChecker_Model_Resource_Core_Config
|
34 |
-
{
|
35 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Model/Path/Locator/Factory.php
DELETED
@@ -1,55 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Locator factory
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package ConflictChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
|
21 |
-
/**
|
22 |
-
* Locator factory
|
23 |
-
*
|
24 |
-
* @category Bronto
|
25 |
-
* @package ConflictChecker
|
26 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
27 |
-
* @copyright 2012 Atlantic BT
|
28 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
29 |
-
* @version Release: @package_version@
|
30 |
-
* @link <>
|
31 |
-
* @see References to other sections (if any)...
|
32 |
-
*/
|
33 |
-
class Bronto_ConflictChecker_Model_Path_Locator_Factory
|
34 |
-
{
|
35 |
-
// {{{ getLocator()
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Get path locator implementation based on PHP version
|
39 |
-
*
|
40 |
-
* @return Bronto_ConflictChecker_Model_Path_Locator_LocatorInterface
|
41 |
-
* @access public
|
42 |
-
*/
|
43 |
-
public function getLocator()
|
44 |
-
{
|
45 |
-
if (version_compare(PHP_VERSION, '5.3.0', '>=')) {
|
46 |
-
$model = new Bronto_ConflictChecker_Model_Path_Locator_Stack(new SplStack());
|
47 |
-
} else {
|
48 |
-
$model = new Bronto_ConflictChecker_Model_Path_Locator_Array(array());
|
49 |
-
}
|
50 |
-
|
51 |
-
return $model;
|
52 |
-
}
|
53 |
-
|
54 |
-
// }}}
|
55 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Model/Path/Locator/IteratorAbstract.php
DELETED
@@ -1,60 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Locator Iterator
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package ConflictChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Locator Iterator
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package ConflictChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
abstract class Bronto_ConflictChecker_Model_Path_Locator_IteratorAbstract
|
33 |
-
{
|
34 |
-
// {{{ properties
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Locator implementation
|
38 |
-
* @var Bronto_ConflictChecker_Model_Path_Locator_LocatorInterface
|
39 |
-
* @access protected
|
40 |
-
*/
|
41 |
-
protected $_iterator = null;
|
42 |
-
|
43 |
-
// }}}
|
44 |
-
// {{{ __construct()
|
45 |
-
|
46 |
-
/**
|
47 |
-
* Constructor
|
48 |
-
*
|
49 |
-
* @param Bronto_ConflictChecker_Model_Path_Locator_LocatorInterface $iterator
|
50 |
-
*
|
51 |
-
* @return void
|
52 |
-
* @access public
|
53 |
-
*/
|
54 |
-
public function __construct($iterator)
|
55 |
-
{
|
56 |
-
$this->_iterator = $iterator;
|
57 |
-
}
|
58 |
-
|
59 |
-
// }}}
|
60 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Model/Path/Locator/LocatorInterface.php
DELETED
@@ -1,63 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Path locator interface
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package ConflictChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Path locator interface
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package ConflictChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
interface Bronto_ConflictChecker_Model_Path_Locator_LocatorInterface
|
33 |
-
{
|
34 |
-
// {{{ getPath()
|
35 |
-
|
36 |
-
/**
|
37 |
-
* Gets a path to a node
|
38 |
-
*
|
39 |
-
* Pass in the child node and will recurse up the XML tree to print out
|
40 |
-
* the path in the tree to that node
|
41 |
-
*
|
42 |
-
* <config>
|
43 |
-
* <path>
|
44 |
-
* <to>
|
45 |
-
* <node>
|
46 |
-
* Node Value
|
47 |
-
* </node>
|
48 |
-
* </to>
|
49 |
-
* </path>
|
50 |
-
* </config>
|
51 |
-
*
|
52 |
-
* If you pass in the "node" object, this will print out
|
53 |
-
* config/path/to/node/
|
54 |
-
*
|
55 |
-
* @param SimpleXmlElement $element Child element to find path to
|
56 |
-
*
|
57 |
-
* @return string
|
58 |
-
* @access public
|
59 |
-
*/
|
60 |
-
public function getPath(SimpleXmlElement $element);
|
61 |
-
|
62 |
-
// }}}
|
63 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Test/Config/Config.php
DELETED
@@ -1,259 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Bronto_ConflictChecker_Test_Config_Config
|
3 |
-
extends EcomDev_PHPUnit_Test_Case_Config
|
4 |
-
{
|
5 |
-
// {{{ blocksProvider()
|
6 |
-
|
7 |
-
public function blocksProvider()
|
8 |
-
{
|
9 |
-
return array(
|
10 |
-
array('bronto_conflictchecker/adminhtml_system_config_conflictchecker', 'Bronto_ConflictChecker_Block_Adminhtml_System_Config_Conflictchecker'),
|
11 |
-
);
|
12 |
-
}
|
13 |
-
|
14 |
-
// }}}
|
15 |
-
// {{{ resourceModelProvider()
|
16 |
-
|
17 |
-
public function resourceModelProvider()
|
18 |
-
{
|
19 |
-
return array(
|
20 |
-
array('bronto_conflictchecker/mysql4_core_config', 'Bronto_ConflictChecker_Model_Mysql4_Core_Config'),
|
21 |
-
array('bronto_conflictchecker/resource_core_config', 'Bronto_ConflictChecker_Model_Resource_Core_Config'),
|
22 |
-
);
|
23 |
-
}
|
24 |
-
|
25 |
-
// }}}
|
26 |
-
// {{{ modelsProvider()
|
27 |
-
|
28 |
-
public function modelsProvider()
|
29 |
-
{
|
30 |
-
return array(
|
31 |
-
array('bronto_conflictchecker/core_config_element', 'Bronto_ConflictChecker_Model_Core_Config_Element'),
|
32 |
-
array('bronto_conflictchecker/core_config_base', 'Bronto_ConflictChecker_Model_Core_Config_Base'),
|
33 |
-
array('bronto_conflictchecker/core_config', 'Bronto_ConflictChecker_Model_Core_Config'),
|
34 |
-
array('bronto_conflictchecker/config_blocks', 'Bronto_ConflictChecker_Model_Config_Blocks'),
|
35 |
-
array('bronto_conflictchecker/config_printer', 'Bronto_ConflictChecker_Model_Config_Printer'),
|
36 |
-
array('bronto_conflictchecker/config_checker', 'Bronto_ConflictChecker_Model_Config_Checker'),
|
37 |
-
array('bronto_conflictchecker/config_configabstract', 'Bronto_ConflictChecker_Model_Config_Configabstract'),
|
38 |
-
array('bronto_conflictchecker/config_configinterface', 'Bronto_ConflictChecker_Model_Config_Configinterface'),
|
39 |
-
array('bronto_conflictchecker/config_datastore', 'Bronto_ConflictChecker_Model_Config_Datastore'),
|
40 |
-
array('bronto_conflictchecker/config_helpers', 'Bronto_ConflictChecker_Model_Config_Helpers'),
|
41 |
-
array('bronto_conflictchecker/config_models', 'Bronto_ConflictChecker_Model_Config_Models'),
|
42 |
-
array('bronto_conflictchecker/config_printer', 'Bronto_ConflictChecker_Model_Config_Printer'),
|
43 |
-
array('bronto_conflictchecker/config_resources', 'Bronto_ConflictChecker_Model_Config_Resources'),
|
44 |
-
);
|
45 |
-
}
|
46 |
-
|
47 |
-
// }}}
|
48 |
-
// {{{ helpersProvider()
|
49 |
-
|
50 |
-
public function helpersProvider()
|
51 |
-
{
|
52 |
-
return array(
|
53 |
-
array('bronto_conflictchecker/data', 'Bronto_ConflictChecker_Helper_Data'),
|
54 |
-
);
|
55 |
-
}
|
56 |
-
|
57 |
-
// }}}
|
58 |
-
// {{{ observersProvider()
|
59 |
-
|
60 |
-
public function observersProvider()
|
61 |
-
{
|
62 |
-
return array(
|
63 |
-
/*array('global', 'customer_save_before', 'user/observer', 'accountUpgrade'),*/
|
64 |
-
);
|
65 |
-
}
|
66 |
-
|
67 |
-
// }}}
|
68 |
-
// {{{ definedLayoutFilesProvider()
|
69 |
-
|
70 |
-
public function definedLayoutFilesProvider()
|
71 |
-
{
|
72 |
-
return array(
|
73 |
-
/*array('frontend', 'bronto/user.xml'),*/
|
74 |
-
);
|
75 |
-
}
|
76 |
-
|
77 |
-
// }}}
|
78 |
-
// {{{ themeLayoutFilesExistProvider()
|
79 |
-
|
80 |
-
public function themeLayoutFilesExistProvider()
|
81 |
-
{
|
82 |
-
return array(
|
83 |
-
/*array('frontend', 'bronto/user.xml', 'adsinc', 'adsinc'),*/
|
84 |
-
);
|
85 |
-
}
|
86 |
-
|
87 |
-
// }}}
|
88 |
-
|
89 |
-
public function dependsProvider()
|
90 |
-
{
|
91 |
-
return array(
|
92 |
-
array('Bronto_Common'),
|
93 |
-
);
|
94 |
-
}
|
95 |
-
|
96 |
-
// {{{ assertConflictCheckerModuleInLocalCodePool()
|
97 |
-
|
98 |
-
|
99 |
-
/**
|
100 |
-
* @test
|
101 |
-
* @group amd
|
102 |
-
* @group config
|
103 |
-
*/
|
104 |
-
public function assertCommonModuleVersionGreaterThanOrEquals()
|
105 |
-
{
|
106 |
-
$this->assertModuleVersionGreaterThanOrEquals('0.1.0');
|
107 |
-
}
|
108 |
-
|
109 |
-
|
110 |
-
/**
|
111 |
-
* @test
|
112 |
-
* @group jmk
|
113 |
-
* @group config
|
114 |
-
*/
|
115 |
-
public function assertConflictCheckerModuleInCommunityCodePool()
|
116 |
-
{
|
117 |
-
$this->assertModuleCodePool('community');
|
118 |
-
}
|
119 |
-
|
120 |
-
// }}}
|
121 |
-
|
122 |
-
/**
|
123 |
-
* Note: Switched to NotDepends to ensure this module doesn't become dependent upon common
|
124 |
-
* @test
|
125 |
-
* @group amd
|
126 |
-
* @group config
|
127 |
-
* @dataProvider dependsProvider
|
128 |
-
*/
|
129 |
-
public function assertConflictCheckerNotDepends(
|
130 |
-
$requiredModuleName
|
131 |
-
) {
|
132 |
-
$this->assertModuleNotDepends($requiredModuleName);
|
133 |
-
}
|
134 |
-
|
135 |
-
// {{{ assertConflictCheckerModelAliases()
|
136 |
-
|
137 |
-
/**
|
138 |
-
* @test
|
139 |
-
* @group jmk
|
140 |
-
* @group config
|
141 |
-
* @dataProvider modelsProvider
|
142 |
-
*/
|
143 |
-
public function assertConflictCheckerModelAliases(
|
144 |
-
$classAlias,
|
145 |
-
$expectedClassName
|
146 |
-
) {
|
147 |
-
$this->assertModelAlias($classAlias, $expectedClassName);
|
148 |
-
}
|
149 |
-
|
150 |
-
// }}}
|
151 |
-
// {{{ assertConflictCheckerResourceModelAliases()
|
152 |
-
|
153 |
-
/**
|
154 |
-
* test
|
155 |
-
* @group jmk
|
156 |
-
* @group config
|
157 |
-
* @dataProvider resourceModelProvider
|
158 |
-
*/
|
159 |
-
public function assertConflictCheckerResourceModelAliases(
|
160 |
-
$classAlias,
|
161 |
-
$expectedClassName
|
162 |
-
) {
|
163 |
-
$this->assertResourceModelAlias($classAlias, $expectedClassName);
|
164 |
-
}
|
165 |
-
|
166 |
-
// }}}
|
167 |
-
// {{{ assertConflictCheckerBlockAliases()
|
168 |
-
|
169 |
-
/**
|
170 |
-
* @test
|
171 |
-
* @group jmk
|
172 |
-
* @group config
|
173 |
-
* @dataProvider blocksProvider
|
174 |
-
*/
|
175 |
-
public function assertConflictCheckerBlockAliases(
|
176 |
-
$classAlias,
|
177 |
-
$expectedClassName
|
178 |
-
) {
|
179 |
-
$this->assertBlockAlias($classAlias, $expectedClassName);
|
180 |
-
}
|
181 |
-
|
182 |
-
// }}}
|
183 |
-
// {{{ assertConflictCheckerHelperAliases()
|
184 |
-
|
185 |
-
/**
|
186 |
-
* @test
|
187 |
-
* @group jmk
|
188 |
-
* @group config
|
189 |
-
* @dataProvider helpersProvider
|
190 |
-
*/
|
191 |
-
public function assertConflictCheckerHelperAliases(
|
192 |
-
$classAlias,
|
193 |
-
$expectedClassName
|
194 |
-
) {
|
195 |
-
$this->assertHelperAlias($classAlias, $expectedClassName);
|
196 |
-
}
|
197 |
-
|
198 |
-
// }}}
|
199 |
-
// {{{ assertConflictCheckerEventObserversDefined()
|
200 |
-
|
201 |
-
/**
|
202 |
-
* test
|
203 |
-
* @group config
|
204 |
-
* @group jmk
|
205 |
-
* @dataProvider observersProvider
|
206 |
-
*/
|
207 |
-
public function assertConflictCheckerEventObserversDefined(
|
208 |
-
$area,
|
209 |
-
$eventName,
|
210 |
-
$observerClassAlias,
|
211 |
-
$observerMethod
|
212 |
-
) {
|
213 |
-
$this->assertEventObserverDefined(
|
214 |
-
$area,
|
215 |
-
$eventName,
|
216 |
-
$observerClassAlias,
|
217 |
-
$observerMethod
|
218 |
-
);
|
219 |
-
}
|
220 |
-
|
221 |
-
// }}}
|
222 |
-
// {{{ assertConflictCheckerLayoutFileDefined()
|
223 |
-
|
224 |
-
/**
|
225 |
-
* test
|
226 |
-
* @group config
|
227 |
-
* @group jmk
|
228 |
-
* @dataProvider definedLayoutFilesProvider
|
229 |
-
*/
|
230 |
-
public function assertConflictCheckerLayoutFileDefined($area, $expectedFileName)
|
231 |
-
{
|
232 |
-
$this->assertLayoutFileDefined($area, $expectedFileName);
|
233 |
-
}
|
234 |
-
|
235 |
-
// }}}
|
236 |
-
// {{{ assertConflictCheckerLayoutFileExistsForDefaultTheme()
|
237 |
-
|
238 |
-
/**
|
239 |
-
* test
|
240 |
-
* @group config
|
241 |
-
* @group jmk
|
242 |
-
* @dataProvider themeLayoutFilesExistProvider
|
243 |
-
*/
|
244 |
-
public function assertConflictCheckerLayoutFileExistsForDefaultTheme(
|
245 |
-
$area,
|
246 |
-
$filename,
|
247 |
-
$theme,
|
248 |
-
$designPackage
|
249 |
-
) {
|
250 |
-
$this->assertLayoutFileExistsInTheme(
|
251 |
-
$area,
|
252 |
-
$filename,
|
253 |
-
$theme,
|
254 |
-
$designPackage
|
255 |
-
);
|
256 |
-
}
|
257 |
-
|
258 |
-
// }}}
|
259 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Test/Model/Path/Locator/Array.php
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Bronto_ConflictChecker_Test_Model_Path_Locator_Array
|
3 |
-
extends EcomDev_PHPUnit_Test_Case
|
4 |
-
{
|
5 |
-
// {{{ getPathWithArrayShouldReturnPathAsString()
|
6 |
-
|
7 |
-
/**
|
8 |
-
* @test
|
9 |
-
* @group jmk
|
10 |
-
* @group model
|
11 |
-
*/
|
12 |
-
public function getPathWithArrayShouldReturnPathAsString()
|
13 |
-
{
|
14 |
-
$locator = new Bronto_ConflictChecker_Model_Path_Locator_Array(array());
|
15 |
-
|
16 |
-
$xmlString = "<config><path><to><node>node value</node></to></path></config>";
|
17 |
-
$xml = new Bronto_ConflictChecker_Model_Lib_Varien_Simplexml_Element($xmlString);
|
18 |
-
list($element) = $xml->xpath('/config/path/to/node');
|
19 |
-
|
20 |
-
$path = $locator->getPath($element);
|
21 |
-
$this->assertEquals('config/path/to/node/', $locator->getpath($element));
|
22 |
-
}
|
23 |
-
|
24 |
-
// }}}
|
25 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Test/Model/Path/Locator/Factory.php
DELETED
@@ -1,21 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Bronto_ConflictChecker_Test_Model_Path_Locator_Factory
|
4 |
-
extends EcomDev_PHPUnit_Test_Case
|
5 |
-
{
|
6 |
-
// {{{ getLocatorShouldReturnCorrectModel()
|
7 |
-
|
8 |
-
/**
|
9 |
-
* @test
|
10 |
-
* @group jmk
|
11 |
-
* @group model
|
12 |
-
*/
|
13 |
-
public function getLocatorShouldReturnCorrectModel()
|
14 |
-
{
|
15 |
-
$factory = new Bronto_ConflictChecker_Model_Path_Locator_Factory;
|
16 |
-
|
17 |
-
$locator = $factory->getLocator();
|
18 |
-
}
|
19 |
-
|
20 |
-
// }}}
|
21 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/Test/Model/Path/Locator/Stack.php
DELETED
@@ -1,25 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Bronto_ConflictChecker_Test_Model_Path_Locator_Stack
|
3 |
-
extends EcomDev_PHPUnit_Test_Case
|
4 |
-
{
|
5 |
-
// {{{ getPathWithStackShouldReturnPathAsString()
|
6 |
-
|
7 |
-
/**
|
8 |
-
* @test
|
9 |
-
* @group jmk
|
10 |
-
* @group model
|
11 |
-
*/
|
12 |
-
public function getPathWithStackShouldReturnPathAsString()
|
13 |
-
{
|
14 |
-
$locator = new Bronto_ConflictChecker_Model_Path_Locator_Stack(new SplStack);
|
15 |
-
|
16 |
-
$xmlString = "<config><path><to><node>node value</node></to></path></config>";
|
17 |
-
$xml = new Bronto_ConflictChecker_Model_Lib_Varien_Simplexml_Element($xmlString);
|
18 |
-
list($element) = $xml->xpath('/config/path/to/node');
|
19 |
-
|
20 |
-
$path = $locator->getPath($element);
|
21 |
-
$this->assertEquals('config/path/to/node/', $locator->getpath($element));
|
22 |
-
}
|
23 |
-
|
24 |
-
// }}}
|
25 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/etc/adminhtml.xml
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* @category Bronto
|
5 |
-
* @package Bronto_ConflictChecker
|
6 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticBT.com>
|
7 |
-
* @copyright 2012 Atlantic BT
|
8 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
9 |
-
*/
|
10 |
-
-->
|
11 |
-
<config>
|
12 |
-
<acl>
|
13 |
-
<resources>
|
14 |
-
<admin>
|
15 |
-
<children>
|
16 |
-
<system>
|
17 |
-
<children>
|
18 |
-
<config>
|
19 |
-
<children>
|
20 |
-
<conflicted_modules translate="title" module="bronto_conflictchecker">
|
21 |
-
<title>Conflict Checker</title>
|
22 |
-
<sort_order>0</sort_order>
|
23 |
-
</conflicted_modules>
|
24 |
-
</children>
|
25 |
-
</config>
|
26 |
-
</children>
|
27 |
-
</system>
|
28 |
-
</children>
|
29 |
-
</admin>
|
30 |
-
</resources>
|
31 |
-
</acl>
|
32 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/etc/config.xml
DELETED
@@ -1,60 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* @category Bronto
|
5 |
-
* @package Bronto_ConflictChecker
|
6 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
7 |
-
* @copyright 2012 Atlantic BT
|
8 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
9 |
-
*/
|
10 |
-
-->
|
11 |
-
<config>
|
12 |
-
<modules>
|
13 |
-
<Bronto_ConflictChecker>
|
14 |
-
<version>0.1.0</version>
|
15 |
-
</Bronto_ConflictChecker>
|
16 |
-
</modules>
|
17 |
-
|
18 |
-
<global>
|
19 |
-
<blocks>
|
20 |
-
<bronto_conflictchecker>
|
21 |
-
<class>Bronto_ConflictChecker_Block</class>
|
22 |
-
</bronto_conflictchecker>
|
23 |
-
</blocks>
|
24 |
-
|
25 |
-
<helpers>
|
26 |
-
<bronto_conflictchecker>
|
27 |
-
<class>Bronto_ConflictChecker_Helper</class>
|
28 |
-
</bronto_conflictchecker>
|
29 |
-
</helpers>
|
30 |
-
|
31 |
-
<models>
|
32 |
-
<bronto_conflictchecker>
|
33 |
-
<class>Bronto_ConflictChecker_Model</class>
|
34 |
-
<resourceModel>bronto_conflictchecker_mysql4</resourceModel>
|
35 |
-
</bronto_conflictchecker>
|
36 |
-
<bronto_conflictchecker_mysql4>
|
37 |
-
<class>Bronto_ConflictChecker_Model_Mysql4</class>
|
38 |
-
</bronto_conflictchecker_mysql4>
|
39 |
-
</models>
|
40 |
-
</global>
|
41 |
-
<admin>
|
42 |
-
<routers>
|
43 |
-
<adminhtml>
|
44 |
-
<args>
|
45 |
-
<modules>
|
46 |
-
<bronto_conflictchecker before="Mage_Adminhtml">Bronto_ConflictChecker_Adminhtml</bronto_conflictchecker>
|
47 |
-
</modules>
|
48 |
-
</args>
|
49 |
-
</adminhtml>
|
50 |
-
</routers>
|
51 |
-
</admin>
|
52 |
-
|
53 |
-
<phpunit>
|
54 |
-
<suite>
|
55 |
-
<modules>
|
56 |
-
<Bronto_ConflictChecker />
|
57 |
-
</modules>
|
58 |
-
</suite>
|
59 |
-
</phpunit>
|
60 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/ConflictChecker/etc/system.xml
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<sections>
|
4 |
-
<conflicted_modules translate="label" module="core">
|
5 |
-
<label>Conflict Checker</label>
|
6 |
-
<tab>bronto</tab>
|
7 |
-
<frontend_type>text</frontend_type>
|
8 |
-
<sort_order>1100</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_conflictchecker/adminhtml_system_config_about</frontend_model>
|
16 |
-
<sort_order>1</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 |
-
<conflictchecker>
|
22 |
-
<frontend_type>text</frontend_type>
|
23 |
-
<frontend_model>bronto_conflictchecker/adminhtml_system_config_conflictchecker</frontend_model>
|
24 |
-
<sort_order>2</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 |
-
</conflictchecker>
|
29 |
-
</groups>
|
30 |
-
</conflicted_modules>
|
31 |
-
</sections>
|
32 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/About.php
CHANGED
@@ -15,5 +15,5 @@ class Bronto_Customer_Block_Adminhtml_System_Config_About extends Bronto_Common_
|
|
15 |
/**
|
16 |
* @var string
|
17 |
*/
|
18 |
-
protected $_name
|
19 |
}
|
15 |
/**
|
16 |
* @var string
|
17 |
*/
|
18 |
+
protected $_name = 'Bronto Customer Import for Magento';
|
19 |
}
|
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Cron.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
*/
|
8 |
class Bronto_Customer_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Block_Adminhtml_System_Config_Cron
|
9 |
{
|
10 |
-
protected $_jobCode
|
11 |
protected $_hasProgressBar = true;
|
12 |
|
13 |
/**
|
@@ -15,10 +15,7 @@ class Bronto_Customer_Block_Adminhtml_System_Config_Cron extends Bronto_Common_B
|
|
15 |
*/
|
16 |
protected function _prepareLayout()
|
17 |
{
|
18 |
-
$
|
19 |
-
if ($missingCustomers > 0) {
|
20 |
-
$this->addButton($this->getLayout()->createBlock('bronto_customer/adminhtml_widget_button_sync'));
|
21 |
-
}
|
22 |
$this->addButton($this->getLayout()->createBlock('bronto_customer/adminhtml_widget_button_reset'));
|
23 |
$this->addButton($this->getLayout()->createBlock('bronto_customer/adminhtml_widget_button_run'));
|
24 |
|
@@ -31,9 +28,8 @@ class Bronto_Customer_Block_Adminhtml_System_Config_Cron extends Bronto_Common_B
|
|
31 |
protected function getProgressBarTotal()
|
32 |
{
|
33 |
return $this->getCustomerResourceCollection()
|
34 |
-
->addBrontoNotSuppressedFilter()
|
35 |
-
->getSize()
|
36 |
-
;
|
37 |
}
|
38 |
|
39 |
/**
|
@@ -47,14 +43,52 @@ class Bronto_Customer_Block_Adminhtml_System_Config_Cron extends Bronto_Common_B
|
|
47 |
->getSize();
|
48 |
}
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
/**
|
51 |
* @return Bronto_Customer_Model_Mysql4_Queue_Collection
|
52 |
*/
|
53 |
protected function getCustomerResourceCollection()
|
54 |
{
|
55 |
$collection = Mage::getModel('bronto_customer/queue')->getCollection();
|
56 |
-
$storeIds
|
57 |
-
|
58 |
if ($storeIds) {
|
59 |
$collection->addStoreFilter($storeIds);
|
60 |
}
|
7 |
*/
|
8 |
class Bronto_Customer_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Block_Adminhtml_System_Config_Cron
|
9 |
{
|
10 |
+
protected $_jobCode = 'bronto_customer_import';
|
11 |
protected $_hasProgressBar = true;
|
12 |
|
13 |
/**
|
15 |
*/
|
16 |
protected function _prepareLayout()
|
17 |
{
|
18 |
+
$this->addButton($this->getLayout()->createBlock('bronto_customer/adminhtml_widget_button_sync'));
|
|
|
|
|
|
|
19 |
$this->addButton($this->getLayout()->createBlock('bronto_customer/adminhtml_widget_button_reset'));
|
20 |
$this->addButton($this->getLayout()->createBlock('bronto_customer/adminhtml_widget_button_run'));
|
21 |
|
28 |
protected function getProgressBarTotal()
|
29 |
{
|
30 |
return $this->getCustomerResourceCollection()
|
31 |
+
// ->addBrontoNotSuppressedFilter()
|
32 |
+
->getSize();
|
|
|
33 |
}
|
34 |
|
35 |
/**
|
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 |
+
* @return int
|
60 |
+
*/
|
61 |
+
protected function getProgressBarDisabled()
|
62 |
+
{
|
63 |
+
$collection = Mage::getModel('bronto_customer/queue')->getCollection();
|
64 |
+
$storeIds = Mage::helper('bronto_customer')->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_Customer_Helper_Data::XML_PATH_ENABLED, $storeId)) {
|
72 |
+
unset($storeIds[$key]);
|
73 |
+
}
|
74 |
+
}
|
75 |
+
$collection->addStoreFilter($storeIds);
|
76 |
+
|
77 |
+
return $collection->addBrontoNotImportedFilter()
|
78 |
+
->addBrontoNotSuppressedFilter()
|
79 |
+
->getSize();
|
80 |
+
}
|
81 |
+
return 0;
|
82 |
+
}
|
83 |
+
|
84 |
/**
|
85 |
* @return Bronto_Customer_Model_Mysql4_Queue_Collection
|
86 |
*/
|
87 |
protected function getCustomerResourceCollection()
|
88 |
{
|
89 |
$collection = Mage::getModel('bronto_customer/queue')->getCollection();
|
90 |
+
$storeIds = Mage::helper('bronto_customer')->getStoreIds();
|
91 |
+
|
92 |
if ($storeIds) {
|
93 |
$collection->addStoreFilter($storeIds);
|
94 |
}
|
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Fieldset/Attributes.php
CHANGED
@@ -5,24 +5,28 @@
|
|
5 |
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
* @version 1.0.0
|
7 |
*/
|
8 |
-
abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attributes extends
|
9 |
-
{
|
10 |
protected $_ignoreAttributes = array();
|
11 |
protected $_configPath = '';
|
12 |
protected $_dummyElement;
|
13 |
protected $_dummyNewElement;
|
14 |
protected $_fieldRenderer;
|
15 |
protected $_values;
|
16 |
-
|
17 |
public function render(Varien_Data_Form_Element_Abstract $element)
|
18 |
{
|
|
|
|
|
|
|
|
|
19 |
$html = $this->_getHeaderHtml($element);
|
20 |
-
|
21 |
// Render Existing elements
|
22 |
foreach ($element->getSortedElements() as $field) {
|
23 |
-
$html.= $field->toHtml();
|
24 |
}
|
25 |
-
|
26 |
// Get Array of existing fields
|
27 |
$skips = $this->_getUsedAttributeCodes($element);
|
28 |
$order = 100;
|
@@ -32,26 +36,26 @@ abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attri
|
|
32 |
if (in_array($_attributeCode, $skips)) {
|
33 |
continue;
|
34 |
} else {
|
35 |
-
|
36 |
try {
|
37 |
-
$order = $order+5;
|
38 |
-
$html.= $this->_getFieldHtml($element, $_attribute, $order);
|
39 |
-
} catch(Exception $e) {
|
40 |
Mage::helper('bronto_customer')->writeDebug('Creating field failed: ' . $e->getMessage());
|
41 |
-
|
42 |
continue;
|
43 |
}
|
44 |
-
|
45 |
}
|
46 |
}
|
47 |
-
|
48 |
$html .= $this->_getFooterHtml($element);
|
49 |
-
|
50 |
return $html;
|
51 |
}
|
52 |
-
|
53 |
/**
|
54 |
-
* this creates a dummy element so you can say if your config fields are available on default and website level -
|
55 |
* you can skip this and add the scope for each element in _getFieldHtml method
|
56 |
* @return type
|
57 |
*/
|
@@ -59,20 +63,20 @@ abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attri
|
|
59 |
{
|
60 |
if (empty($this->_dummyElement)) {
|
61 |
$this->_dummyElement = new Varien_Object(array(
|
62 |
-
'sort_order'
|
63 |
-
'frontend_type'
|
64 |
-
'frontend_model'
|
65 |
-
'backend_model'
|
66 |
-
'source_model'
|
67 |
-
'show_in_default'
|
68 |
-
'show_in_website'
|
69 |
-
'show_in_store'
|
70 |
));
|
71 |
}
|
72 |
-
|
73 |
return $this->_dummyElement;
|
74 |
}
|
75 |
-
|
76 |
/**
|
77 |
* Get Dummy Element for 'Create New...' form
|
78 |
* @param int $order
|
@@ -82,17 +86,17 @@ abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attri
|
|
82 |
{
|
83 |
if (empty($this->_dummyNewElement)) {
|
84 |
$this->_dummyNewElement = new Varien_Object(array(
|
85 |
-
'sort_order'
|
86 |
-
'frontend_type'
|
87 |
-
'backend_model'
|
88 |
-
'show_in_default'
|
89 |
-
'show_in_website'
|
90 |
-
'show_in_store'
|
91 |
));
|
92 |
}
|
93 |
return $this->_dummyNewElement;
|
94 |
}
|
95 |
-
|
96 |
/**
|
97 |
* this sets the fields renderer. If you have a custom renderer you can change this.
|
98 |
* @return type
|
@@ -104,7 +108,7 @@ abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attri
|
|
104 |
}
|
105 |
return $this->_fieldRenderer;
|
106 |
}
|
107 |
-
|
108 |
/**
|
109 |
* this actually gets the html for a field
|
110 |
* @param Varien_Data_Form_Element_Abstract $fieldset
|
@@ -115,22 +119,28 @@ abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attri
|
|
115 |
protected function _getFieldHtml(Varien_Data_Form_Element_Abstract $fieldset, Mage_Eav_Model_Entity_Attribute $attribute, $order)
|
116 |
{
|
117 |
// Create Select Field
|
118 |
-
$e
|
119 |
$field = $this->_createField($fieldset, $e, $attribute);
|
120 |
-
|
|
|
|
|
|
|
121 |
// Create New Field
|
122 |
-
$en
|
123 |
$newField = $this->_createField($fieldset, $en, $attribute, 'newfield');
|
124 |
-
|
|
|
|
|
|
|
125 |
// Define Field Dependencies
|
126 |
$this->getForm()->getChild('element_dependense')
|
127 |
->addFieldMap($field->getHtmlId(), $field->getName())
|
128 |
->addFieldMap($newField->getHtmlId(), $newField->getName())
|
129 |
->addFieldDependence($newField->getName(), $field->getName(), '_new_');
|
130 |
-
|
131 |
return $field->toHtml() . $newField->toHtml();
|
132 |
}
|
133 |
-
|
134 |
/**
|
135 |
* Create Field and Return it
|
136 |
* @param Varien_Data_Form_Element_Abstract $fieldset
|
@@ -140,43 +150,43 @@ abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attri
|
|
140 |
* @return Varien_Data_Form_Element_Abstract
|
141 |
*/
|
142 |
protected function _createField(
|
143 |
-
Varien_Data_Form_Element_Abstract $fieldset,
|
144 |
-
Varien_Object $e,
|
145 |
-
Mage_Eav_Model_Entity_Attribute $attribute,
|
146 |
$fieldStep = 'standard'
|
147 |
)
|
148 |
{
|
149 |
// Get Config Data
|
150 |
$configData = $this->getConfigData();
|
151 |
if ('' == $attribute->getFrontendLabel()) {
|
152 |
-
|
153 |
}
|
154 |
// Define Attribute Code
|
155 |
$attributeCode = $attribute->getAttributeCode();
|
156 |
$attributeCode = ($fieldStep == 'newfield') ? "dynamic_new_{$attributeCode}" : $attributeCode;
|
157 |
-
|
158 |
// Get Attribute Data and Inheritance
|
159 |
$path = $this->_configPath . $attributeCode;
|
160 |
if (isset($configData[$path])) {
|
161 |
$data = $configData[$path];
|
162 |
$inherit = false;
|
163 |
} else {
|
164 |
-
$data = (string)$this->getForm()->
|
165 |
$inherit = true;
|
166 |
}
|
167 |
-
|
168 |
// Get field Renderer
|
169 |
if ($e->frontend_model) {
|
170 |
$fieldRenderer = Mage::getBlockSingleton((string)$e->frontend_model);
|
171 |
} else {
|
172 |
$fieldRenderer = $this->_getFieldRenderer();
|
173 |
}
|
174 |
-
|
175 |
// Define Type, Name, and Label
|
176 |
-
$fieldType
|
177 |
-
$name
|
178 |
-
$label
|
179 |
-
|
180 |
// Pass through backend model in case it needs to modify value
|
181 |
if ($e->backend_model) {
|
182 |
$model = Mage::getModel((string)$e->backend_model);
|
@@ -186,35 +196,36 @@ abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attri
|
|
186 |
$model->setPath($path)->setValue($data)->afterLoad();
|
187 |
$data = $model->getValue();
|
188 |
}
|
189 |
-
|
190 |
// Select Field for Existing attributes.
|
191 |
$field = $fieldset->addField($attributeCode, $fieldType,
|
192 |
array(
|
193 |
-
'name'
|
194 |
-
'label'
|
195 |
-
'value'
|
196 |
-
'inherit'
|
197 |
-
'field_config'
|
198 |
-
'scope'
|
199 |
-
'scopeId'
|
200 |
-
'scope_label'
|
201 |
'can_use_default_value' => $this->getForm()->canUseDefaultValue((int)$e->show_in_default),
|
202 |
'can_use_website_value' => $this->getForm()->canUseWebsiteValue((int)$e->show_in_website),
|
|
|
203 |
));
|
204 |
-
|
205 |
// Add Validation
|
206 |
if ($e->validate) {
|
207 |
$field->addClass($e->validate);
|
208 |
}
|
209 |
-
|
210 |
// Determine if value can be empty
|
211 |
if (isset($e->frontend_type) && 'multiselect' === (string)$e->frontend_type && isset($e->can_be_empty)) {
|
212 |
$field->setCanBeEmpty(true);
|
213 |
}
|
214 |
-
|
215 |
// Set Field Renderer
|
216 |
$field->setRenderer($fieldRenderer);
|
217 |
-
|
218 |
// Use Source Model to define available options
|
219 |
if ($e->source_model) {
|
220 |
$sourceModel = Mage::getSingleton((string)$e->source_model);
|
@@ -223,12 +234,12 @@ abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attri
|
|
223 |
}
|
224 |
$field->setValues($sourceModel->toOptionArray());
|
225 |
}
|
226 |
-
|
227 |
return $field;
|
228 |
}
|
229 |
-
|
230 |
abstract protected function _getAttributes();
|
231 |
-
|
232 |
/**
|
233 |
* @param Varien_Data_Form_Element_Fieldset $fieldset
|
234 |
* @return array<string>
|
@@ -244,7 +255,7 @@ abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attri
|
|
244 |
$usedAttributeCodes[] = $matches[1];
|
245 |
}
|
246 |
}
|
247 |
-
|
248 |
// Merge in ignored attribute codes
|
249 |
$usedAttributeCodes = array_merge($usedAttributeCodes, $this->_ignoreAttributes);
|
250 |
|
5 |
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
* @version 1.0.0
|
7 |
*/
|
8 |
+
abstract class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attributes extends Bronto_Common_Block_Adminhtml_System_Config_Form_Fieldset
|
9 |
+
{
|
10 |
protected $_ignoreAttributes = array();
|
11 |
protected $_configPath = '';
|
12 |
protected $_dummyElement;
|
13 |
protected $_dummyNewElement;
|
14 |
protected $_fieldRenderer;
|
15 |
protected $_values;
|
16 |
+
|
17 |
public function render(Varien_Data_Form_Element_Abstract $element)
|
18 |
{
|
19 |
+
if (!$this->helper('bronto_customer')->isEnabled()) {
|
20 |
+
return;
|
21 |
+
}
|
22 |
+
|
23 |
$html = $this->_getHeaderHtml($element);
|
24 |
+
|
25 |
// Render Existing elements
|
26 |
foreach ($element->getSortedElements() as $field) {
|
27 |
+
$html .= $field->toHtml();
|
28 |
}
|
29 |
+
|
30 |
// Get Array of existing fields
|
31 |
$skips = $this->_getUsedAttributeCodes($element);
|
32 |
$order = 100;
|
36 |
if (in_array($_attributeCode, $skips)) {
|
37 |
continue;
|
38 |
} else {
|
39 |
+
|
40 |
try {
|
41 |
+
$order = $order + 5;
|
42 |
+
$html .= $this->_getFieldHtml($element, $_attribute, $order);
|
43 |
+
} catch (Exception $e) {
|
44 |
Mage::helper('bronto_customer')->writeDebug('Creating field failed: ' . $e->getMessage());
|
45 |
+
|
46 |
continue;
|
47 |
}
|
48 |
+
|
49 |
}
|
50 |
}
|
51 |
+
|
52 |
$html .= $this->_getFooterHtml($element);
|
53 |
+
|
54 |
return $html;
|
55 |
}
|
56 |
+
|
57 |
/**
|
58 |
+
* this creates a dummy element so you can say if your config fields are available on default and website level -
|
59 |
* you can skip this and add the scope for each element in _getFieldHtml method
|
60 |
* @return type
|
61 |
*/
|
63 |
{
|
64 |
if (empty($this->_dummyElement)) {
|
65 |
$this->_dummyElement = new Varien_Object(array(
|
66 |
+
'sort_order' => $order,
|
67 |
+
'frontend_type' => 'select',
|
68 |
+
'frontend_model' => 'bronto_common/adminhtml_system_config_form_field',
|
69 |
+
'backend_model' => 'bronto_customer/system_config_backend_brontofield',
|
70 |
+
'source_model' => 'bronto_common/system_config_source_field',
|
71 |
+
'show_in_default' => 1,
|
72 |
+
'show_in_website' => 1,
|
73 |
+
'show_in_store' => 1,
|
74 |
));
|
75 |
}
|
76 |
+
|
77 |
return $this->_dummyElement;
|
78 |
}
|
79 |
+
|
80 |
/**
|
81 |
* Get Dummy Element for 'Create New...' form
|
82 |
* @param int $order
|
86 |
{
|
87 |
if (empty($this->_dummyNewElement)) {
|
88 |
$this->_dummyNewElement = new Varien_Object(array(
|
89 |
+
'sort_order' => $order,
|
90 |
+
'frontend_type' => 'text',
|
91 |
+
'backend_model' => 'bronto_customer/system_config_backend_newfield',
|
92 |
+
'show_in_default' => 1,
|
93 |
+
'show_in_website' => 1,
|
94 |
+
'show_in_store' => 1,
|
95 |
));
|
96 |
}
|
97 |
return $this->_dummyNewElement;
|
98 |
}
|
99 |
+
|
100 |
/**
|
101 |
* this sets the fields renderer. If you have a custom renderer you can change this.
|
102 |
* @return type
|
108 |
}
|
109 |
return $this->_fieldRenderer;
|
110 |
}
|
111 |
+
|
112 |
/**
|
113 |
* this actually gets the html for a field
|
114 |
* @param Varien_Data_Form_Element_Abstract $fieldset
|
119 |
protected function _getFieldHtml(Varien_Data_Form_Element_Abstract $fieldset, Mage_Eav_Model_Entity_Attribute $attribute, $order)
|
120 |
{
|
121 |
// Create Select Field
|
122 |
+
$e = $this->_getDummyElement($order);
|
123 |
$field = $this->_createField($fieldset, $e, $attribute);
|
124 |
+
if (!$field) {
|
125 |
+
return '';
|
126 |
+
}
|
127 |
+
|
128 |
// Create New Field
|
129 |
+
$en = $this->_getDummyNewElement($order + 1);
|
130 |
$newField = $this->_createField($fieldset, $en, $attribute, 'newfield');
|
131 |
+
if (!$newField) {
|
132 |
+
return '';
|
133 |
+
}
|
134 |
+
|
135 |
// Define Field Dependencies
|
136 |
$this->getForm()->getChild('element_dependense')
|
137 |
->addFieldMap($field->getHtmlId(), $field->getName())
|
138 |
->addFieldMap($newField->getHtmlId(), $newField->getName())
|
139 |
->addFieldDependence($newField->getName(), $field->getName(), '_new_');
|
140 |
+
|
141 |
return $field->toHtml() . $newField->toHtml();
|
142 |
}
|
143 |
+
|
144 |
/**
|
145 |
* Create Field and Return it
|
146 |
* @param Varien_Data_Form_Element_Abstract $fieldset
|
150 |
* @return Varien_Data_Form_Element_Abstract
|
151 |
*/
|
152 |
protected function _createField(
|
153 |
+
Varien_Data_Form_Element_Abstract $fieldset,
|
154 |
+
Varien_Object $e,
|
155 |
+
Mage_Eav_Model_Entity_Attribute $attribute,
|
156 |
$fieldStep = 'standard'
|
157 |
)
|
158 |
{
|
159 |
// Get Config Data
|
160 |
$configData = $this->getConfigData();
|
161 |
if ('' == $attribute->getFrontendLabel()) {
|
162 |
+
return false;
|
163 |
}
|
164 |
// Define Attribute Code
|
165 |
$attributeCode = $attribute->getAttributeCode();
|
166 |
$attributeCode = ($fieldStep == 'newfield') ? "dynamic_new_{$attributeCode}" : $attributeCode;
|
167 |
+
|
168 |
// Get Attribute Data and Inheritance
|
169 |
$path = $this->_configPath . $attributeCode;
|
170 |
if (isset($configData[$path])) {
|
171 |
$data = $configData[$path];
|
172 |
$inherit = false;
|
173 |
} else {
|
174 |
+
$data = (string)Mage::getConfig()->getNode(null, $this->getForm()->getScope(), $this->getForm()->getScopeCode())->descend($path);
|
175 |
$inherit = true;
|
176 |
}
|
177 |
+
|
178 |
// Get field Renderer
|
179 |
if ($e->frontend_model) {
|
180 |
$fieldRenderer = Mage::getBlockSingleton((string)$e->frontend_model);
|
181 |
} else {
|
182 |
$fieldRenderer = $this->_getFieldRenderer();
|
183 |
}
|
184 |
+
|
185 |
// Define Type, Name, and Label
|
186 |
+
$fieldType = (string)$e->frontend_type ? (string)$e->frontend_type : 'text';
|
187 |
+
$name = str_replace('_attrCode_', $attributeCode, $this->_fieldNameTemplate);
|
188 |
+
$label = ($fieldStep == 'newfield') ? "" : $attribute->getFrontendLabel();
|
189 |
+
|
190 |
// Pass through backend model in case it needs to modify value
|
191 |
if ($e->backend_model) {
|
192 |
$model = Mage::getModel((string)$e->backend_model);
|
196 |
$model->setPath($path)->setValue($data)->afterLoad();
|
197 |
$data = $model->getValue();
|
198 |
}
|
199 |
+
|
200 |
// Select Field for Existing attributes.
|
201 |
$field = $fieldset->addField($attributeCode, $fieldType,
|
202 |
array(
|
203 |
+
'name' => $name,
|
204 |
+
'label' => $label,
|
205 |
+
'value' => ($data === 0) ? '' : $data,
|
206 |
+
'inherit' => ($fieldStep == 'newfield') ? false : $inherit,
|
207 |
+
'field_config' => $e,
|
208 |
+
'scope' => $this->getForm()->getScope(),
|
209 |
+
'scopeId' => $this->getForm()->getScopeId(),
|
210 |
+
'scope_label' => '[STORE VIEW]',
|
211 |
'can_use_default_value' => $this->getForm()->canUseDefaultValue((int)$e->show_in_default),
|
212 |
'can_use_website_value' => $this->getForm()->canUseWebsiteValue((int)$e->show_in_website),
|
213 |
+
'can_use_store_value' => $this->getForm()->canUseWebsiteValue((int)$e->show_in_store),
|
214 |
));
|
215 |
+
|
216 |
// Add Validation
|
217 |
if ($e->validate) {
|
218 |
$field->addClass($e->validate);
|
219 |
}
|
220 |
+
|
221 |
// Determine if value can be empty
|
222 |
if (isset($e->frontend_type) && 'multiselect' === (string)$e->frontend_type && isset($e->can_be_empty)) {
|
223 |
$field->setCanBeEmpty(true);
|
224 |
}
|
225 |
+
|
226 |
// Set Field Renderer
|
227 |
$field->setRenderer($fieldRenderer);
|
228 |
+
|
229 |
// Use Source Model to define available options
|
230 |
if ($e->source_model) {
|
231 |
$sourceModel = Mage::getSingleton((string)$e->source_model);
|
234 |
}
|
235 |
$field->setValues($sourceModel->toOptionArray());
|
236 |
}
|
237 |
+
|
238 |
return $field;
|
239 |
}
|
240 |
+
|
241 |
abstract protected function _getAttributes();
|
242 |
+
|
243 |
/**
|
244 |
* @param Varien_Data_Form_Element_Fieldset $fieldset
|
245 |
* @return array<string>
|
255 |
$usedAttributeCodes[] = $matches[1];
|
256 |
}
|
257 |
}
|
258 |
+
|
259 |
// Merge in ignored attribute codes
|
260 |
$usedAttributeCodes = array_merge($usedAttributeCodes, $this->_ignoreAttributes);
|
261 |
|
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Fieldset/Attributes/Address.php
CHANGED
@@ -28,8 +28,9 @@ class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attributes_Add
|
|
28 |
'vat_request_date',
|
29 |
'vat_request_success',
|
30 |
);
|
31 |
-
|
32 |
protected $_configPath = Bronto_Customer_Helper_Data::XML_PREFIX_ADDRESS_ATTR;
|
|
|
33 |
protected $_fieldNameTemplate = 'groups[address_attributes][fields][_attrCode_][value]';
|
34 |
|
35 |
/**
|
28 |
'vat_request_date',
|
29 |
'vat_request_success',
|
30 |
);
|
31 |
+
|
32 |
protected $_configPath = Bronto_Customer_Helper_Data::XML_PREFIX_ADDRESS_ATTR;
|
33 |
+
protected $_idPath = 'bronto_customer_address_attributes_';
|
34 |
protected $_fieldNameTemplate = 'groups[address_attributes][fields][_attrCode_][value]';
|
35 |
|
36 |
/**
|
app/code/community/Bronto/Customer/Block/Adminhtml/System/Config/Form/Fieldset/Attributes/Customer.php
CHANGED
@@ -30,8 +30,9 @@ class Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attributes_Cus
|
|
30 |
'reward_warning_notification',
|
31 |
'disable_auto_group_change',
|
32 |
);
|
33 |
-
|
34 |
protected $_configPath = Bronto_Customer_Helper_Data::XML_PREFIX_CUSTOMER_ATTR;
|
|
|
35 |
protected $_fieldNameTemplate = 'groups[attributes][fields][_attrCode_][value]';
|
36 |
|
37 |
/**
|
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 |
/**
|
app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Reset.php
CHANGED
@@ -13,11 +13,15 @@ class Bronto_Customer_Block_Adminhtml_Widget_Button_Reset extends Mage_Adminhtml
|
|
13 |
protected function _construct()
|
14 |
{
|
15 |
$this->setLabel('Reset All Customers');
|
16 |
-
|
|
|
17 |
$this->setClass('delete');
|
18 |
|
19 |
-
if (!
|
20 |
$this->setDisabled(true)->setClass('disabled');
|
|
|
|
|
|
|
21 |
}
|
22 |
}
|
23 |
}
|
13 |
protected function _construct()
|
14 |
{
|
15 |
$this->setLabel('Reset All Customers');
|
16 |
+
|
17 |
+
$this->setOnClick("deleteConfirm('This will mark all customers as not-imported and will cause the importer to re-process each customer again.\\n\\nAre you sure you want to do this?', '" . Mage::helper('bronto_customer')->getScopeUrl('*/customer/reset') . "'); return false;");
|
18 |
$this->setClass('delete');
|
19 |
|
20 |
+
if (!Mage::helper('bronto_customer')->isModuleActive() || (!Mage::helper('bronto_customer')->isDebugEnabled() && !Mage::helper('bronto_customer')->isTestModeEnabled())) {
|
21 |
$this->setDisabled(true)->setClass('disabled');
|
22 |
+
if (!Mage::helper('bronto_customer')->isDebugEnabled()) {
|
23 |
+
$this->setTitle('Enable Debug in the General section to ' . $this->getLabel() . '.');
|
24 |
+
}
|
25 |
}
|
26 |
}
|
27 |
}
|
app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Run.php
CHANGED
@@ -13,9 +13,9 @@ class Bronto_Customer_Block_Adminhtml_Widget_Button_Run extends Mage_Adminhtml_B
|
|
13 |
protected function _construct()
|
14 |
{
|
15 |
$this->setLabel('Run Now');
|
16 |
-
$this->setOnClick("setLocation('" . Mage::helper('
|
17 |
|
18 |
-
if (!
|
19 |
$this->setDisabled(true)->setClass('disabled');
|
20 |
}
|
21 |
}
|
13 |
protected function _construct()
|
14 |
{
|
15 |
$this->setLabel('Run Now');
|
16 |
+
$this->setOnClick("setLocation('" . Mage::helper('bronto_customer')->getScopeUrl('*/customer/run') . "'); return false;");
|
17 |
|
18 |
+
if (!Mage::helper('bronto_customer')->isModuleActive()) {
|
19 |
$this->setDisabled(true)->setClass('disabled');
|
20 |
}
|
21 |
}
|
app/code/community/Bronto/Customer/Block/Adminhtml/Widget/Button/Sync.php
CHANGED
@@ -12,19 +12,11 @@ class Bronto_Customer_Block_Adminhtml_Widget_Button_Sync extends Mage_Adminhtml_
|
|
12 |
*/
|
13 |
protected function _construct()
|
14 |
{
|
15 |
-
$
|
16 |
-
|
17 |
-
$this->setLabel(sprintf('Sync %d Contacts to Queue', $missingCustomers));
|
18 |
-
$this->setOnClick("setLocation('" . Mage::helper('adminhtml')->getUrl('*/customer/sync') . "'); return false;");
|
19 |
$this->setClass('save');
|
20 |
-
|
21 |
-
|
22 |
-
if ($missingCustomers == 0) {
|
23 |
-
$this->setLabel('Sync Complete');
|
24 |
-
$this->setDisabled(true)->setClass('disabled');
|
25 |
-
}
|
26 |
|
27 |
-
if (!
|
28 |
$this->setDisabled(true)->setClass('disabled');
|
29 |
}
|
30 |
}
|
12 |
*/
|
13 |
protected function _construct()
|
14 |
{
|
15 |
+
$this->setLabel($this->__('Sync Contacts to Queue'));
|
16 |
+
$this->setOnClick("deleteConfirm('This will ensure all Magento contacts are in the queue to import into Bronto\\n\\nThis is meant to be used when the customer count does not match the total number of customers in the Magento admin\\n\\nWould you like to continue?', '" . Mage::helper('bronto_customer')->getScopeUrl('*/customer/sync') . "'); return false;");
|
|
|
|
|
17 |
$this->setClass('save');
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
if (!Mage::helper('bronto_customer')->isModuleActive()) {
|
20 |
$this->setDisabled(true)->setClass('disabled');
|
21 |
}
|
22 |
}
|
app/code/community/Bronto/Customer/Helper/Data.php
CHANGED
@@ -7,30 +7,119 @@
|
|
7 |
*/
|
8 |
class Bronto_Customer_Helper_Data extends Bronto_Common_Helper_Data implements Bronto_Common_Helper_DataInterface
|
9 |
{
|
10 |
-
const XML_PATH_ENABLED
|
11 |
-
const XML_PATH_LIMIT
|
12 |
-
const
|
13 |
-
const
|
|
|
14 |
|
15 |
-
const XML_PREFIX_CUSTOMER_ATTR
|
16 |
-
const XML_PREFIX_ADDRESS_ATTR
|
17 |
|
18 |
/**
|
19 |
* @return bool
|
20 |
*/
|
21 |
public function isEnabled()
|
22 |
{
|
23 |
-
return (bool)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
24 |
}
|
25 |
|
26 |
/**
|
27 |
-
* @param
|
28 |
-
* @
|
29 |
-
* @return mixed
|
30 |
*/
|
31 |
-
public function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
{
|
33 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
}
|
35 |
|
36 |
/**
|
@@ -38,18 +127,19 @@ class Bronto_Customer_Helper_Data extends Bronto_Common_Helper_Data implements B
|
|
38 |
* @param int|string $store
|
39 |
* @return mixed
|
40 |
*/
|
41 |
-
public function
|
42 |
{
|
43 |
-
return
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
-
* @param
|
48 |
-
* @
|
|
|
49 |
*/
|
50 |
-
public function
|
51 |
{
|
52 |
-
return $this->
|
53 |
}
|
54 |
|
55 |
/**
|
@@ -60,69 +150,87 @@ class Bronto_Customer_Helper_Data extends Bronto_Common_Helper_Data implements B
|
|
60 |
{
|
61 |
return 'bronto_customer';
|
62 |
}
|
63 |
-
|
64 |
/**
|
65 |
* Get Human Readable label for attribute value option
|
66 |
* @param Mage_Eav_Model_Entity_Attribute $attribute
|
67 |
* @param int|string $attributeValueId
|
68 |
* @return string|boolean
|
69 |
*/
|
70 |
-
public function getAttributeAdminLabel($attribute, $attributeValueId)
|
|
|
71 |
$_collection = Mage::getResourceModel('eav/entity_attribute_option_collection')
|
72 |
->setStoreFilter(0)
|
73 |
->setAttributeFilter($attribute->getId())
|
74 |
->load();
|
75 |
|
76 |
-
foreach(
|
77 |
-
if ($_cur_option['value'] == $attributeValueId){
|
78 |
-
|
|
|
|
|
79 |
}
|
80 |
return false;
|
81 |
}
|
82 |
-
|
83 |
/**
|
84 |
-
*
|
85 |
-
* @
|
86 |
-
* @return boolean
|
87 |
*/
|
88 |
-
public function
|
89 |
{
|
90 |
-
|
91 |
-
|
92 |
-
$options = array();
|
93 |
-
foreach ($fieldObjectOptions as $option) {
|
94 |
-
$options[] = $option->value;
|
95 |
-
}
|
96 |
-
return $options;
|
97 |
-
}
|
98 |
-
return false;
|
99 |
}
|
100 |
-
|
101 |
/**
|
102 |
-
* Get Customers
|
103 |
-
* @
|
104 |
-
* @return int|Mage_Customer_Model_Resource_Customer_Collection
|
105 |
*/
|
106 |
-
public function getMissingCustomers(
|
107 |
{
|
108 |
-
|
109 |
-
|
110 |
-
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
}
|
117 |
-
|
118 |
-
|
119 |
-
|
120 |
-
|
121 |
-
|
122 |
-
|
123 |
-
|
|
|
124 |
}
|
125 |
-
|
126 |
-
|
|
|
127 |
}
|
128 |
}
|
7 |
*/
|
8 |
class Bronto_Customer_Helper_Data extends Bronto_Common_Helper_Data implements Bronto_Common_Helper_DataInterface
|
9 |
{
|
10 |
+
const XML_PATH_ENABLED = 'bronto_customer/settings/enabled';
|
11 |
+
const XML_PATH_LIMIT = 'bronto_customer/settings/limit';
|
12 |
+
const XML_PATH_SYNC_LIMIT = 'bronto_customer/settings/sync_limit';
|
13 |
+
const XML_PATH_INSTALL_DATE = 'bronto_customer/settings/install_date';
|
14 |
+
const XML_PATH_UPGRADE_DATE = 'bronto_customer/settings/upgrade_date';
|
15 |
|
16 |
+
const XML_PREFIX_CUSTOMER_ATTR = 'bronto_customer/attributes/';
|
17 |
+
const XML_PREFIX_ADDRESS_ATTR = 'bronto_customer/address_attributes/';
|
18 |
|
19 |
/**
|
20 |
* @return bool
|
21 |
*/
|
22 |
public function isEnabled()
|
23 |
{
|
24 |
+
return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED);
|
25 |
+
}
|
26 |
+
|
27 |
+
/*
|
28 |
+
* Get Text to display in notice when enabling module
|
29 |
+
*
|
30 |
+
* @return string
|
31 |
+
*/
|
32 |
+
public function getModuleEnabledText()
|
33 |
+
{
|
34 |
+
$message = parent::getModuleEnabledText();
|
35 |
+
$scopeData = $this->getScopeParams();
|
36 |
+
if ($scopeData['scope'] != 'default') {
|
37 |
+
$message = $this->__(
|
38 |
+
'If the API token being used for this configuration scope is different from that of the Default Config scope, ' .
|
39 |
+
'you should un-check the `Use Website` or `Use Default` for ALL <em>Customer Attributes</em> ' .
|
40 |
+
'and <em>Address Attributes</em> on this page and select the desired fields.'
|
41 |
+
);
|
42 |
+
}
|
43 |
+
return $message;
|
44 |
}
|
45 |
|
46 |
/**
|
47 |
+
* @param string $path
|
48 |
+
* @return bool
|
|
|
49 |
*/
|
50 |
+
public function disableModule($scope = 'default', $scopeId = 0)
|
51 |
+
{
|
52 |
+
return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId);
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* @param $storeId int (Optional)
|
57 |
+
* @return int
|
58 |
+
*/
|
59 |
+
public function getLimit($storeId = null)
|
60 |
+
{
|
61 |
+
return (int)$this->getAdminScopedConfig(self::XML_PATH_LIMIT, $storeId);
|
62 |
+
}
|
63 |
+
|
64 |
+
/**
|
65 |
+
* @return int
|
66 |
+
*/
|
67 |
+
public function getSyncLimit()
|
68 |
{
|
69 |
+
return (int)$this->getAdminScopedConfig(self::XML_PATH_SYNC_LIMIT);
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* @return array
|
74 |
+
*/
|
75 |
+
public function getSystemAttributes()
|
76 |
+
{
|
77 |
+
return array(
|
78 |
+
'attributes' => array(
|
79 |
+
'prefix',
|
80 |
+
'new_prefix',
|
81 |
+
'firstname',
|
82 |
+
'new_firstname',
|
83 |
+
'middlename',
|
84 |
+
'new_middlename',
|
85 |
+
'lastname',
|
86 |
+
'new_lastname',
|
87 |
+
'suffix',
|
88 |
+
'new_suffix',
|
89 |
+
'gender',
|
90 |
+
'new_gender',
|
91 |
+
'dob',
|
92 |
+
'new_dob',
|
93 |
+
'taxvat',
|
94 |
+
'new_taxvat',
|
95 |
+
'website_id',
|
96 |
+
'new_website_id',
|
97 |
+
'group_id',
|
98 |
+
'new_group_id',
|
99 |
+
'created_at',
|
100 |
+
'new_created_at',
|
101 |
+
'created_in',
|
102 |
+
'new_created_in',
|
103 |
+
),
|
104 |
+
'address_attributes' => array(
|
105 |
+
'street',
|
106 |
+
'new_street',
|
107 |
+
'city',
|
108 |
+
'new_city',
|
109 |
+
'region',
|
110 |
+
'new_region',
|
111 |
+
'postcode',
|
112 |
+
'new_postcode',
|
113 |
+
'country_id',
|
114 |
+
'new_country_id',
|
115 |
+
'company',
|
116 |
+
'new_company',
|
117 |
+
'telephone',
|
118 |
+
'new_telephone',
|
119 |
+
'fax',
|
120 |
+
'new_fax',
|
121 |
+
),
|
122 |
+
);
|
123 |
}
|
124 |
|
125 |
/**
|
127 |
* @param int|string $store
|
128 |
* @return mixed
|
129 |
*/
|
130 |
+
public function getCustomerAttributeField($attribute, $store = null)
|
131 |
{
|
132 |
+
return $this->getAdminScopedConfig(self::XML_PREFIX_CUSTOMER_ATTR . $attribute, $store);
|
133 |
}
|
134 |
|
135 |
/**
|
136 |
+
* @param string $attribute
|
137 |
+
* @param int|string $store
|
138 |
+
* @return mixed
|
139 |
*/
|
140 |
+
public function getAddressAttributeField($attribute, $store = null)
|
141 |
{
|
142 |
+
return $this->getAdminScopedConfig(self::XML_PREFIX_ADDRESS_ATTR . $attribute, $store);
|
143 |
}
|
144 |
|
145 |
/**
|
150 |
{
|
151 |
return 'bronto_customer';
|
152 |
}
|
153 |
+
|
154 |
/**
|
155 |
* Get Human Readable label for attribute value option
|
156 |
* @param Mage_Eav_Model_Entity_Attribute $attribute
|
157 |
* @param int|string $attributeValueId
|
158 |
* @return string|boolean
|
159 |
*/
|
160 |
+
public function getAttributeAdminLabel($attribute, $attributeValueId)
|
161 |
+
{
|
162 |
$_collection = Mage::getResourceModel('eav/entity_attribute_option_collection')
|
163 |
->setStoreFilter(0)
|
164 |
->setAttributeFilter($attribute->getId())
|
165 |
->load();
|
166 |
|
167 |
+
foreach ($_collection->toOptionArray() as $_cur_option) {
|
168 |
+
if ($_cur_option['value'] == $attributeValueId) {
|
169 |
+
return $_cur_option['label'];
|
170 |
+
}
|
171 |
+
|
172 |
}
|
173 |
return false;
|
174 |
}
|
175 |
+
|
176 |
/**
|
177 |
+
* Get Count of customers not in queue
|
178 |
+
* @return int
|
|
|
179 |
*/
|
180 |
+
public function getMissingCustomersCount()
|
181 |
{
|
182 |
+
return Mage::getModel('bronto_customer/queue')
|
183 |
+
->getMissingCustomersCount();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
}
|
185 |
+
|
186 |
/**
|
187 |
+
* Get Customers which aren't in contact queue
|
188 |
+
* @return array
|
|
|
189 |
*/
|
190 |
+
public function getMissingCustomers()
|
191 |
{
|
192 |
+
return Mage::getModel('bronto_customer/queue')
|
193 |
+
->getMissingCustomers();
|
194 |
+
}
|
195 |
+
|
196 |
+
/**
|
197 |
+
* Does this helper have custom config for debugging
|
198 |
+
*
|
199 |
+
* @return boolean
|
200 |
+
*/
|
201 |
+
public function hasCustomConfig() {
|
202 |
+
return true;
|
203 |
+
}
|
204 |
+
|
205 |
+
/**
|
206 |
+
* Gets the bronto customer field attributes
|
207 |
+
*
|
208 |
+
* @param object $store (Optional)
|
209 |
+
* @return array
|
210 |
+
*/
|
211 |
+
public function getCustomConfig($store = null) {
|
212 |
+
$customerAttributes = Mage::getModel('customer/entity_attribute_collection');
|
213 |
+
$addressAttributes = Mage::getModel('customer/entity_address_attribute_collection');
|
214 |
+
|
215 |
+
$attributes = array();
|
216 |
+
$data = array();
|
217 |
+
foreach ($customerAttributes as $attribute) {
|
218 |
+
$config = $this->getCustomerAttributeField($attribute->getAttributeCode(), $store);
|
219 |
+
if ($config && $attribute->getFrontendLabel()) {
|
220 |
+
$data[$attribute->getAttributeCode()] = $config;
|
221 |
+
}
|
222 |
}
|
223 |
+
$attributes['customer_attributes'] = $data;
|
224 |
+
|
225 |
+
$data = array();
|
226 |
+
foreach ($addressAttributes as $attribute) {
|
227 |
+
$config = $this->getAddressAttributeField($attribute->getAttributeCode(), $store);
|
228 |
+
if ($config && $attribute->getFrontendLabel()) {
|
229 |
+
$data[$attribute->getAttributeCode()] = $config;
|
230 |
+
}
|
231 |
}
|
232 |
+
$attributes['address_attributes'] = $data;
|
233 |
+
|
234 |
+
return $attributes;
|
235 |
}
|
236 |
}
|
app/code/community/Bronto/Customer/Model/Mysql4/Queue.php
CHANGED
@@ -13,15 +13,24 @@ class Bronto_Customer_Model_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstract
|
|
13 |
* @var bool
|
14 |
*/
|
15 |
protected $_isPkAutoIncrement = false;
|
16 |
-
|
17 |
/**
|
18 |
* Initialize Model
|
19 |
-
*
|
20 |
-
* @return void
|
21 |
* @access public
|
22 |
*/
|
23 |
public function _construct()
|
24 |
{
|
25 |
$this->_init('bronto_customer/queue', 'queue_id');
|
26 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
13 |
* @var bool
|
14 |
*/
|
15 |
protected $_isPkAutoIncrement = false;
|
16 |
+
|
17 |
/**
|
18 |
* Initialize Model
|
19 |
+
*
|
20 |
+
* @return void
|
21 |
* @access public
|
22 |
*/
|
23 |
public function _construct()
|
24 |
{
|
25 |
$this->_init('bronto_customer/queue', 'queue_id');
|
26 |
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Get Write adapter instance
|
30 |
+
* @return type
|
31 |
+
*/
|
32 |
+
public function getWriteAdapter()
|
33 |
+
{
|
34 |
+
return $this->_getWriteAdapter();
|
35 |
+
}
|
36 |
}
|
app/code/community/Bronto/Customer/Model/Mysql4/Queue/Collection.php
CHANGED
@@ -5,20 +5,21 @@
|
|
5 |
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
* @version 1.0.2
|
7 |
*/
|
8 |
-
class Bronto_Customer_Model_Mysql4_Queue_Collection
|
9 |
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
10 |
-
{
|
11 |
/**
|
12 |
* Initialize Model
|
13 |
-
*
|
14 |
-
* @return void
|
15 |
* @access public
|
16 |
*/
|
17 |
-
public function _construct()
|
|
|
18 |
parent::_construct();
|
19 |
$this->_init('bronto_customer/queue');
|
20 |
}
|
21 |
-
|
22 |
/**
|
23 |
* @return Bronto_Order_Model_Mysql4_Queue_Collection
|
24 |
*/
|
@@ -27,7 +28,7 @@ class Bronto_Customer_Model_Mysql4_Queue_Collection
|
|
27 |
$this->addFieldToFilter('bronto_imported', array('notnull' => true));
|
28 |
return $this;
|
29 |
}
|
30 |
-
|
31 |
/**
|
32 |
* @return Bronto_Order_Model_Mysql4_Queue_Collection
|
33 |
*/
|
@@ -69,13 +70,11 @@ class Bronto_Customer_Model_Mysql4_Queue_Collection
|
|
69 |
|
70 |
$storeIds = array_unique($storeIds);
|
71 |
|
72 |
-
if ($index = array_search(null, $storeIds)) {
|
73 |
unset($storeIds[$index]);
|
74 |
$nullCheck = true;
|
75 |
}
|
76 |
|
77 |
-
$storeIds[0] = ($storeIds[0] == '') ? 0 : $storeIds[0];
|
78 |
-
|
79 |
if ($nullCheck) {
|
80 |
$this->getSelect()->where('store_id IN(?) OR store_id IS NULL', $storeIds);
|
81 |
} else {
|
@@ -93,7 +92,8 @@ class Bronto_Customer_Model_Mysql4_Queue_Collection
|
|
93 |
*/
|
94 |
public function orderByCreatedAt($dir = self::SORT_ORDER_DESC)
|
95 |
{
|
96 |
-
$this->
|
|
|
97 |
return $this;
|
98 |
}
|
99 |
|
@@ -105,7 +105,8 @@ class Bronto_Customer_Model_Mysql4_Queue_Collection
|
|
105 |
*/
|
106 |
public function orderByUpdatedAt($dir = self::SORT_ORDER_DESC)
|
107 |
{
|
108 |
-
$this->
|
|
|
109 |
return $this;
|
110 |
}
|
111 |
}
|
5 |
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
* @version 1.0.2
|
7 |
*/
|
8 |
+
class Bronto_Customer_Model_Mysql4_Queue_Collection
|
9 |
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
10 |
+
{
|
11 |
/**
|
12 |
* Initialize Model
|
13 |
+
*
|
14 |
+
* @return void
|
15 |
* @access public
|
16 |
*/
|
17 |
+
public function _construct()
|
18 |
+
{
|
19 |
parent::_construct();
|
20 |
$this->_init('bronto_customer/queue');
|
21 |
}
|
22 |
+
|
23 |
/**
|
24 |
* @return Bronto_Order_Model_Mysql4_Queue_Collection
|
25 |
*/
|
28 |
$this->addFieldToFilter('bronto_imported', array('notnull' => true));
|
29 |
return $this;
|
30 |
}
|
31 |
+
|
32 |
/**
|
33 |
* @return Bronto_Order_Model_Mysql4_Queue_Collection
|
34 |
*/
|
70 |
|
71 |
$storeIds = array_unique($storeIds);
|
72 |
|
73 |
+
if ($index = array_search(null, $storeIds, true)) {
|
74 |
unset($storeIds[$index]);
|
75 |
$nullCheck = true;
|
76 |
}
|
77 |
|
|
|
|
|
78 |
if ($nullCheck) {
|
79 |
$this->getSelect()->where('store_id IN(?) OR store_id IS NULL', $storeIds);
|
80 |
} else {
|
92 |
*/
|
93 |
public function orderByCreatedAt($dir = self::SORT_ORDER_DESC)
|
94 |
{
|
95 |
+
$this->getSelect()->order("created_at $dir");
|
96 |
+
|
97 |
return $this;
|
98 |
}
|
99 |
|
105 |
*/
|
106 |
public function orderByUpdatedAt($dir = self::SORT_ORDER_DESC)
|
107 |
{
|
108 |
+
$this->getSelect()->order("updated_at $dir");
|
109 |
+
|
110 |
return $this;
|
111 |
}
|
112 |
}
|
app/code/community/Bronto/Customer/Model/Observer.php
CHANGED
@@ -8,17 +8,31 @@
|
|
8 |
class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
|
9 |
{
|
10 |
private $_fieldMap = array();
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
13 |
* @param mixed $storeId
|
14 |
*
|
15 |
* @return array
|
16 |
*/
|
17 |
-
public function processCustomersForStore($storeId = null)
|
18 |
{
|
19 |
-
|
|
|
|
|
|
|
|
|
|
|
20 |
$storeId = $store->getId();
|
21 |
-
|
22 |
$result = array('total' => 0, 'success' => 0, 'error' => 0);
|
23 |
Mage::helper('bronto_customer')->writeDebug("Starting Customer Import process for store: {$store->getName()} ({$storeId})");
|
24 |
|
@@ -36,12 +50,6 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
|
|
36 |
/* @var $contactObject Bronto_Api_Contact */
|
37 |
$contactObject = $api->getContactObject();
|
38 |
|
39 |
-
$limit = $store->getConfig(Bronto_Customer_Helper_Data::XML_PATH_LIMIT);
|
40 |
-
if (!$limit) {
|
41 |
-
Mage::helper('bronto_customer')->writeDebug(' Limit empty. Skipping...');
|
42 |
-
return false;
|
43 |
-
}
|
44 |
-
|
45 |
// Get all customers in queue who haven't been imported into bronto
|
46 |
$customerRows = Mage::getModel('bronto_customer/queue')
|
47 |
->getCollection()
|
@@ -58,43 +66,43 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
|
|
58 |
}
|
59 |
|
60 |
$customerAttributes = Mage::getModel('customer/entity_attribute_collection');
|
61 |
-
$addressAttributes
|
62 |
-
$customerCache
|
63 |
|
64 |
// For each Customer...
|
65 |
foreach ($customerRows as $customerRow) {
|
66 |
$customerId = $customerRow->getCustomerId();
|
67 |
-
if ($customer = Mage::getModel('customer/customer')->load($customerId)
|
68 |
Mage::helper('bronto_customer')->writeDebug(" Processing Customer ID: {$customerId} for Store ID: {$storeId}");
|
69 |
$customerCache[] = array('customerId' => $customerId, 'storeId' => $storeId);
|
70 |
-
|
71 |
/* @var $brontoContact Bronto_Api_Contact_Row */
|
72 |
-
$brontoContact = $contactObject->createRow();
|
73 |
$brontoContact->email = $customer->getEmail();
|
74 |
-
|
75 |
/* Process Customer Attributes */
|
76 |
try {
|
77 |
-
$brontoContact = $this->
|
78 |
|
79 |
/* Process Address Attributes */
|
80 |
$primaryAddress = $customer->getPrimaryShippingAddress();
|
81 |
if (!empty($primaryAddress)) {
|
82 |
-
$brontoContact = $this->
|
83 |
}
|
84 |
-
|
85 |
$brontoContact->persist();
|
86 |
} catch (Exception $e) {
|
87 |
-
|
88 |
}
|
89 |
|
90 |
try {
|
91 |
// Mark Customer as imported
|
92 |
$customerRow->setBrontoImported(Mage::getSingleton('core/date')->gmtDate());
|
93 |
$customerRow->save();
|
94 |
-
|
95 |
// Flush every 10 Customers
|
96 |
if ($result['total'] % 100 === 0) {
|
97 |
-
$result
|
98 |
$customerCache = array();
|
99 |
}
|
100 |
} catch (Exception $e) {
|
@@ -102,7 +110,7 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
|
|
102 |
|
103 |
// Mark Customer as *not* imported
|
104 |
$customerRow->setBrontoImported(null);
|
105 |
-
|
106 |
$customerRow->save();
|
107 |
|
108 |
$result['error']++;
|
@@ -113,7 +121,7 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
|
|
113 |
}
|
114 |
|
115 |
// Final flush (for any we miss)
|
116 |
-
$results = $this->
|
117 |
|
118 |
Mage::helper('bronto_customer')->writeDebug(' Success: ' . $results['success']);
|
119 |
Mage::helper('bronto_customer')->writeDebug(' Error: ' . $results['error']);
|
@@ -121,7 +129,7 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
|
|
121 |
|
122 |
return $results;
|
123 |
}
|
124 |
-
|
125 |
/**
|
126 |
* Cycle through attributes and validate against Bronto Field type
|
127 |
* @param Bronto_Api_Contact_Row $brontoContact
|
@@ -131,7 +139,7 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
|
|
131 |
* @param string $type 'customer' or 'address'
|
132 |
* @return Bronto_Api_Contact_Row
|
133 |
*/
|
134 |
-
|
135 |
{
|
136 |
// For each Customer attribute
|
137 |
foreach ($attributes as $attribute) {
|
@@ -139,7 +147,7 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
|
|
139 |
continue;
|
140 |
}
|
141 |
$_attributeCode = $attribute->getAttributeCode();
|
142 |
-
|
143 |
// Get Attribute Field
|
144 |
switch ($type) {
|
145 |
case 'address':
|
@@ -149,37 +157,41 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
|
|
149 |
$_fieldName = Mage::helper('bronto_customer')->getCustomerAttributeField($_attributeCode, $store);
|
150 |
break;
|
151 |
}
|
152 |
-
|
153 |
// Get Customer Attribute Value
|
154 |
-
$_attributeValue = $this->
|
155 |
-
|
156 |
// Skip un-mapped or empty attributes
|
157 |
if (empty($_fieldName) || '_none_' == $_fieldName || !$_attributeValue || '' == $_attributeValue) {
|
158 |
continue;
|
159 |
}
|
160 |
-
|
161 |
// Store Bronto Key => Magento field label for errors
|
162 |
if (!array_key_exists($_fieldName, $this->_fieldMap)) {
|
163 |
$this->_fieldMap[$_fieldName] = $attribute->getFrontendLabel();
|
164 |
}
|
165 |
-
|
166 |
$brontoContact->setField($_fieldName, $_attributeValue);
|
167 |
}
|
168 |
-
|
169 |
return $brontoContact;
|
170 |
}
|
171 |
-
|
172 |
/**
|
173 |
* Based on attribute type, pull the value or the label
|
174 |
* @param type $attribute
|
175 |
* @param type $value
|
176 |
* @return type
|
177 |
*/
|
178 |
-
|
179 |
{
|
|
|
|
|
|
|
|
|
180 |
$_attributeType = $attribute->getFrontendInput();
|
181 |
$_attributeCode = $attribute->getAttributeCode();
|
182 |
-
|
183 |
// Pick up Website/Store/Group Values
|
184 |
switch ($_attributeCode) {
|
185 |
case 'website_id':
|
@@ -201,7 +213,7 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
|
|
201 |
default:
|
202 |
break;
|
203 |
}
|
204 |
-
|
205 |
// Format Attribute Values
|
206 |
switch ($_attributeType) {
|
207 |
case 'select':
|
@@ -216,7 +228,14 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
|
|
216 |
return $values;
|
217 |
break;
|
218 |
case 'date':
|
219 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
220 |
break;
|
221 |
default:
|
222 |
return $value;
|
@@ -231,7 +250,7 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
|
|
231 |
*
|
232 |
* @return array
|
233 |
*/
|
234 |
-
|
235 |
{
|
236 |
$fieldModel = Mage::getModel('bronto_common/system_config_source_field');
|
237 |
$flushResult = $customerObject->flush();
|
@@ -242,36 +261,40 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
|
|
242 |
|
243 |
foreach ($flushResult as $i => $flushResultRow) {
|
244 |
if ($flushResultRow->hasError()) {
|
245 |
-
$errorCode
|
246 |
$errorMessage = $flushResultRow->getErrorMessage();
|
247 |
-
|
248 |
// Catch Error and Replace Field ID with Field Name
|
249 |
if (preg_match_all("/([a-zA-Z0-9\-]){36}/", $errorMessage, $matches)) { // Grab field id if exists
|
250 |
foreach ($matches[0] as $match) {
|
251 |
-
$fieldObject
|
252 |
if ($fieldObject) {
|
253 |
$errorMessage = str_replace($match, $fieldObject->name, $errorMessage);
|
254 |
-
} elseif(array_key_exists($match, $this->_fieldMap)) {
|
255 |
-
$mageLabel
|
256 |
$errorMessage = "Bronto field mapped for {$mageLabel} no longer exists in your bronto account";
|
257 |
}
|
258 |
}
|
259 |
}
|
260 |
-
|
261 |
if (isset($customerCache[$i])) {
|
262 |
// Get Customer Object
|
263 |
$customer = Mage::getModel('customer/customer')->load($customerCache[$i]['customerId']);
|
264 |
-
$store
|
265 |
-
$website
|
266 |
$storeMessage = "For `{$website->getName()}`:`{$store->getName()}`: ";
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
-
|
272 |
-
|
273 |
-
|
274 |
-
|
|
|
|
|
|
|
|
|
275 |
Mage::helper('bronto_customer')->writeError("[{$errorCode}] {$storeMessage}{$errorMessage} ({$customer->getEmail()})");
|
276 |
} else {
|
277 |
Mage::helper('bronto_customer')->writeError("[{$errorCode}] {$errorMessage}");
|
@@ -281,7 +304,7 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
|
|
281 |
$result['success']++;
|
282 |
}
|
283 |
}
|
284 |
-
|
285 |
return $result;
|
286 |
}
|
287 |
|
@@ -291,17 +314,23 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
|
|
291 |
public function processCustomers()
|
292 |
{
|
293 |
$result = array(
|
294 |
-
'total'
|
295 |
'success' => 0,
|
296 |
-
'error'
|
297 |
);
|
298 |
|
|
|
|
|
299 |
$stores = Mage::app()->getStores(true);
|
300 |
foreach ($stores as $_store) {
|
301 |
-
$
|
302 |
-
|
|
|
|
|
|
|
303 |
$result['success'] += $storeResult['success'];
|
304 |
-
$result['error']
|
|
|
305 |
}
|
306 |
|
307 |
return $result;
|
@@ -314,84 +343,148 @@ class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
|
|
314 |
{
|
315 |
/* @var $customer Mage_Customer_Model_Customer */
|
316 |
$customer = $observer->getCustomer();
|
317 |
-
|
318 |
/* @var $contactQueue Bronto_Customer_Model_Queue */
|
319 |
Mage::getModel('bronto_customer/queue')
|
320 |
-
|
321 |
-
|
322 |
-
|
323 |
-
|
324 |
-
|
325 |
-
|
326 |
}
|
327 |
-
|
328 |
/**
|
329 |
-
* Grab Config Data Object before save and handle the 'Create New...' value for
|
330 |
* fields that were generated dynamically
|
331 |
* @param Varien_Event_Observer $observer
|
332 |
* @return Varien_Event_Observer
|
333 |
*/
|
334 |
public function saveDynamicField(Varien_Event_Observer $observer)
|
335 |
{
|
336 |
-
|
337 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
338 |
}
|
339 |
-
|
340 |
return $observer;
|
341 |
}
|
342 |
-
|
343 |
/**
|
344 |
* Process customer and address attributes and save back to observer
|
345 |
-
* @param
|
346 |
-
* @
|
|
|
347 |
*/
|
348 |
-
protected function
|
349 |
{
|
350 |
-
|
351 |
-
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
|
|
|
|
|
|
361 |
}
|
362 |
-
|
363 |
/**
|
364 |
* Capture "Create New..." attributes, create field in Bronto, and save field id
|
365 |
* @param array $attributesFields
|
|
|
|
|
366 |
* @return array
|
367 |
*/
|
368 |
-
protected function
|
369 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
370 |
foreach ($attributesFields as $fieldId => $field) {
|
|
|
371 |
if (preg_match('/dynamic_new_/', $fieldId)) {
|
372 |
-
|
|
|
373 |
$value = $field['value'];
|
374 |
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
$field = $fieldObject->createRow();
|
379 |
-
$field->name = $fieldObject->normalize($value);
|
380 |
-
$field->label = $value;
|
381 |
-
$field->type = Bronto_Api_Field::TYPE_TEXT;
|
382 |
|
383 |
try {
|
384 |
-
$
|
385 |
-
$fieldObject->
|
|
|
|
|
|
|
|
|
386 |
|
387 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
388 |
unset($attributesFields[$fieldId]);
|
|
|
389 |
} catch (Exception $e) {
|
390 |
Mage::helper('bronto_customer')->writeError("Unable to save new field: {$value}");
|
391 |
}
|
392 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
393 |
}
|
394 |
-
|
395 |
return $attributesFields;
|
396 |
}
|
397 |
}
|
8 |
class Bronto_Customer_Model_Observer extends Mage_Core_Model_Abstract
|
9 |
{
|
10 |
private $_fieldMap = array();
|
11 |
+
|
12 |
+
/**
|
13 |
+
* Observes module becoming enabled and displays message warning user to configure settings
|
14 |
+
* @param Varien_Event_Observer $observer
|
15 |
+
*/
|
16 |
+
public function watchEnableAction(Varien_Event_Observer $observer)
|
17 |
+
{
|
18 |
+
Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('bronto_customer')->__(Mage::helper('bronto_customer')->getModuleEnabledText()));
|
19 |
+
}
|
20 |
+
|
21 |
/**
|
22 |
* @param mixed $storeId
|
23 |
*
|
24 |
* @return array
|
25 |
*/
|
26 |
+
public function processCustomersForStore($storeId = null, $limit)
|
27 |
{
|
28 |
+
if (!$limit) {
|
29 |
+
Mage::helper('bronto_customer')->writeDebug(' Limit empty. Skipping...');
|
30 |
+
return false;
|
31 |
+
}
|
32 |
+
|
33 |
+
$store = Mage::app()->getStore($storeId);
|
34 |
$storeId = $store->getId();
|
35 |
+
|
36 |
$result = array('total' => 0, 'success' => 0, 'error' => 0);
|
37 |
Mage::helper('bronto_customer')->writeDebug("Starting Customer Import process for store: {$store->getName()} ({$storeId})");
|
38 |
|
50 |
/* @var $contactObject Bronto_Api_Contact */
|
51 |
$contactObject = $api->getContactObject();
|
52 |
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
// Get all customers in queue who haven't been imported into bronto
|
54 |
$customerRows = Mage::getModel('bronto_customer/queue')
|
55 |
->getCollection()
|
66 |
}
|
67 |
|
68 |
$customerAttributes = Mage::getModel('customer/entity_attribute_collection');
|
69 |
+
$addressAttributes = Mage::getModel('customer/entity_address_attribute_collection')->addVisibleFilter();
|
70 |
+
$customerCache = array();
|
71 |
|
72 |
// For each Customer...
|
73 |
foreach ($customerRows as $customerRow) {
|
74 |
$customerId = $customerRow->getCustomerId();
|
75 |
+
if ($customer = Mage::getModel('customer/customer')->load($customerId)/* @var $customer Mage_Customer_Model_Customer */) {
|
76 |
Mage::helper('bronto_customer')->writeDebug(" Processing Customer ID: {$customerId} for Store ID: {$storeId}");
|
77 |
$customerCache[] = array('customerId' => $customerId, 'storeId' => $storeId);
|
78 |
+
|
79 |
/* @var $brontoContact Bronto_Api_Contact_Row */
|
80 |
+
$brontoContact = $contactObject->createRow(array());
|
81 |
$brontoContact->email = $customer->getEmail();
|
82 |
+
|
83 |
/* Process Customer Attributes */
|
84 |
try {
|
85 |
+
$brontoContact = $this->_processAttributes($brontoContact, $customer, $customerAttributes, $store, 'customer');
|
86 |
|
87 |
/* Process Address Attributes */
|
88 |
$primaryAddress = $customer->getPrimaryShippingAddress();
|
89 |
if (!empty($primaryAddress)) {
|
90 |
+
$brontoContact = $this->_processAttributes($brontoContact, $primaryAddress, $addressAttributes, $store, 'address');
|
91 |
}
|
92 |
+
|
93 |
$brontoContact->persist();
|
94 |
} catch (Exception $e) {
|
95 |
+
|
96 |
}
|
97 |
|
98 |
try {
|
99 |
// Mark Customer as imported
|
100 |
$customerRow->setBrontoImported(Mage::getSingleton('core/date')->gmtDate());
|
101 |
$customerRow->save();
|
102 |
+
|
103 |
// Flush every 10 Customers
|
104 |
if ($result['total'] % 100 === 0) {
|
105 |
+
$result = $this->_flushCustomers($contactObject, $customerCache, $result);
|
106 |
$customerCache = array();
|
107 |
}
|
108 |
} catch (Exception $e) {
|
110 |
|
111 |
// Mark Customer as *not* imported
|
112 |
$customerRow->setBrontoImported(null);
|
113 |
+
|
114 |
$customerRow->save();
|
115 |
|
116 |
$result['error']++;
|
121 |
}
|
122 |
|
123 |
// Final flush (for any we miss)
|
124 |
+
$results = $this->_flushCustomers($contactObject, $customerCache, $result);
|
125 |
|
126 |
Mage::helper('bronto_customer')->writeDebug(' Success: ' . $results['success']);
|
127 |
Mage::helper('bronto_customer')->writeDebug(' Error: ' . $results['error']);
|
129 |
|
130 |
return $results;
|
131 |
}
|
132 |
+
|
133 |
/**
|
134 |
* Cycle through attributes and validate against Bronto Field type
|
135 |
* @param Bronto_Api_Contact_Row $brontoContact
|
139 |
* @param string $type 'customer' or 'address'
|
140 |
* @return Bronto_Api_Contact_Row
|
141 |
*/
|
142 |
+
protected function _processAttributes(Bronto_Api_Contact_Row $brontoContact, $source, $attributes, Mage_Core_Model_Store $store, $type = 'customer')
|
143 |
{
|
144 |
// For each Customer attribute
|
145 |
foreach ($attributes as $attribute) {
|
147 |
continue;
|
148 |
}
|
149 |
$_attributeCode = $attribute->getAttributeCode();
|
150 |
+
|
151 |
// Get Attribute Field
|
152 |
switch ($type) {
|
153 |
case 'address':
|
157 |
$_fieldName = Mage::helper('bronto_customer')->getCustomerAttributeField($_attributeCode, $store);
|
158 |
break;
|
159 |
}
|
160 |
+
|
161 |
// Get Customer Attribute Value
|
162 |
+
$_attributeValue = $this->_getReadableValue($attribute, $source->getData($_attributeCode));
|
163 |
+
|
164 |
// Skip un-mapped or empty attributes
|
165 |
if (empty($_fieldName) || '_none_' == $_fieldName || !$_attributeValue || '' == $_attributeValue) {
|
166 |
continue;
|
167 |
}
|
168 |
+
|
169 |
// Store Bronto Key => Magento field label for errors
|
170 |
if (!array_key_exists($_fieldName, $this->_fieldMap)) {
|
171 |
$this->_fieldMap[$_fieldName] = $attribute->getFrontendLabel();
|
172 |
}
|
173 |
+
|
174 |
$brontoContact->setField($_fieldName, $_attributeValue);
|
175 |
}
|
176 |
+
|
177 |
return $brontoContact;
|
178 |
}
|
179 |
+
|
180 |
/**
|
181 |
* Based on attribute type, pull the value or the label
|
182 |
* @param type $attribute
|
183 |
* @param type $value
|
184 |
* @return type
|
185 |
*/
|
186 |
+
protected function _getReadableValue($attribute, $value)
|
187 |
{
|
188 |
+
if ('' == $value) {
|
189 |
+
return '';
|
190 |
+
}
|
191 |
+
|
192 |
$_attributeType = $attribute->getFrontendInput();
|
193 |
$_attributeCode = $attribute->getAttributeCode();
|
194 |
+
|
195 |
// Pick up Website/Store/Group Values
|
196 |
switch ($_attributeCode) {
|
197 |
case 'website_id':
|
213 |
default:
|
214 |
break;
|
215 |
}
|
216 |
+
|
217 |
// Format Attribute Values
|
218 |
switch ($_attributeType) {
|
219 |
case 'select':
|
228 |
return $values;
|
229 |
break;
|
230 |
case 'date':
|
231 |
+
$dates = explode(' ', $value);
|
232 |
+
$date = $dates[0];
|
233 |
+
|
234 |
+
if (!preg_match('/^[\d]{4}-[\d]{2}-[\d]{2}$/', $date)) {
|
235 |
+
return '';
|
236 |
+
} else {
|
237 |
+
return $date;
|
238 |
+
}
|
239 |
break;
|
240 |
default:
|
241 |
return $value;
|
250 |
*
|
251 |
* @return array
|
252 |
*/
|
253 |
+
protected function _flushCustomers($customerObject, $customerCache, $result)
|
254 |
{
|
255 |
$fieldModel = Mage::getModel('bronto_common/system_config_source_field');
|
256 |
$flushResult = $customerObject->flush();
|
261 |
|
262 |
foreach ($flushResult as $i => $flushResultRow) {
|
263 |
if ($flushResultRow->hasError()) {
|
264 |
+
$errorCode = $flushResultRow->getErrorCode();
|
265 |
$errorMessage = $flushResultRow->getErrorMessage();
|
266 |
+
|
267 |
// Catch Error and Replace Field ID with Field Name
|
268 |
if (preg_match_all("/([a-zA-Z0-9\-]){36}/", $errorMessage, $matches)) { // Grab field id if exists
|
269 |
foreach ($matches[0] as $match) {
|
270 |
+
$fieldObject = $fieldModel->getFieldObjectById($match);
|
271 |
if ($fieldObject) {
|
272 |
$errorMessage = str_replace($match, $fieldObject->name, $errorMessage);
|
273 |
+
} elseif (array_key_exists($match, $this->_fieldMap)) {
|
274 |
+
$mageLabel = $this->_fieldMap[$match];
|
275 |
$errorMessage = "Bronto field mapped for {$mageLabel} no longer exists in your bronto account";
|
276 |
}
|
277 |
}
|
278 |
}
|
279 |
+
|
280 |
if (isset($customerCache[$i])) {
|
281 |
// Get Customer Object
|
282 |
$customer = Mage::getModel('customer/customer')->load($customerCache[$i]['customerId']);
|
283 |
+
$store = Mage::getModel('core/store')->load($customerCache[$i]['storeId']);
|
284 |
+
$website = Mage::getModel('core/website')->load($store->getWebsiteId());
|
285 |
$storeMessage = "For `{$website->getName()}`:`{$store->getName()}`: ";
|
286 |
+
|
287 |
+
$customerObject = Mage::getModel('bronto_customer/queue')
|
288 |
+
->getCustomerRow($customerCache[$i]['customerId'], $customerCache[$i]['storeId'])
|
289 |
+
->setBrontoImported(null);
|
290 |
+
|
291 |
+
// If Error Code In specified Array, suppress contact
|
292 |
+
if (in_array($errorCode, array(302, 303, 314, 315, 317))) {
|
293 |
+
$customerObject->setBrontoSuppressed($errorMessage);
|
294 |
+
}
|
295 |
+
|
296 |
+
$customerObject->save();
|
297 |
+
|
298 |
Mage::helper('bronto_customer')->writeError("[{$errorCode}] {$storeMessage}{$errorMessage} ({$customer->getEmail()})");
|
299 |
} else {
|
300 |
Mage::helper('bronto_customer')->writeError("[{$errorCode}] {$errorMessage}");
|
304 |
$result['success']++;
|
305 |
}
|
306 |
}
|
307 |
+
|
308 |
return $result;
|
309 |
}
|
310 |
|
314 |
public function processCustomers()
|
315 |
{
|
316 |
$result = array(
|
317 |
+
'total' => 0,
|
318 |
'success' => 0,
|
319 |
+
'error' => 0,
|
320 |
);
|
321 |
|
322 |
+
$limit = Mage::helper('bronto_customer')->getLimit();
|
323 |
+
|
324 |
$stores = Mage::app()->getStores(true);
|
325 |
foreach ($stores as $_store) {
|
326 |
+
if ($limit <= 0) {
|
327 |
+
continue;
|
328 |
+
}
|
329 |
+
$storeResult = $this->processCustomersForStore($_store, $limit);
|
330 |
+
$result['total'] += $storeResult['total'];
|
331 |
$result['success'] += $storeResult['success'];
|
332 |
+
$result['error'] += $storeResult['error'];
|
333 |
+
$limit = $limit - $storeResult['total'];
|
334 |
}
|
335 |
|
336 |
return $result;
|
343 |
{
|
344 |
/* @var $customer Mage_Customer_Model_Customer */
|
345 |
$customer = $observer->getCustomer();
|
346 |
+
|
347 |
/* @var $contactQueue Bronto_Customer_Model_Queue */
|
348 |
Mage::getModel('bronto_customer/queue')
|
349 |
+
->getCustomerRow($customer->getId(), $customer->getStoreId())
|
350 |
+
->setCreatedAt($customer->getCreatedAt())
|
351 |
+
->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate())
|
352 |
+
->setBrontoImported(null)
|
353 |
+
->setBrontoSuppressed(null)
|
354 |
+
->save();
|
355 |
}
|
356 |
+
|
357 |
/**
|
358 |
+
* Grab Config Data Object before save and handle the 'Create New...' value for
|
359 |
* fields that were generated dynamically
|
360 |
* @param Varien_Event_Observer $observer
|
361 |
* @return Varien_Event_Observer
|
362 |
*/
|
363 |
public function saveDynamicField(Varien_Event_Observer $observer)
|
364 |
{
|
365 |
+
$action = $observer->getEvent()->getControllerAction();
|
366 |
+
|
367 |
+
if ($action->getRequest()->getParam('section') == 'bronto_customer') {
|
368 |
+
$groups = $action->getRequest()->getPost('groups');
|
369 |
+
$section = $action->getRequest()->getParam('section');
|
370 |
+
|
371 |
+
// Pre-Process Fields to Strip out and Handle Dynamic Fields
|
372 |
+
$groups = $this->_handleDynamicAttributes($groups, $section);
|
373 |
+
|
374 |
+
// Replace Existing 'groups' data with newly stripped 'groups' data and pass on to be saved
|
375 |
+
$observer->getEvent()->getControllerAction()->getRequest()->setPost('groups', $groups);
|
376 |
}
|
377 |
+
|
378 |
return $observer;
|
379 |
}
|
380 |
+
|
381 |
/**
|
382 |
* Process customer and address attributes and save back to observer
|
383 |
+
* @param array $groups
|
384 |
+
* @param string $section
|
385 |
+
* @return array
|
386 |
*/
|
387 |
+
protected function _handleDynamicAttributes($groups, $section)
|
388 |
{
|
389 |
+
// Process Dynamic Customer Attribute Fields
|
390 |
+
if (array_key_exists('attributes', $groups)) {
|
391 |
+
$attrFieldsCustomer = $this->_processDynamicAttributes($groups['attributes']['fields'], $section, 'attributes');
|
392 |
+
$groups['attributes']['fields'] = $attrFieldsCustomer;
|
393 |
+
}
|
394 |
+
|
395 |
+
// Process Dynamic Address Attribute Fields
|
396 |
+
if (array_key_exists('address_attributes', $groups)) {
|
397 |
+
$attrFieldsAddress = $this->_processDynamicAttributes($groups['address_attributes']['fields'], $section, 'address_attributes');
|
398 |
+
$groups['address_attributes']['fields'] = $attrFieldsAddress;
|
399 |
+
}
|
400 |
+
|
401 |
+
// Return Updated Groups Data
|
402 |
+
return $groups;
|
403 |
}
|
404 |
+
|
405 |
/**
|
406 |
* Capture "Create New..." attributes, create field in Bronto, and save field id
|
407 |
* @param array $attributesFields
|
408 |
+
* @param string $section
|
409 |
+
* @param string $group
|
410 |
* @return array
|
411 |
*/
|
412 |
+
protected function _processDynamicAttributes($attributesFields = array(), $section, $group)
|
413 |
{
|
414 |
+
// Create Config Object
|
415 |
+
$config = Mage::getModel('core/config');
|
416 |
+
|
417 |
+
// Get Admin Scope Parameters
|
418 |
+
$scopeParams = Mage::helper('bronto_common')->getScopeParams();
|
419 |
+
|
420 |
+
// Get Array of Attributes that are hard-coded into system.xml
|
421 |
+
$ignore = Mage::helper('bronto_customer')->getSystemAttributes();
|
422 |
+
|
423 |
+
// Cycle Through Attribute Fields to Find and Save Dynamic Fields
|
424 |
foreach ($attributesFields as $fieldId => $field) {
|
425 |
+
// Save Dynamic 'Create New...' Fields
|
426 |
if (preg_match('/dynamic_new_/', $fieldId)) {
|
427 |
+
// Strip off 'dynamic_new_' from Field ID to Get real Field ID
|
428 |
+
$realField = str_replace('dynamic_new_', '', $fieldId);
|
429 |
$value = $field['value'];
|
430 |
|
431 |
+
if (is_null($value)) {
|
432 |
+
continue;
|
433 |
+
}
|
|
|
|
|
|
|
|
|
434 |
|
435 |
try {
|
436 |
+
/* @var $fieldObject Bronto_Api_Field */
|
437 |
+
$fieldObject = Mage::helper('bronto_common')->getApi()->getFieldObject();
|
438 |
+
$brontoField = $fieldObject->createRow();
|
439 |
+
$brontoField->name = $fieldObject->normalize($value);
|
440 |
+
$brontoField->label = $value;
|
441 |
+
$brontoField->type = Bronto_Api_Field::TYPE_TEXT;
|
442 |
|
443 |
+
$brontoField->save();
|
444 |
+
$fieldObject->addToCache($brontoField->name, $brontoField);
|
445 |
+
|
446 |
+
$scope = $scopeParams['scope'];
|
447 |
+
if ($scope != 'default') {
|
448 |
+
$scope .= 's';
|
449 |
+
}
|
450 |
+
|
451 |
+
// Save Field To Config
|
452 |
+
$config->saveConfig(
|
453 |
+
$section.'/'.$group.'/'.$realField,
|
454 |
+
$brontoField->id,
|
455 |
+
$scope,
|
456 |
+
$scopeParams[$scopeParams['scope'].'_id']
|
457 |
+
);
|
458 |
+
|
459 |
+
// Unset Dynamic Fields
|
460 |
+
unset($attributesFields[$realField]);
|
461 |
unset($attributesFields[$fieldId]);
|
462 |
+
unset($fieldObject);
|
463 |
} catch (Exception $e) {
|
464 |
Mage::helper('bronto_customer')->writeError("Unable to save new field: {$value}");
|
465 |
}
|
466 |
}
|
467 |
+
|
468 |
+
// Save Dynamic Fields
|
469 |
+
elseif (!in_array($fieldId, $ignore[$group])) {
|
470 |
+
$scope = $scopeParams['scope'];
|
471 |
+
if ($scope != 'default') {
|
472 |
+
$scope .= 's';
|
473 |
+
}
|
474 |
+
|
475 |
+
// Save Field To Config
|
476 |
+
$config->saveConfig(
|
477 |
+
$section.'/'.$group.'/'.$fieldId,
|
478 |
+
$field['value'],
|
479 |
+
$scope,
|
480 |
+
$scopeParams[$scopeParams['scope'].'_id']
|
481 |
+
);
|
482 |
+
|
483 |
+
// Unset Dynamic Field
|
484 |
+
unset($attributesFields[$fieldId]);
|
485 |
+
}
|
486 |
}
|
487 |
+
|
488 |
return $attributesFields;
|
489 |
}
|
490 |
}
|
app/code/community/Bronto/Customer/Model/Queue.php
CHANGED
@@ -12,7 +12,7 @@ class Bronto_Customer_Model_Queue extends Mage_Core_Model_Abstract
|
|
12 |
parent::_construct();
|
13 |
$this->_init('bronto_customer/queue');
|
14 |
}
|
15 |
-
|
16 |
/**
|
17 |
* Retrieve Customer Queue Row
|
18 |
* @param int $customerId
|
@@ -25,53 +25,90 @@ class Bronto_Customer_Model_Queue extends Mage_Core_Model_Abstract
|
|
25 |
$collection = $this->getCollection()
|
26 |
->addFieldToFilter('customer_id', $customerId)
|
27 |
->addFieldToFilter('store_id', $storeId);
|
28 |
-
|
29 |
// Handle Results
|
30 |
if ($collection->count() == 1) {
|
31 |
return $collection->getFirstItem();
|
32 |
} else {
|
33 |
$this->setCustomerId($customerId)
|
34 |
-
|
35 |
}
|
36 |
-
|
37 |
return $this;
|
38 |
}
|
39 |
-
|
40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
41 |
{
|
42 |
-
|
43 |
-
$
|
44 |
-
->
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
|
|
|
|
49 |
}
|
50 |
-
|
51 |
/**
|
52 |
-
* Get collection of customers
|
53 |
-
* @
|
54 |
-
* @return Mage_Customer_Model_Resource_Customer_Collection
|
55 |
*/
|
56 |
-
public function getMissingCustomers(
|
57 |
{
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
//
|
63 |
-
$
|
64 |
-
|
65 |
-
//
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
|
|
|
|
|
76 |
}
|
77 |
}
|
12 |
parent::_construct();
|
13 |
$this->_init('bronto_customer/queue');
|
14 |
}
|
15 |
+
|
16 |
/**
|
17 |
* Retrieve Customer Queue Row
|
18 |
* @param int $customerId
|
25 |
$collection = $this->getCollection()
|
26 |
->addFieldToFilter('customer_id', $customerId)
|
27 |
->addFieldToFilter('store_id', $storeId);
|
28 |
+
|
29 |
// Handle Results
|
30 |
if ($collection->count() == 1) {
|
31 |
return $collection->getFirstItem();
|
32 |
} else {
|
33 |
$this->setCustomerId($customerId)
|
34 |
+
->setStoreId($storeId);
|
35 |
}
|
36 |
+
|
37 |
return $this;
|
38 |
}
|
39 |
+
|
40 |
+
/**
|
41 |
+
* Get Count of missing customers
|
42 |
+
* @return int
|
43 |
+
*/
|
44 |
+
public function getMissingCustomersCount()
|
45 |
+
{
|
46 |
+
// Get Resources
|
47 |
+
$resource = $this->getResource();
|
48 |
+
$adapter = $resource->getWriteAdapter();
|
49 |
+
|
50 |
+
// Build Select Statement
|
51 |
+
$select = $adapter->select();
|
52 |
+
$select->from(
|
53 |
+
array('customer' => $resource->getTable('customer/entity')),
|
54 |
+
array(new Zend_Db_Expr('COUNT(entity_id) as count'))
|
55 |
+
)
|
56 |
+
->where('NOT EXISTS (?)', $this->_getSubselect($resource, $adapter));
|
57 |
+
|
58 |
+
// Get Results
|
59 |
+
$result = $adapter->query($select)->fetch();
|
60 |
+
|
61 |
+
if (array_key_exists('count', $result)) {
|
62 |
+
return (int) $result['count'];
|
63 |
+
} else {
|
64 |
+
return 0;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Get Sub-Select Statement that limits results
|
70 |
+
* @param Bronto_Customer_Model_Mysql4_Queue $resource
|
71 |
+
* @param type $adapter
|
72 |
+
* @return Varien_Db_Select
|
73 |
+
*/
|
74 |
+
private function _getSubselect($resource, $adapter)
|
75 |
{
|
76 |
+
// Build Sub-Select Statement
|
77 |
+
$subselect = $adapter->select()
|
78 |
+
->from(
|
79 |
+
array('queue' => $resource->getTable('bronto_customer/queue')),
|
80 |
+
array(new Zend_Db_Expr(1))
|
81 |
+
)
|
82 |
+
->where('queue.customer_id = customer.entity_id');
|
83 |
+
|
84 |
+
return $subselect;
|
85 |
}
|
86 |
+
|
87 |
/**
|
88 |
+
* Get collection of customers which aren't already in the queue, but should be
|
89 |
+
* @return array
|
|
|
90 |
*/
|
91 |
+
public function getMissingCustomers()
|
92 |
{
|
93 |
+
// Get Resources
|
94 |
+
$resource = $this->getResource();
|
95 |
+
$adapter = $resource->getWriteAdapter();
|
96 |
+
|
97 |
+
// Get Sync Limit Value
|
98 |
+
$count = Mage::helper('bronto_customer')->getSyncLimit();
|
99 |
+
|
100 |
+
// Build Select Statement
|
101 |
+
$select = $adapter->select();
|
102 |
+
$select->from(
|
103 |
+
array('customer' => $resource->getTable('customer/entity')),
|
104 |
+
array('entity_id', 'created_at', 'store_id')
|
105 |
+
)
|
106 |
+
->where('NOT EXISTS (?)', $this->_getSubselect($resource, $adapter))
|
107 |
+
->limit($count);
|
108 |
+
|
109 |
+
// Get Results
|
110 |
+
$result = $adapter->query($select)->fetchAll();
|
111 |
+
|
112 |
+
return $result;
|
113 |
}
|
114 |
}
|
app/code/community/Bronto/Customer/Model/Resource/Customer.php
CHANGED
@@ -6,7 +6,7 @@ class Bronto_Customer_Model_Resource_Customer extends Mage_Customer_Model_Resour
|
|
6 |
{
|
7 |
parent::__construct();
|
8 |
}
|
9 |
-
|
10 |
/**
|
11 |
* Retrieve customer entity default attributes
|
12 |
*
|
6 |
{
|
7 |
parent::__construct();
|
8 |
}
|
9 |
+
|
10 |
/**
|
11 |
* Retrieve customer entity default attributes
|
12 |
*
|
app/code/community/Bronto/Customer/Model/System/Config/Backend/Brontofield.php
CHANGED
@@ -16,12 +16,12 @@ class Bronto_Customer_Model_System_Config_Backend_Brontofield extends Mage_Core_
|
|
16 |
/* @var $fieldObject Bronto_Api_Field */
|
17 |
$fieldObject = Mage::getModel('bronto_common/system_config_source_field')->getFieldObjectById($this->getValue());
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
|
26 |
if ($attributes) {
|
27 |
foreach ($attributes as $attribute) {
|
16 |
/* @var $fieldObject Bronto_Api_Field */
|
17 |
$fieldObject = Mage::getModel('bronto_common/system_config_source_field')->getFieldObjectById($this->getValue());
|
18 |
|
19 |
+
if ($fieldObject) {
|
20 |
+
if ('attributes' == $this->group_id) {
|
21 |
+
$attributes = Mage::getModel('customer/entity_attribute_collection');
|
22 |
+
} elseif ('address_attributes' == $this->group_id) {
|
23 |
+
$attributes = Mage::getModel('customer/entity_address_attribute_collection')->addVisibleFilter();
|
24 |
+
}
|
25 |
|
26 |
if ($attributes) {
|
27 |
foreach ($attributes as $attribute) {
|
app/code/community/Bronto/Customer/Model/System/Config/Backend/Cron.php
CHANGED
@@ -7,5 +7,5 @@
|
|
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
|
11 |
}
|
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 |
}
|
app/code/community/Bronto/Customer/Model/System/Config/Backend/Newfield.php
CHANGED
@@ -14,22 +14,22 @@ class Bronto_Customer_Model_System_Config_Backend_Newfield extends Mage_Core_Mod
|
|
14 |
protected function _beforeSave()
|
15 |
{
|
16 |
if ($this->isValueChanged()) {
|
17 |
-
|
18 |
-
|
|
|
19 |
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
|
25 |
-
try {
|
26 |
$field->save();
|
27 |
$fieldObject->addToCache($field->name, $field);
|
28 |
|
29 |
$this->_saveConfigData(str_replace('new_', '', $this->getPath()), $field->id);
|
30 |
$this->setValue(null);
|
31 |
} catch (Exception $e) {
|
32 |
-
Mage::throwException(Mage::helper('adminhtml')->__('Unable to save new field'));
|
33 |
}
|
34 |
}
|
35 |
|
@@ -43,10 +43,19 @@ class Bronto_Customer_Model_System_Config_Backend_Newfield extends Mage_Core_Mod
|
|
43 |
*/
|
44 |
protected function _saveConfigData($path, $value)
|
45 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
Mage::getModel('core/config_data')
|
47 |
->load($path, 'path')
|
48 |
->setValue($value)
|
49 |
->setPath($path)
|
|
|
|
|
50 |
->save();
|
51 |
|
52 |
return $this;
|
14 |
protected function _beforeSave()
|
15 |
{
|
16 |
if ($this->isValueChanged()) {
|
17 |
+
try {
|
18 |
+
/* @var $fieldObject Bronto_Api_Field */
|
19 |
+
$fieldObject = Mage::helper('bronto_common')->getApi()->getFieldObject();
|
20 |
|
21 |
+
$field = $fieldObject->createRow();
|
22 |
+
$field->name = $fieldObject->normalize($this->getValue());
|
23 |
+
$field->label = $this->getValue();
|
24 |
+
$field->type = Bronto_Api_Field::TYPE_TEXT;
|
25 |
|
|
|
26 |
$field->save();
|
27 |
$fieldObject->addToCache($field->name, $field);
|
28 |
|
29 |
$this->_saveConfigData(str_replace('new_', '', $this->getPath()), $field->id);
|
30 |
$this->setValue(null);
|
31 |
} catch (Exception $e) {
|
32 |
+
Mage::throwException(Mage::helper('adminhtml')->__('Unable to save new field: ') . $e->getMessage());
|
33 |
}
|
34 |
}
|
35 |
|
43 |
*/
|
44 |
protected function _saveConfigData($path, $value)
|
45 |
{
|
46 |
+
$scopeParams = Mage::helper('bronto_common')->getScopeParams();
|
47 |
+
|
48 |
+
$scope = $scopeParams['scope'];
|
49 |
+
if ($scope != 'default') {
|
50 |
+
$scope .= 's';
|
51 |
+
}
|
52 |
+
|
53 |
Mage::getModel('core/config_data')
|
54 |
->load($path, 'path')
|
55 |
->setValue($value)
|
56 |
->setPath($path)
|
57 |
+
->setScope($scope)
|
58 |
+
->setScopeId($scopeParams[$scopeParams['scope'].'_id'])
|
59 |
->save();
|
60 |
|
61 |
return $this;
|
app/code/community/Bronto/Customer/Test/Config/Config.php
DELETED
@@ -1,159 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Bronto_Customer_Test_Config_Config
|
3 |
-
extends EcomDev_PHPUnit_Test_Case_Config
|
4 |
-
{
|
5 |
-
public function blocksProvider()
|
6 |
-
{
|
7 |
-
return array(
|
8 |
-
array('bronto_customer/adminhtml_system_config_about', 'Bronto_Customer_Block_Adminhtml_System_Config_About'),
|
9 |
-
array('bronto_customer/adminhtml_system_config_form_fieldset_attributes', 'Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attributes'),
|
10 |
-
array('bronto_customer/adminhtml_system_config_form_fieldset_attributes_address', 'Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attributes_Address'),
|
11 |
-
array('bronto_customer/adminhtml_system_config_form_fieldset_attributes_customer', 'Bronto_Customer_Block_Adminhtml_System_Config_Form_Fieldset_Attributes_Customer'),
|
12 |
-
);
|
13 |
-
}
|
14 |
-
|
15 |
-
public function modelsProvider()
|
16 |
-
{
|
17 |
-
return array(
|
18 |
-
array('bronto_customer/system_config_backend_cron', 'Bronto_Customer_Model_System_Config_Backend_Cron'),
|
19 |
-
array('bronto_customer/system_config_backend_newfield', 'Bronto_Customer_Model_System_Config_Backend_Newfield'),
|
20 |
-
array('bronto_customer/queue', 'Bronto_Customer_Model_Queue'),
|
21 |
-
);
|
22 |
-
}
|
23 |
-
|
24 |
-
public function resourceModelProvider()
|
25 |
-
{
|
26 |
-
return array(
|
27 |
-
array('bronto_customer_resource/setup', 'Bronto_Customer_Model_Resource_Setup'),
|
28 |
-
array('bronto_customer_resource/customer_collection', 'Bronto_Customer_Model_Resource_Customer_Collection'),
|
29 |
-
array('bronto_customer_mysql4/queue', 'Bronto_Customer_Model_Mysql4_Queue'),
|
30 |
-
array('bronto_customer_mysql4/queue_collection', 'Bronto_Customer_Model_Mysql4_Queue_Collection'),
|
31 |
-
);
|
32 |
-
}
|
33 |
-
|
34 |
-
public function observersProvider()
|
35 |
-
{
|
36 |
-
return array(
|
37 |
-
array('global', 'customer_save_after', 'bronto_customer/observer', 'markCustomerForReimport'),
|
38 |
-
);
|
39 |
-
}
|
40 |
-
|
41 |
-
public function helpersProvider()
|
42 |
-
{
|
43 |
-
return array(
|
44 |
-
array('bronto_customer/data', 'Bronto_Customer_Helper_Data'),
|
45 |
-
);
|
46 |
-
}
|
47 |
-
|
48 |
-
public function dependsProvider()
|
49 |
-
{
|
50 |
-
return array(
|
51 |
-
array('Bronto_Common'),
|
52 |
-
);
|
53 |
-
}
|
54 |
-
|
55 |
-
/**
|
56 |
-
* @test
|
57 |
-
* @group amd
|
58 |
-
* @group config
|
59 |
-
*/
|
60 |
-
public function assertCustomerModuleVersionGreaterThanOrEquals()
|
61 |
-
{
|
62 |
-
$this->assertModuleVersionGreaterThanOrEquals('1.0.1');
|
63 |
-
}
|
64 |
-
|
65 |
-
|
66 |
-
/**
|
67 |
-
* @test
|
68 |
-
* @group amd
|
69 |
-
* @group config
|
70 |
-
*/
|
71 |
-
public function assertCustomerModuleInCommunityCodePool()
|
72 |
-
{
|
73 |
-
$this->assertModuleCodePool('community');
|
74 |
-
}
|
75 |
-
|
76 |
-
/**
|
77 |
-
* @test
|
78 |
-
* @group amd
|
79 |
-
* @group config
|
80 |
-
* @dataProvider dependsProvider
|
81 |
-
*/
|
82 |
-
public function assertCustomerModuleDepends(
|
83 |
-
$requiredModuleName
|
84 |
-
) {
|
85 |
-
$this->assertModuleDepends($requiredModuleName);
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* test
|
90 |
-
* @group amd
|
91 |
-
* @group config
|
92 |
-
* @dataProvider modelsProvider
|
93 |
-
*/
|
94 |
-
public function assertCustomerModelAliases(
|
95 |
-
$classAlias,
|
96 |
-
$expectedClassName
|
97 |
-
) {
|
98 |
-
$this->assertModelAlias($classAlias, $expectedClassName);
|
99 |
-
}
|
100 |
-
|
101 |
-
/**
|
102 |
-
* test
|
103 |
-
* @group amd
|
104 |
-
* @group config
|
105 |
-
* @dataProvider resourceModelProvider
|
106 |
-
*/
|
107 |
-
public function assertCustomerResourceModelAliases(
|
108 |
-
$classAlias,
|
109 |
-
$expectedClassName
|
110 |
-
) {
|
111 |
-
$this->assertResourceModelAlias($classAlias, $expectedClassName);
|
112 |
-
}
|
113 |
-
|
114 |
-
/**
|
115 |
-
* test
|
116 |
-
* @group config
|
117 |
-
* @group amd
|
118 |
-
* @dataProvider observersProvider
|
119 |
-
*/
|
120 |
-
public function assertCustomerEventObserversDefined(
|
121 |
-
$area,
|
122 |
-
$eventName,
|
123 |
-
$observerClassAlias,
|
124 |
-
$observerMethod
|
125 |
-
) {
|
126 |
-
$this->assertEventObserverDefined(
|
127 |
-
$area,
|
128 |
-
$eventName,
|
129 |
-
$observerClassAlias,
|
130 |
-
$observerMethod
|
131 |
-
);
|
132 |
-
}
|
133 |
-
|
134 |
-
/**
|
135 |
-
* @test
|
136 |
-
* @group amd
|
137 |
-
* @group config
|
138 |
-
* @dataProvider blocksProvider
|
139 |
-
*/
|
140 |
-
public function assertCustomerBlockAliases(
|
141 |
-
$classAlias,
|
142 |
-
$expectedClassName
|
143 |
-
) {
|
144 |
-
$this->assertBlockAlias($classAlias, $expectedClassName);
|
145 |
-
}
|
146 |
-
|
147 |
-
/**
|
148 |
-
* @test
|
149 |
-
* @group amd
|
150 |
-
* @group config
|
151 |
-
* @dataProvider helpersProvider
|
152 |
-
*/
|
153 |
-
public function assertCustomerHelperAliases(
|
154 |
-
$classAlias,
|
155 |
-
$expectedClassName
|
156 |
-
) {
|
157 |
-
$this->assertHelperAlias($classAlias, $expectedClassName);
|
158 |
-
}
|
159 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/Customer/controllers/Adminhtml/CustomerController.php
CHANGED
@@ -11,17 +11,25 @@ class Bronto_Customer_Adminhtml_CustomerController extends Mage_Adminhtml_Contro
|
|
11 |
*/
|
12 |
public function runAction()
|
13 |
{
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
|
|
|
19 |
if ($storeIds = $helper->getStoreIds()) {
|
|
|
|
|
|
|
20 |
foreach ($storeIds as $storeId) {
|
21 |
-
$
|
22 |
-
|
|
|
|
|
|
|
23 |
$result['success'] += $storeResult['success'];
|
24 |
-
$result['error']
|
|
|
25 |
}
|
26 |
} else {
|
27 |
$result = $model->processCustomers();
|
@@ -35,10 +43,12 @@ class Bronto_Customer_Adminhtml_CustomerController extends Mage_Adminhtml_Contro
|
|
35 |
|
36 |
} catch (Exception $e) {
|
37 |
$this->_getSession()->addError($e->getMessage());
|
38 |
-
|
39 |
}
|
40 |
|
41 |
-
$
|
|
|
|
|
42 |
}
|
43 |
|
44 |
/**
|
@@ -46,45 +56,53 @@ class Bronto_Customer_Adminhtml_CustomerController extends Mage_Adminhtml_Contro
|
|
46 |
*/
|
47 |
public function resetAction()
|
48 |
{
|
49 |
-
$helper
|
50 |
$storeIds = $helper->getStoreIds();
|
51 |
-
|
52 |
-
$
|
53 |
|
|
|
54 |
if ($storeIds) {
|
55 |
-
$
|
56 |
}
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
$
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
|
|
|
|
65 |
}
|
66 |
|
67 |
-
$
|
|
|
|
|
68 |
}
|
69 |
-
|
70 |
/**
|
71 |
* Pull Customers from Customer Table if not in queue
|
72 |
*/
|
73 |
public function syncAction()
|
74 |
{
|
|
|
75 |
$imported = 0;
|
76 |
-
|
77 |
-
|
78 |
try {
|
79 |
-
$customers = Mage::helper('bronto_customer')->getMissingCustomers();
|
80 |
-
$waiting
|
81 |
-
|
82 |
if ($waiting > 0) {
|
83 |
foreach ($customers as $customer) {
|
84 |
-
Mage::getModel('bronto_customer/queue')->getCustomerRow($customer
|
85 |
-
->setCreatedAt($customer
|
86 |
->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate())
|
87 |
-
->setBrontoImported(
|
88 |
->save();
|
89 |
|
90 |
$imported++;
|
@@ -94,9 +112,11 @@ class Bronto_Customer_Adminhtml_CustomerController extends Mage_Adminhtml_Contro
|
|
94 |
Mage::helper('bronto_customer')->writeError($e);
|
95 |
$this->_getSession()->addError('Sync failed: ' . $e->getMessage());
|
96 |
}
|
97 |
-
|
98 |
$this->_getSession()->addSuccess(sprintf("%d of %d Customers were added to the Queue", $imported, $waiting));
|
99 |
-
$
|
|
|
|
|
100 |
}
|
101 |
|
102 |
/**
|
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();
|
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 |
/**
|
56 |
*/
|
57 |
public function resetAction()
|
58 |
{
|
59 |
+
$helper = Mage::helper('bronto_customer');
|
60 |
$storeIds = $helper->getStoreIds();
|
61 |
+
$resource = Mage::getResourceModel('bronto_customer/queue');
|
62 |
+
$adapter = $resource->getWriteAdapter();
|
63 |
|
64 |
+
$where = array();
|
65 |
if ($storeIds) {
|
66 |
+
$where = array('store_id IN (?)' => $storeIds);
|
67 |
}
|
68 |
+
|
69 |
+
try {
|
70 |
+
$adapter->update(
|
71 |
+
$resource->getTable('bronto_customer/queue'),
|
72 |
+
array(
|
73 |
+
'bronto_imported' => null,
|
74 |
+
'bronto_suppressed' => null,
|
75 |
+
),
|
76 |
+
$where
|
77 |
+
);
|
78 |
+
} catch (Exception $e) {
|
79 |
+
$helper->writeError($e);
|
80 |
+
$this->_getSession()->addError('Reset failed: ' . $e->getMessage());
|
81 |
}
|
82 |
|
83 |
+
$returnParams = array('section' => 'bronto_customer');
|
84 |
+
$returnParams = array_merge($returnParams, $helper->getScopeParams());
|
85 |
+
$this->_redirect('*/system_config/edit', $returnParams);
|
86 |
}
|
87 |
+
|
88 |
/**
|
89 |
* Pull Customers from Customer Table if not in queue
|
90 |
*/
|
91 |
public function syncAction()
|
92 |
{
|
93 |
+
$helper = Mage::helper('bronto_customer');
|
94 |
$imported = 0;
|
95 |
+
|
|
|
96 |
try {
|
97 |
+
$customers = Mage::helper('bronto_customer')->getMissingCustomers();
|
98 |
+
$waiting = count($customers);
|
99 |
+
|
100 |
if ($waiting > 0) {
|
101 |
foreach ($customers as $customer) {
|
102 |
+
Mage::getModel('bronto_customer/queue')->getCustomerRow($customer['entity_id'], $customer['store_id'])
|
103 |
+
->setCreatedAt($customer['created_at'])
|
104 |
->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate())
|
105 |
+
->setBrontoImported(0)
|
106 |
->save();
|
107 |
|
108 |
$imported++;
|
112 |
Mage::helper('bronto_customer')->writeError($e);
|
113 |
$this->_getSession()->addError('Sync failed: ' . $e->getMessage());
|
114 |
}
|
115 |
+
|
116 |
$this->_getSession()->addSuccess(sprintf("%d of %d Customers were added to the Queue", $imported, $waiting));
|
117 |
+
$returnParams = array('section' => 'bronto_customer');
|
118 |
+
$returnParams = array_merge($returnParams, $helper->getScopeParams());
|
119 |
+
$this->_redirect('*/system_config/edit', $returnParams);
|
120 |
}
|
121 |
|
122 |
/**
|
app/code/community/Bronto/Customer/etc/adminhtml.xml
CHANGED
@@ -9,7 +9,8 @@
|
|
9 |
<config>
|
10 |
<children>
|
11 |
<bronto_customer module="bronto_customer">
|
12 |
-
<title>Bronto
|
|
|
13 |
</bronto_customer>
|
14 |
</children>
|
15 |
</config>
|
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>
|
app/code/community/Bronto/Customer/etc/config.xml
CHANGED
@@ -29,7 +29,9 @@
|
|
29 |
<bronto_customer_mysql4>
|
30 |
<class>Bronto_Customer_Model_Mysql4</class>
|
31 |
<entities>
|
32 |
-
<queue
|
|
|
|
|
33 |
</entities>
|
34 |
</bronto_customer_mysql4>
|
35 |
</models>
|
@@ -64,38 +66,17 @@
|
|
64 |
</bronto_customer_sales_customer_save_after>
|
65 |
</observers>
|
66 |
</customer_save_after>
|
67 |
-
<
|
68 |
<observers>
|
69 |
-
<
|
70 |
<type>singleton</type>
|
71 |
<class>bronto_customer/observer</class>
|
72 |
<method>saveDynamicField</method>
|
73 |
-
</
|
74 |
</observers>
|
75 |
-
</
|
76 |
</events>
|
77 |
</global>
|
78 |
-
<adminhtml>
|
79 |
-
<acl>
|
80 |
-
<resources>
|
81 |
-
<admin>
|
82 |
-
<children>
|
83 |
-
<system>
|
84 |
-
<children>
|
85 |
-
<config>
|
86 |
-
<children>
|
87 |
-
<bronto_customer>
|
88 |
-
<title>Bronto Customer Import Section</title>
|
89 |
-
</bronto_customer>
|
90 |
-
</children>
|
91 |
-
</config>
|
92 |
-
</children>
|
93 |
-
</system>
|
94 |
-
</children>
|
95 |
-
</admin>
|
96 |
-
</resources>
|
97 |
-
</acl>
|
98 |
-
</adminhtml>
|
99 |
<admin>
|
100 |
<routers>
|
101 |
<adminhtml>
|
@@ -107,6 +88,19 @@
|
|
107 |
</adminhtml>
|
108 |
</routers>
|
109 |
</admin>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
110 |
<default>
|
111 |
<bronto_customer>
|
112 |
<settings>
|
@@ -115,6 +109,7 @@
|
|
115 |
<interval>15</interval>
|
116 |
<minutes>0</minutes>
|
117 |
<limit>100</limit>
|
|
|
118 |
</settings>
|
119 |
<attributes>
|
120 |
<prefix>_none_</prefix>
|
@@ -144,15 +139,17 @@
|
|
144 |
</default>
|
145 |
<crontab>
|
146 |
<jobs>
|
147 |
-
<bronto_customer_import>
|
148 |
-
<run
|
|
|
|
|
149 |
</bronto_customer_import>
|
150 |
</jobs>
|
151 |
</crontab>
|
152 |
<phpunit>
|
153 |
<suite>
|
154 |
<modules>
|
155 |
-
<Bronto_Customer
|
156 |
</modules>
|
157 |
</suite>
|
158 |
</phpunit>
|
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>
|
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>
|
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>
|
109 |
<interval>15</interval>
|
110 |
<minutes>0</minutes>
|
111 |
<limit>100</limit>
|
112 |
+
<sync_limit>1000</sync_limit>
|
113 |
</settings>
|
114 |
<attributes>
|
115 |
<prefix>_none_</prefix>
|
139 |
</default>
|
140 |
<crontab>
|
141 |
<jobs>
|
142 |
+
<bronto_customer_import>
|
143 |
+
<run>
|
144 |
+
<model>bronto_customer/observer::processCustomers</model>
|
145 |
+
</run>
|
146 |
</bronto_customer_import>
|
147 |
</jobs>
|
148 |
</crontab>
|
149 |
<phpunit>
|
150 |
<suite>
|
151 |
<modules>
|
152 |
+
<Bronto_Customer/>
|
153 |
</modules>
|
154 |
</suite>
|
155 |
</phpunit>
|
app/code/community/Bronto/Customer/etc/system.xml
CHANGED
@@ -31,6 +31,7 @@
|
|
31 |
<label>Enable Module</label>
|
32 |
<frontend_type>select</frontend_type>
|
33 |
<frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
|
|
|
34 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
35 |
<sort_order>0</sort_order>
|
36 |
<show_in_default>1</show_in_default>
|
@@ -39,56 +40,80 @@
|
|
39 |
</enabled>
|
40 |
<frequency>
|
41 |
<label>Frequency</label>
|
42 |
-
<depends
|
|
|
|
|
43 |
<frontend_type>select</frontend_type>
|
44 |
<source_model>bronto_common/system_config_source_cron_frequency</source_model>
|
45 |
<backend_model>bronto_customer/system_config_backend_cron</backend_model>
|
46 |
<sort_order>20</sort_order>
|
47 |
<show_in_default>1</show_in_default>
|
48 |
<show_in_website>1</show_in_website>
|
49 |
-
<show_in_store>
|
50 |
</frequency>
|
51 |
<interval>
|
52 |
<label>Interval</label>
|
53 |
-
<depends
|
|
|
|
|
54 |
<frontend_type>select</frontend_type>
|
55 |
<source_model>bronto_common/system_config_source_cron_minutes</source_model>
|
56 |
<sort_order>30</sort_order>
|
57 |
<show_in_default>1</show_in_default>
|
58 |
<show_in_website>1</show_in_website>
|
59 |
-
<show_in_store>
|
60 |
<comment>Set this value larger than your cron.php launch period.</comment>
|
61 |
</interval>
|
62 |
<minutes>
|
63 |
<label>Minute of the Hour</label>
|
64 |
-
<depends
|
|
|
|
|
65 |
<frontend_type>text</frontend_type>
|
66 |
<sort_order>40</sort_order>
|
67 |
<show_in_default>1</show_in_default>
|
68 |
<show_in_website>1</show_in_website>
|
69 |
-
<show_in_store>
|
70 |
<comment>Valid range: 0-59 (default 0).</comment>
|
71 |
</minutes>
|
72 |
<time>
|
73 |
<label>Start Time</label>
|
74 |
-
<depends
|
|
|
|
|
75 |
<frontend_type>time</frontend_type>
|
76 |
<sort_order>50</sort_order>
|
77 |
<show_in_default>1</show_in_default>
|
78 |
<show_in_website>1</show_in_website>
|
79 |
-
<show_in_store>
|
|
|
80 |
</time>
|
81 |
<limit>
|
82 |
<label>Limit</label>
|
83 |
-
<depends
|
|
|
|
|
84 |
<frontend_type>select</frontend_type>
|
85 |
-
<source_model>
|
86 |
<sort_order>60</sort_order>
|
87 |
<show_in_default>1</show_in_default>
|
88 |
<show_in_website>1</show_in_website>
|
89 |
-
<show_in_store>
|
90 |
<comment>Total Customers to process every cron run.</comment>
|
91 |
</limit>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
</fields>
|
93 |
</settings>
|
94 |
<cron_list>
|
@@ -96,7 +121,7 @@
|
|
96 |
<frontend_model>bronto_customer/adminhtml_system_config_cron</frontend_model>
|
97 |
<sort_order>6</sort_order>
|
98 |
<show_in_default>1</show_in_default>
|
99 |
-
<show_in_website>
|
100 |
<show_in_store>1</show_in_store>
|
101 |
</cron_list>
|
102 |
<attributes>
|
@@ -106,7 +131,7 @@
|
|
106 |
<sort_order>10</sort_order>
|
107 |
<show_in_default>1</show_in_default>
|
108 |
<show_in_website>1</show_in_website>
|
109 |
-
<show_in_store>
|
110 |
<fields>
|
111 |
<!-- prefix -->
|
112 |
<prefix>
|
@@ -118,7 +143,7 @@
|
|
118 |
<source_model>bronto_common/system_config_source_field</source_model>
|
119 |
<show_in_default>1</show_in_default>
|
120 |
<show_in_website>1</show_in_website>
|
121 |
-
<show_in_store>
|
122 |
</prefix>
|
123 |
<new_prefix>
|
124 |
<sort_order>2</sort_order>
|
@@ -126,7 +151,7 @@
|
|
126 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
127 |
<show_in_default>1</show_in_default>
|
128 |
<show_in_website>1</show_in_website>
|
129 |
-
<show_in_store>
|
130 |
<depends><prefix>_new_</prefix></depends>
|
131 |
</new_prefix>
|
132 |
<!-- firstname -->
|
@@ -139,7 +164,7 @@
|
|
139 |
<source_model>bronto_common/system_config_source_field</source_model>
|
140 |
<show_in_default>1</show_in_default>
|
141 |
<show_in_website>1</show_in_website>
|
142 |
-
<show_in_store>
|
143 |
</firstname>
|
144 |
<new_firstname>
|
145 |
<sort_order>6</sort_order>
|
@@ -147,7 +172,7 @@
|
|
147 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
148 |
<show_in_default>1</show_in_default>
|
149 |
<show_in_website>1</show_in_website>
|
150 |
-
<show_in_store>
|
151 |
<depends><firstname>_new_</firstname></depends>
|
152 |
</new_firstname>
|
153 |
<!-- middlename -->
|
@@ -160,7 +185,7 @@
|
|
160 |
<source_model>bronto_common/system_config_source_field</source_model>
|
161 |
<show_in_default>1</show_in_default>
|
162 |
<show_in_website>1</show_in_website>
|
163 |
-
<show_in_store>
|
164 |
</middlename>
|
165 |
<new_middlename>
|
166 |
<sort_order>11</sort_order>
|
@@ -168,7 +193,7 @@
|
|
168 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
169 |
<show_in_default>1</show_in_default>
|
170 |
<show_in_website>1</show_in_website>
|
171 |
-
<show_in_store>
|
172 |
<depends><middlename>_new_</middlename></depends>
|
173 |
</new_middlename>
|
174 |
<!-- lastname -->
|
@@ -181,7 +206,7 @@
|
|
181 |
<source_model>bronto_common/system_config_source_field</source_model>
|
182 |
<show_in_default>1</show_in_default>
|
183 |
<show_in_website>1</show_in_website>
|
184 |
-
<show_in_store>
|
185 |
</lastname>
|
186 |
<new_lastname>
|
187 |
<sort_order>16</sort_order>
|
@@ -189,8 +214,10 @@
|
|
189 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
190 |
<show_in_default>1</show_in_default>
|
191 |
<show_in_website>1</show_in_website>
|
192 |
-
<show_in_store>
|
193 |
-
<depends
|
|
|
|
|
194 |
</new_lastname>
|
195 |
<!-- suffix -->
|
196 |
<suffix>
|
@@ -202,7 +229,7 @@
|
|
202 |
<source_model>bronto_common/system_config_source_field</source_model>
|
203 |
<show_in_default>1</show_in_default>
|
204 |
<show_in_website>1</show_in_website>
|
205 |
-
<show_in_store>
|
206 |
</suffix>
|
207 |
<new_suffix>
|
208 |
<sort_order>21</sort_order>
|
@@ -210,8 +237,10 @@
|
|
210 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
211 |
<show_in_default>1</show_in_default>
|
212 |
<show_in_website>1</show_in_website>
|
213 |
-
<show_in_store>
|
214 |
-
<depends
|
|
|
|
|
215 |
</new_suffix>
|
216 |
<!-- gender -->
|
217 |
<gender>
|
@@ -223,7 +252,7 @@
|
|
223 |
<source_model>bronto_common/system_config_source_field</source_model>
|
224 |
<show_in_default>1</show_in_default>
|
225 |
<show_in_website>1</show_in_website>
|
226 |
-
<show_in_store>
|
227 |
</gender>
|
228 |
<new_gender>
|
229 |
<sort_order>26</sort_order>
|
@@ -231,8 +260,10 @@
|
|
231 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
232 |
<show_in_default>1</show_in_default>
|
233 |
<show_in_website>1</show_in_website>
|
234 |
-
<show_in_store>
|
235 |
-
<depends
|
|
|
|
|
236 |
</new_gender>
|
237 |
<!-- dob -->
|
238 |
<dob>
|
@@ -244,7 +275,7 @@
|
|
244 |
<source_model>bronto_common/system_config_source_field</source_model>
|
245 |
<show_in_default>1</show_in_default>
|
246 |
<show_in_website>1</show_in_website>
|
247 |
-
<show_in_store>
|
248 |
</dob>
|
249 |
<new_dob>
|
250 |
<sort_order>31</sort_order>
|
@@ -252,8 +283,10 @@
|
|
252 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
253 |
<show_in_default>1</show_in_default>
|
254 |
<show_in_website>1</show_in_website>
|
255 |
-
<show_in_store>
|
256 |
-
<depends
|
|
|
|
|
257 |
</new_dob>
|
258 |
<!-- taxvat -->
|
259 |
<taxvat>
|
@@ -265,7 +298,7 @@
|
|
265 |
<source_model>bronto_common/system_config_source_field</source_model>
|
266 |
<show_in_default>1</show_in_default>
|
267 |
<show_in_website>1</show_in_website>
|
268 |
-
<show_in_store>
|
269 |
</taxvat>
|
270 |
<new_taxvat>
|
271 |
<sort_order>36</sort_order>
|
@@ -273,8 +306,10 @@
|
|
273 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
274 |
<show_in_default>1</show_in_default>
|
275 |
<show_in_website>1</show_in_website>
|
276 |
-
<show_in_store>
|
277 |
-
<depends
|
|
|
|
|
278 |
</new_taxvat>
|
279 |
<!-- website_id -->
|
280 |
<website_id>
|
@@ -286,7 +321,7 @@
|
|
286 |
<source_model>bronto_common/system_config_source_field</source_model>
|
287 |
<show_in_default>1</show_in_default>
|
288 |
<show_in_website>1</show_in_website>
|
289 |
-
<show_in_store>
|
290 |
</website_id>
|
291 |
<new_website_id>
|
292 |
<sort_order>41</sort_order>
|
@@ -294,8 +329,10 @@
|
|
294 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
295 |
<show_in_default>1</show_in_default>
|
296 |
<show_in_website>1</show_in_website>
|
297 |
-
<show_in_store>
|
298 |
-
<depends
|
|
|
|
|
299 |
</new_website_id>
|
300 |
<!-- group_id -->
|
301 |
<group_id>
|
@@ -307,7 +344,7 @@
|
|
307 |
<source_model>bronto_common/system_config_source_field</source_model>
|
308 |
<show_in_default>1</show_in_default>
|
309 |
<show_in_website>1</show_in_website>
|
310 |
-
<show_in_store>
|
311 |
</group_id>
|
312 |
<new_group_id>
|
313 |
<sort_order>46</sort_order>
|
@@ -315,8 +352,10 @@
|
|
315 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
316 |
<show_in_default>1</show_in_default>
|
317 |
<show_in_website>1</show_in_website>
|
318 |
-
<show_in_store>
|
319 |
-
<depends
|
|
|
|
|
320 |
</new_group_id>
|
321 |
<!-- created_at -->
|
322 |
<created_at>
|
@@ -328,7 +367,7 @@
|
|
328 |
<source_model>bronto_common/system_config_source_field</source_model>
|
329 |
<show_in_default>1</show_in_default>
|
330 |
<show_in_website>1</show_in_website>
|
331 |
-
<show_in_store>
|
332 |
</created_at>
|
333 |
<new_created_at>
|
334 |
<sort_order>51</sort_order>
|
@@ -336,8 +375,10 @@
|
|
336 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
337 |
<show_in_default>1</show_in_default>
|
338 |
<show_in_website>1</show_in_website>
|
339 |
-
<show_in_store>
|
340 |
-
<depends
|
|
|
|
|
341 |
</new_created_at>
|
342 |
<!-- created_in -->
|
343 |
<created_in>
|
@@ -349,7 +390,7 @@
|
|
349 |
<source_model>bronto_common/system_config_source_field</source_model>
|
350 |
<show_in_default>1</show_in_default>
|
351 |
<show_in_website>1</show_in_website>
|
352 |
-
<show_in_store>
|
353 |
</created_in>
|
354 |
<new_created_in>
|
355 |
<sort_order>56</sort_order>
|
@@ -357,19 +398,22 @@
|
|
357 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
358 |
<show_in_default>1</show_in_default>
|
359 |
<show_in_website>1</show_in_website>
|
360 |
-
<show_in_store>
|
361 |
-
<depends
|
|
|
|
|
362 |
</new_created_in>
|
363 |
</fields>
|
364 |
</attributes>
|
365 |
<address_attributes>
|
366 |
<label>Address Attributes</label>
|
367 |
<frontend_type>text</frontend_type>
|
368 |
-
<frontend_model>bronto_customer/adminhtml_system_config_form_fieldset_attributes_address
|
|
|
369 |
<sort_order>15</sort_order>
|
370 |
<show_in_default>1</show_in_default>
|
371 |
<show_in_website>1</show_in_website>
|
372 |
-
<show_in_store>
|
373 |
<fields>
|
374 |
<!-- street -->
|
375 |
<street>
|
@@ -381,7 +425,7 @@
|
|
381 |
<source_model>bronto_common/system_config_source_field</source_model>
|
382 |
<show_in_default>1</show_in_default>
|
383 |
<show_in_website>1</show_in_website>
|
384 |
-
<show_in_store>
|
385 |
</street>
|
386 |
<new_street>
|
387 |
<sort_order>2</sort_order>
|
@@ -389,8 +433,10 @@
|
|
389 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
390 |
<show_in_default>1</show_in_default>
|
391 |
<show_in_website>1</show_in_website>
|
392 |
-
<show_in_store>
|
393 |
-
<depends
|
|
|
|
|
394 |
</new_street>
|
395 |
<!-- city -->
|
396 |
<city>
|
@@ -402,7 +448,7 @@
|
|
402 |
<source_model>bronto_common/system_config_source_field</source_model>
|
403 |
<show_in_default>1</show_in_default>
|
404 |
<show_in_website>1</show_in_website>
|
405 |
-
<show_in_store>
|
406 |
</city>
|
407 |
<new_city>
|
408 |
<sort_order>6</sort_order>
|
@@ -410,8 +456,10 @@
|
|
410 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
411 |
<show_in_default>1</show_in_default>
|
412 |
<show_in_website>1</show_in_website>
|
413 |
-
<show_in_store>
|
414 |
-
<depends
|
|
|
|
|
415 |
</new_city>
|
416 |
<!-- region -->
|
417 |
<region>
|
@@ -423,7 +471,7 @@
|
|
423 |
<source_model>bronto_common/system_config_source_field</source_model>
|
424 |
<show_in_default>1</show_in_default>
|
425 |
<show_in_website>1</show_in_website>
|
426 |
-
<show_in_store>
|
427 |
</region>
|
428 |
<new_region>
|
429 |
<sort_order>11</sort_order>
|
@@ -431,8 +479,10 @@
|
|
431 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
432 |
<show_in_default>1</show_in_default>
|
433 |
<show_in_website>1</show_in_website>
|
434 |
-
<show_in_store>
|
435 |
-
<depends
|
|
|
|
|
436 |
</new_region>
|
437 |
<!-- postcode -->
|
438 |
<postcode>
|
@@ -444,7 +494,7 @@
|
|
444 |
<source_model>bronto_common/system_config_source_field</source_model>
|
445 |
<show_in_default>1</show_in_default>
|
446 |
<show_in_website>1</show_in_website>
|
447 |
-
<show_in_store>
|
448 |
</postcode>
|
449 |
<new_postcode>
|
450 |
<sort_order>16</sort_order>
|
@@ -452,8 +502,10 @@
|
|
452 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
453 |
<show_in_default>1</show_in_default>
|
454 |
<show_in_website>1</show_in_website>
|
455 |
-
<show_in_store>
|
456 |
-
<depends
|
|
|
|
|
457 |
</new_postcode>
|
458 |
<!-- country_id -->
|
459 |
<country_id>
|
@@ -465,7 +517,7 @@
|
|
465 |
<source_model>bronto_common/system_config_source_field</source_model>
|
466 |
<show_in_default>1</show_in_default>
|
467 |
<show_in_website>1</show_in_website>
|
468 |
-
<show_in_store>
|
469 |
</country_id>
|
470 |
<new_country_id>
|
471 |
<sort_order>21</sort_order>
|
@@ -473,8 +525,10 @@
|
|
473 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
474 |
<show_in_default>1</show_in_default>
|
475 |
<show_in_website>1</show_in_website>
|
476 |
-
<show_in_store>
|
477 |
-
<depends
|
|
|
|
|
478 |
</new_country_id>
|
479 |
<!-- company -->
|
480 |
<company>
|
@@ -486,7 +540,7 @@
|
|
486 |
<source_model>bronto_common/system_config_source_field</source_model>
|
487 |
<show_in_default>1</show_in_default>
|
488 |
<show_in_website>1</show_in_website>
|
489 |
-
<show_in_store>
|
490 |
</company>
|
491 |
<new_company>
|
492 |
<sort_order>26</sort_order>
|
@@ -494,8 +548,10 @@
|
|
494 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
495 |
<show_in_default>1</show_in_default>
|
496 |
<show_in_website>1</show_in_website>
|
497 |
-
<show_in_store>
|
498 |
-
<depends
|
|
|
|
|
499 |
</new_company>
|
500 |
<!-- telephone -->
|
501 |
<telephone>
|
@@ -507,7 +563,7 @@
|
|
507 |
<source_model>bronto_common/system_config_source_field</source_model>
|
508 |
<show_in_default>1</show_in_default>
|
509 |
<show_in_website>1</show_in_website>
|
510 |
-
<show_in_store>
|
511 |
</telephone>
|
512 |
<new_telephone>
|
513 |
<sort_order>31</sort_order>
|
@@ -515,8 +571,10 @@
|
|
515 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
516 |
<show_in_default>1</show_in_default>
|
517 |
<show_in_website>1</show_in_website>
|
518 |
-
<show_in_store>
|
519 |
-
<depends
|
|
|
|
|
520 |
</new_telephone>
|
521 |
<!-- fax -->
|
522 |
<fax>
|
@@ -528,7 +586,7 @@
|
|
528 |
<source_model>bronto_common/system_config_source_field</source_model>
|
529 |
<show_in_default>1</show_in_default>
|
530 |
<show_in_website>1</show_in_website>
|
531 |
-
<show_in_store>
|
532 |
</fax>
|
533 |
<new_fax>
|
534 |
<sort_order>36</sort_order>
|
@@ -536,8 +594,10 @@
|
|
536 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
537 |
<show_in_default>1</show_in_default>
|
538 |
<show_in_website>1</show_in_website>
|
539 |
-
<show_in_store>
|
540 |
-
<depends
|
|
|
|
|
541 |
</new_fax>
|
542 |
</fields>
|
543 |
</address_attributes>
|
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>
|
40 |
</enabled>
|
41 |
<frequency>
|
42 |
<label>Frequency</label>
|
43 |
+
<depends>
|
44 |
+
<enabled>1</enabled>
|
45 |
+
</depends>
|
46 |
<frontend_type>select</frontend_type>
|
47 |
<source_model>bronto_common/system_config_source_cron_frequency</source_model>
|
48 |
<backend_model>bronto_customer/system_config_backend_cron</backend_model>
|
49 |
<sort_order>20</sort_order>
|
50 |
<show_in_default>1</show_in_default>
|
51 |
<show_in_website>1</show_in_website>
|
52 |
+
<show_in_store>1</show_in_store>
|
53 |
</frequency>
|
54 |
<interval>
|
55 |
<label>Interval</label>
|
56 |
+
<depends>
|
57 |
+
<frequency>I</frequency>
|
58 |
+
</depends>
|
59 |
<frontend_type>select</frontend_type>
|
60 |
<source_model>bronto_common/system_config_source_cron_minutes</source_model>
|
61 |
<sort_order>30</sort_order>
|
62 |
<show_in_default>1</show_in_default>
|
63 |
<show_in_website>1</show_in_website>
|
64 |
+
<show_in_store>1</show_in_store>
|
65 |
<comment>Set this value larger than your cron.php launch period.</comment>
|
66 |
</interval>
|
67 |
<minutes>
|
68 |
<label>Minute of the Hour</label>
|
69 |
+
<depends>
|
70 |
+
<frequency>H</frequency>
|
71 |
+
</depends>
|
72 |
<frontend_type>text</frontend_type>
|
73 |
<sort_order>40</sort_order>
|
74 |
<show_in_default>1</show_in_default>
|
75 |
<show_in_website>1</show_in_website>
|
76 |
+
<show_in_store>1</show_in_store>
|
77 |
<comment>Valid range: 0-59 (default 0).</comment>
|
78 |
</minutes>
|
79 |
<time>
|
80 |
<label>Start Time</label>
|
81 |
+
<depends>
|
82 |
+
<enabled>1</enabled>
|
83 |
+
</depends>
|
84 |
<frontend_type>time</frontend_type>
|
85 |
<sort_order>50</sort_order>
|
86 |
<show_in_default>1</show_in_default>
|
87 |
<show_in_website>1</show_in_website>
|
88 |
+
<show_in_store>1</show_in_store>
|
89 |
+
<comment>H:m:s (*note: seconds are not used)</comment>
|
90 |
</time>
|
91 |
<limit>
|
92 |
<label>Limit</label>
|
93 |
+
<depends>
|
94 |
+
<enabled>1</enabled>
|
95 |
+
</depends>
|
96 |
<frontend_type>select</frontend_type>
|
97 |
+
<source_model>bronto_common/system_config_source_limit</source_model>
|
98 |
<sort_order>60</sort_order>
|
99 |
<show_in_default>1</show_in_default>
|
100 |
<show_in_website>1</show_in_website>
|
101 |
+
<show_in_store>1</show_in_store>
|
102 |
<comment>Total Customers to process every cron run.</comment>
|
103 |
</limit>
|
104 |
+
<sync_limit>
|
105 |
+
<label>Sync Limit</label>
|
106 |
+
<depends>
|
107 |
+
<enabled>1</enabled>
|
108 |
+
</depends>
|
109 |
+
<frontend_type>select</frontend_type>
|
110 |
+
<source_model>bronto_common/system_config_source_synclimit</source_model>
|
111 |
+
<sort_order>65</sort_order>
|
112 |
+
<show_in_default>1</show_in_default>
|
113 |
+
<show_in_website>1</show_in_website>
|
114 |
+
<show_in_store>1</show_in_store>
|
115 |
+
<comment>Total Customers to sync to queue at a time.</comment>
|
116 |
+
</sync_limit>
|
117 |
</fields>
|
118 |
</settings>
|
119 |
<cron_list>
|
121 |
<frontend_model>bronto_customer/adminhtml_system_config_cron</frontend_model>
|
122 |
<sort_order>6</sort_order>
|
123 |
<show_in_default>1</show_in_default>
|
124 |
+
<show_in_website>1</show_in_website>
|
125 |
<show_in_store>1</show_in_store>
|
126 |
</cron_list>
|
127 |
<attributes>
|
131 |
<sort_order>10</sort_order>
|
132 |
<show_in_default>1</show_in_default>
|
133 |
<show_in_website>1</show_in_website>
|
134 |
+
<show_in_store>1</show_in_store>
|
135 |
<fields>
|
136 |
<!-- prefix -->
|
137 |
<prefix>
|
143 |
<source_model>bronto_common/system_config_source_field</source_model>
|
144 |
<show_in_default>1</show_in_default>
|
145 |
<show_in_website>1</show_in_website>
|
146 |
+
<show_in_store>1</show_in_store>
|
147 |
</prefix>
|
148 |
<new_prefix>
|
149 |
<sort_order>2</sort_order>
|
151 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
152 |
<show_in_default>1</show_in_default>
|
153 |
<show_in_website>1</show_in_website>
|
154 |
+
<show_in_store>1</show_in_store>
|
155 |
<depends><prefix>_new_</prefix></depends>
|
156 |
</new_prefix>
|
157 |
<!-- firstname -->
|
164 |
<source_model>bronto_common/system_config_source_field</source_model>
|
165 |
<show_in_default>1</show_in_default>
|
166 |
<show_in_website>1</show_in_website>
|
167 |
+
<show_in_store>1</show_in_store>
|
168 |
</firstname>
|
169 |
<new_firstname>
|
170 |
<sort_order>6</sort_order>
|
172 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
173 |
<show_in_default>1</show_in_default>
|
174 |
<show_in_website>1</show_in_website>
|
175 |
+
<show_in_store>1</show_in_store>
|
176 |
<depends><firstname>_new_</firstname></depends>
|
177 |
</new_firstname>
|
178 |
<!-- middlename -->
|
185 |
<source_model>bronto_common/system_config_source_field</source_model>
|
186 |
<show_in_default>1</show_in_default>
|
187 |
<show_in_website>1</show_in_website>
|
188 |
+
<show_in_store>1</show_in_store>
|
189 |
</middlename>
|
190 |
<new_middlename>
|
191 |
<sort_order>11</sort_order>
|
193 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
194 |
<show_in_default>1</show_in_default>
|
195 |
<show_in_website>1</show_in_website>
|
196 |
+
<show_in_store>1</show_in_store>
|
197 |
<depends><middlename>_new_</middlename></depends>
|
198 |
</new_middlename>
|
199 |
<!-- lastname -->
|
206 |
<source_model>bronto_common/system_config_source_field</source_model>
|
207 |
<show_in_default>1</show_in_default>
|
208 |
<show_in_website>1</show_in_website>
|
209 |
+
<show_in_store>1</show_in_store>
|
210 |
</lastname>
|
211 |
<new_lastname>
|
212 |
<sort_order>16</sort_order>
|
214 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
215 |
<show_in_default>1</show_in_default>
|
216 |
<show_in_website>1</show_in_website>
|
217 |
+
<show_in_store>1</show_in_store>
|
218 |
+
<depends>
|
219 |
+
<lastname>_new_</lastname>
|
220 |
+
</depends>
|
221 |
</new_lastname>
|
222 |
<!-- suffix -->
|
223 |
<suffix>
|
229 |
<source_model>bronto_common/system_config_source_field</source_model>
|
230 |
<show_in_default>1</show_in_default>
|
231 |
<show_in_website>1</show_in_website>
|
232 |
+
<show_in_store>1</show_in_store>
|
233 |
</suffix>
|
234 |
<new_suffix>
|
235 |
<sort_order>21</sort_order>
|
237 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
238 |
<show_in_default>1</show_in_default>
|
239 |
<show_in_website>1</show_in_website>
|
240 |
+
<show_in_store>1</show_in_store>
|
241 |
+
<depends>
|
242 |
+
<suffix>_new_</suffix>
|
243 |
+
</depends>
|
244 |
</new_suffix>
|
245 |
<!-- gender -->
|
246 |
<gender>
|
252 |
<source_model>bronto_common/system_config_source_field</source_model>
|
253 |
<show_in_default>1</show_in_default>
|
254 |
<show_in_website>1</show_in_website>
|
255 |
+
<show_in_store>1</show_in_store>
|
256 |
</gender>
|
257 |
<new_gender>
|
258 |
<sort_order>26</sort_order>
|
260 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
261 |
<show_in_default>1</show_in_default>
|
262 |
<show_in_website>1</show_in_website>
|
263 |
+
<show_in_store>1</show_in_store>
|
264 |
+
<depends>
|
265 |
+
<gender>_new_</gender>
|
266 |
+
</depends>
|
267 |
</new_gender>
|
268 |
<!-- dob -->
|
269 |
<dob>
|
275 |
<source_model>bronto_common/system_config_source_field</source_model>
|
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 |
</dob>
|
280 |
<new_dob>
|
281 |
<sort_order>31</sort_order>
|
283 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
284 |
<show_in_default>1</show_in_default>
|
285 |
<show_in_website>1</show_in_website>
|
286 |
+
<show_in_store>1</show_in_store>
|
287 |
+
<depends>
|
288 |
+
<dob>_new_</dob>
|
289 |
+
</depends>
|
290 |
</new_dob>
|
291 |
<!-- taxvat -->
|
292 |
<taxvat>
|
298 |
<source_model>bronto_common/system_config_source_field</source_model>
|
299 |
<show_in_default>1</show_in_default>
|
300 |
<show_in_website>1</show_in_website>
|
301 |
+
<show_in_store>1</show_in_store>
|
302 |
</taxvat>
|
303 |
<new_taxvat>
|
304 |
<sort_order>36</sort_order>
|
306 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
307 |
<show_in_default>1</show_in_default>
|
308 |
<show_in_website>1</show_in_website>
|
309 |
+
<show_in_store>1</show_in_store>
|
310 |
+
<depends>
|
311 |
+
<taxvat>_new_</taxvat>
|
312 |
+
</depends>
|
313 |
</new_taxvat>
|
314 |
<!-- website_id -->
|
315 |
<website_id>
|
321 |
<source_model>bronto_common/system_config_source_field</source_model>
|
322 |
<show_in_default>1</show_in_default>
|
323 |
<show_in_website>1</show_in_website>
|
324 |
+
<show_in_store>1</show_in_store>
|
325 |
</website_id>
|
326 |
<new_website_id>
|
327 |
<sort_order>41</sort_order>
|
329 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
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 |
+
<depends>
|
334 |
+
<website_id>_new_</website_id>
|
335 |
+
</depends>
|
336 |
</new_website_id>
|
337 |
<!-- group_id -->
|
338 |
<group_id>
|
344 |
<source_model>bronto_common/system_config_source_field</source_model>
|
345 |
<show_in_default>1</show_in_default>
|
346 |
<show_in_website>1</show_in_website>
|
347 |
+
<show_in_store>1</show_in_store>
|
348 |
</group_id>
|
349 |
<new_group_id>
|
350 |
<sort_order>46</sort_order>
|
352 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
353 |
<show_in_default>1</show_in_default>
|
354 |
<show_in_website>1</show_in_website>
|
355 |
+
<show_in_store>1</show_in_store>
|
356 |
+
<depends>
|
357 |
+
<group_id>_new_</group_id>
|
358 |
+
</depends>
|
359 |
</new_group_id>
|
360 |
<!-- created_at -->
|
361 |
<created_at>
|
367 |
<source_model>bronto_common/system_config_source_field</source_model>
|
368 |
<show_in_default>1</show_in_default>
|
369 |
<show_in_website>1</show_in_website>
|
370 |
+
<show_in_store>1</show_in_store>
|
371 |
</created_at>
|
372 |
<new_created_at>
|
373 |
<sort_order>51</sort_order>
|
375 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
376 |
<show_in_default>1</show_in_default>
|
377 |
<show_in_website>1</show_in_website>
|
378 |
+
<show_in_store>1</show_in_store>
|
379 |
+
<depends>
|
380 |
+
<created_at>_new_</created_at>
|
381 |
+
</depends>
|
382 |
</new_created_at>
|
383 |
<!-- created_in -->
|
384 |
<created_in>
|
390 |
<source_model>bronto_common/system_config_source_field</source_model>
|
391 |
<show_in_default>1</show_in_default>
|
392 |
<show_in_website>1</show_in_website>
|
393 |
+
<show_in_store>1</show_in_store>
|
394 |
</created_in>
|
395 |
<new_created_in>
|
396 |
<sort_order>56</sort_order>
|
398 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
399 |
<show_in_default>1</show_in_default>
|
400 |
<show_in_website>1</show_in_website>
|
401 |
+
<show_in_store>1</show_in_store>
|
402 |
+
<depends>
|
403 |
+
<created_in>_new_</created_in>
|
404 |
+
</depends>
|
405 |
</new_created_in>
|
406 |
</fields>
|
407 |
</attributes>
|
408 |
<address_attributes>
|
409 |
<label>Address Attributes</label>
|
410 |
<frontend_type>text</frontend_type>
|
411 |
+
<frontend_model>bronto_customer/adminhtml_system_config_form_fieldset_attributes_address
|
412 |
+
</frontend_model>
|
413 |
<sort_order>15</sort_order>
|
414 |
<show_in_default>1</show_in_default>
|
415 |
<show_in_website>1</show_in_website>
|
416 |
+
<show_in_store>1</show_in_store>
|
417 |
<fields>
|
418 |
<!-- street -->
|
419 |
<street>
|
425 |
<source_model>bronto_common/system_config_source_field</source_model>
|
426 |
<show_in_default>1</show_in_default>
|
427 |
<show_in_website>1</show_in_website>
|
428 |
+
<show_in_store>1</show_in_store>
|
429 |
</street>
|
430 |
<new_street>
|
431 |
<sort_order>2</sort_order>
|
433 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
434 |
<show_in_default>1</show_in_default>
|
435 |
<show_in_website>1</show_in_website>
|
436 |
+
<show_in_store>1</show_in_store>
|
437 |
+
<depends>
|
438 |
+
<street>_new_</street>
|
439 |
+
</depends>
|
440 |
</new_street>
|
441 |
<!-- city -->
|
442 |
<city>
|
448 |
<source_model>bronto_common/system_config_source_field</source_model>
|
449 |
<show_in_default>1</show_in_default>
|
450 |
<show_in_website>1</show_in_website>
|
451 |
+
<show_in_store>1</show_in_store>
|
452 |
</city>
|
453 |
<new_city>
|
454 |
<sort_order>6</sort_order>
|
456 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
457 |
<show_in_default>1</show_in_default>
|
458 |
<show_in_website>1</show_in_website>
|
459 |
+
<show_in_store>1</show_in_store>
|
460 |
+
<depends>
|
461 |
+
<city>_new_</city>
|
462 |
+
</depends>
|
463 |
</new_city>
|
464 |
<!-- region -->
|
465 |
<region>
|
471 |
<source_model>bronto_common/system_config_source_field</source_model>
|
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 |
</region>
|
476 |
<new_region>
|
477 |
<sort_order>11</sort_order>
|
479 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
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 |
+
<depends>
|
484 |
+
<region>_new_</region>
|
485 |
+
</depends>
|
486 |
</new_region>
|
487 |
<!-- postcode -->
|
488 |
<postcode>
|
494 |
<source_model>bronto_common/system_config_source_field</source_model>
|
495 |
<show_in_default>1</show_in_default>
|
496 |
<show_in_website>1</show_in_website>
|
497 |
+
<show_in_store>1</show_in_store>
|
498 |
</postcode>
|
499 |
<new_postcode>
|
500 |
<sort_order>16</sort_order>
|
502 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
503 |
<show_in_default>1</show_in_default>
|
504 |
<show_in_website>1</show_in_website>
|
505 |
+
<show_in_store>1</show_in_store>
|
506 |
+
<depends>
|
507 |
+
<postcode>_new_</postcode>
|
508 |
+
</depends>
|
509 |
</new_postcode>
|
510 |
<!-- country_id -->
|
511 |
<country_id>
|
517 |
<source_model>bronto_common/system_config_source_field</source_model>
|
518 |
<show_in_default>1</show_in_default>
|
519 |
<show_in_website>1</show_in_website>
|
520 |
+
<show_in_store>1</show_in_store>
|
521 |
</country_id>
|
522 |
<new_country_id>
|
523 |
<sort_order>21</sort_order>
|
525 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
526 |
<show_in_default>1</show_in_default>
|
527 |
<show_in_website>1</show_in_website>
|
528 |
+
<show_in_store>1</show_in_store>
|
529 |
+
<depends>
|
530 |
+
<country_id>_new_</country_id>
|
531 |
+
</depends>
|
532 |
</new_country_id>
|
533 |
<!-- company -->
|
534 |
<company>
|
540 |
<source_model>bronto_common/system_config_source_field</source_model>
|
541 |
<show_in_default>1</show_in_default>
|
542 |
<show_in_website>1</show_in_website>
|
543 |
+
<show_in_store>1</show_in_store>
|
544 |
</company>
|
545 |
<new_company>
|
546 |
<sort_order>26</sort_order>
|
548 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
549 |
<show_in_default>1</show_in_default>
|
550 |
<show_in_website>1</show_in_website>
|
551 |
+
<show_in_store>1</show_in_store>
|
552 |
+
<depends>
|
553 |
+
<company>_new_</company>
|
554 |
+
</depends>
|
555 |
</new_company>
|
556 |
<!-- telephone -->
|
557 |
<telephone>
|
563 |
<source_model>bronto_common/system_config_source_field</source_model>
|
564 |
<show_in_default>1</show_in_default>
|
565 |
<show_in_website>1</show_in_website>
|
566 |
+
<show_in_store>1</show_in_store>
|
567 |
</telephone>
|
568 |
<new_telephone>
|
569 |
<sort_order>31</sort_order>
|
571 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
572 |
<show_in_default>1</show_in_default>
|
573 |
<show_in_website>1</show_in_website>
|
574 |
+
<show_in_store>1</show_in_store>
|
575 |
+
<depends>
|
576 |
+
<telephone>_new_</telephone>
|
577 |
+
</depends>
|
578 |
</new_telephone>
|
579 |
<!-- fax -->
|
580 |
<fax>
|
586 |
<source_model>bronto_common/system_config_source_field</source_model>
|
587 |
<show_in_default>1</show_in_default>
|
588 |
<show_in_website>1</show_in_website>
|
589 |
+
<show_in_store>1</show_in_store>
|
590 |
</fax>
|
591 |
<new_fax>
|
592 |
<sort_order>36</sort_order>
|
594 |
<backend_model>bronto_customer/system_config_backend_newfield</backend_model>
|
595 |
<show_in_default>1</show_in_default>
|
596 |
<show_in_website>1</show_in_website>
|
597 |
+
<show_in_store>1</show_in_store>
|
598 |
+
<depends>
|
599 |
+
<fax>_new_</fax>
|
600 |
+
</depends>
|
601 |
</new_fax>
|
602 |
</fields>
|
603 |
</address_attributes>
|
app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-install-1.0.0.php
CHANGED
@@ -8,7 +8,7 @@ $installer->startSetup();
|
|
8 |
//
|
9 |
// Customer Attributes
|
10 |
$installer->addAttribute('customer', 'bronto_imported', array(
|
11 |
-
'type'
|
12 |
'required' => false,
|
13 |
));
|
14 |
|
8 |
//
|
9 |
// Customer Attributes
|
10 |
$installer->addAttribute('customer', 'bronto_imported', array(
|
11 |
+
'type' => 'datetime',
|
12 |
'required' => false,
|
13 |
));
|
14 |
|
app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-install-1.0.3.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 (`queue_id`,`customer_id`,`store_id`),
|
22 |
+
KEY `IDX_BRONTO_CUSTOMER_QUEUE_STORE_ID` (`store_id`),
|
23 |
+
KEY `IDX_BRONTO_CUSTOMER_QUEUE_BRONTO_IMPORTED` (`bronto_imported`),
|
24 |
+
KEY `IDX_BRONTO_CUSTOMER_QUEUE_CREATED_AT` (`created_at`),
|
25 |
+
KEY `IDX_BRONTO_CUSTOMER_QUEUE_UPDATED_AT` (`updated_at`),
|
26 |
+
CONSTRAINT `FK_BRONTO_CUSTOMER_QUEUE_STORE_ID_CORE_STORE_STORE_ID` FOREIGN KEY (`store_id`)
|
27 |
+
REFERENCES `{$this->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
|
28 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Customer Import Queue';
|
29 |
+
");
|
30 |
+
} catch (Exception $e) {
|
31 |
+
throw new RuntimeException('Failed Creating Customer Queue Table: ' . $e->getMessage());
|
32 |
+
}
|
33 |
+
|
34 |
+
try {
|
35 |
+
// Populate New Table
|
36 |
+
$installer->run("
|
37 |
+
INSERT IGNORE INTO `{$this->getTable('bronto_customer_queue')}`
|
38 |
+
(`customer_id`, `store_id`, `bronto_imported`, `created_at`, `updated_at`)
|
39 |
+
SELECT `ce`.`entity_id`, `ce`.`store_id`, null, `ce`.`created_at`, `ce`.`updated_at`
|
40 |
+
FROM `{$this->getTable('customer_entity')}` `ce`
|
41 |
+
WHERE `ce`.`is_active` = 1;
|
42 |
+
");
|
43 |
+
} catch (Exception $e) {
|
44 |
+
throw new RuntimeException('Failed Populating Customer Queue Table: ' . $e->getMessage());
|
45 |
+
}
|
46 |
+
|
47 |
+
$installer->endSetup();
|
app/code/community/Bronto/Customer/sql/bronto_customer_setup/mysql4-upgrade-1.0.0-1.0.1.php
CHANGED
@@ -25,7 +25,7 @@ try {
|
|
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')}`
|
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')}`
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/About.php
CHANGED
@@ -15,5 +15,5 @@ class Bronto_Email_Block_Adminhtml_System_Config_About extends Bronto_Common_Blo
|
|
15 |
/**
|
16 |
* @var string
|
17 |
*/
|
18 |
-
protected $_name
|
19 |
}
|
15 |
/**
|
16 |
* @var string
|
17 |
*/
|
18 |
+
protected $_name = 'Bronto Transactional Email Module';
|
19 |
}
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Settings.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @package Bronto\Reminder
|
5 |
+
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
+
* @version 1.5.0
|
7 |
+
*/
|
8 |
+
class Bronto_Email_Block_Adminhtml_System_Config_Settings
|
9 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Return header comment part of html for fieldset
|
13 |
+
*
|
14 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
15 |
+
* @return string
|
16 |
+
*/
|
17 |
+
protected function _getHeaderCommentHtml($element)
|
18 |
+
{
|
19 |
+
$url = Mage::helper('adminhtml')->getUrl('/system_email_template');
|
20 |
+
$element->setComment("Additional configuration located at: <strong>System › <a href=\"{$url}\">Transactional Emails</a></strong><br/><br/>");
|
21 |
+
return parent::_getHeaderCommentHtml($element);
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates.php
ADDED
@@ -0,0 +1,210 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @package Bronto\Reminder
|
5 |
+
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
+
* @version 1.5.0
|
7 |
+
*/
|
8 |
+
class Bronto_Email_Block_Adminhtml_System_Config_Templates
|
9 |
+
extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
10 |
+
{
|
11 |
+
const XML_PATH_TEMPLATE_EMAIL = '//sections/*/groups/*/fields/*[source_model="adminhtml/system_config_source_email_template"]';
|
12 |
+
|
13 |
+
protected $_dummySubset;
|
14 |
+
protected $_fieldRenderer;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* Return header comment part of html for fieldset
|
18 |
+
*
|
19 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
20 |
+
* @return string
|
21 |
+
*/
|
22 |
+
protected function _getHeaderCommentHtml($element)
|
23 |
+
{
|
24 |
+
$element->setComment("<strong>This form is provided as a centralized location for assigning all Magento email templates.<br />Each section contains a link to where this action would normally be performed.</strong><br /><br />");
|
25 |
+
return parent::_getHeaderCommentHtml($element);
|
26 |
+
}
|
27 |
+
|
28 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
29 |
+
{
|
30 |
+
// Only show template mapping if module is enabled
|
31 |
+
if (!$this->helper('bronto_email')->isEnabled()) {
|
32 |
+
return '';
|
33 |
+
}
|
34 |
+
|
35 |
+
$html = $this->_getHeaderHtml($element);
|
36 |
+
|
37 |
+
$fields = $this->_getSystemConfigPathsParts();
|
38 |
+
|
39 |
+
$order = 0;
|
40 |
+
foreach ($fields as $section => $groups) {
|
41 |
+
$html .= $this->_getSubsetHtml($element, $section, $groups, $order);
|
42 |
+
$order = $order + 5;
|
43 |
+
}
|
44 |
+
|
45 |
+
$html .= $this->_getFooterHtml($element);
|
46 |
+
|
47 |
+
return $html;
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Adds fields to the child fieldset
|
52 |
+
*
|
53 |
+
* @param Varien_Data_Form_Element_Abstract $fieldset
|
54 |
+
* @param Varien_Object $element
|
55 |
+
* @return Varien_Data_Form_Element_Abstract
|
56 |
+
*/
|
57 |
+
protected function _addSubFields($fieldset, $element) {
|
58 |
+
$configCode = 'bronto_email_templates_label_' . $element->getSection();
|
59 |
+
|
60 |
+
if ($element->frontend_model) {
|
61 |
+
$fieldRenderer = Mage::getBlockSingleton((string)$element->frontend_model);
|
62 |
+
} else {
|
63 |
+
$fieldRenderer = $this->_getFieldRenderer();
|
64 |
+
}
|
65 |
+
|
66 |
+
$labelLink = $element->getLabel();
|
67 |
+
$label = sprintf('<a href="%s" title="%s">%s</a>',
|
68 |
+
$labelLink['url'],
|
69 |
+
$labelLink['title'],
|
70 |
+
$labelLink['title']
|
71 |
+
);
|
72 |
+
|
73 |
+
try {
|
74 |
+
$field = $fieldset->addFieldSet($configCode,
|
75 |
+
array(
|
76 |
+
'label' => $label,
|
77 |
+
'inherit' => false,
|
78 |
+
'field_config' => $element,
|
79 |
+
'scope' => $this->getForm()->getScope(),
|
80 |
+
'scopeId' => $this->getForm()->getScopeId(),
|
81 |
+
'can_use_default_value' => $this->getForm()->canUseDefaultValue((int)$element->show_in_default),
|
82 |
+
'can_use_website_value' => $this->getForm()->canUseWebsiteValue((int)$element->show_in_website),
|
83 |
+
)
|
84 |
+
);
|
85 |
+
|
86 |
+
$fieldRenderer->setForm($this->getForm());
|
87 |
+
$field->setRenderer($fieldRenderer);
|
88 |
+
} catch (Exception $e) {
|
89 |
+
Mage::helper('bronto_customer')->writeDebug('Creating field failed: ' . $e->getMessage());
|
90 |
+
return '';
|
91 |
+
}
|
92 |
+
|
93 |
+
return $field;
|
94 |
+
}
|
95 |
+
|
96 |
+
/**
|
97 |
+
* Gets the subfieldset HTML
|
98 |
+
*
|
99 |
+
* @param Varien_Data_Form_Element_Abstract $fieldset
|
100 |
+
* @param string $section
|
101 |
+
* @param array $groups
|
102 |
+
* @param int $order
|
103 |
+
* @return string
|
104 |
+
*/
|
105 |
+
protected function _getSubsetHtml($fieldset, $section, $groups, $order) {
|
106 |
+
$data = current($groups);
|
107 |
+
$element = $this->_getDummySubset($order);
|
108 |
+
$element
|
109 |
+
->setLabel($data['parts'][1])
|
110 |
+
->setSection($section)
|
111 |
+
->setGroups($groups);
|
112 |
+
|
113 |
+
$tempFieldset = $this->_addSubFields($fieldset, $element);
|
114 |
+
if (!$tempFieldset) {
|
115 |
+
return '';
|
116 |
+
}
|
117 |
+
|
118 |
+
return $tempFieldset->toHtml();
|
119 |
+
}
|
120 |
+
|
121 |
+
/**
|
122 |
+
* this sets the fields renderer. If you have a custom renderer you can change this.
|
123 |
+
* @return type
|
124 |
+
*/
|
125 |
+
protected function _getFieldRenderer()
|
126 |
+
{
|
127 |
+
if (empty($this->_fieldRenderer)) {
|
128 |
+
$this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
|
129 |
+
}
|
130 |
+
return $this->_fieldRenderer;
|
131 |
+
}
|
132 |
+
|
133 |
+
/**
|
134 |
+
* Gets the dummy fieldset config
|
135 |
+
*
|
136 |
+
* @param int $order
|
137 |
+
* @return Varien_Object
|
138 |
+
*/
|
139 |
+
protected function _getDummySubset($order) {
|
140 |
+
if (empty($this->_dummySubset)) {
|
141 |
+
$this->_dummySubset = new Varien_Object(array(
|
142 |
+
'sort_order' => $order,
|
143 |
+
'frontend_type' => 'text',
|
144 |
+
'frontend_model' => 'bronto_email/adminhtml_system_config_templates_fieldset',
|
145 |
+
'show_in_store' => 1,
|
146 |
+
'show_in_default' => 1,
|
147 |
+
'show_in_website' => 1,
|
148 |
+
));
|
149 |
+
}
|
150 |
+
|
151 |
+
return $this->_dummySubset;
|
152 |
+
}
|
153 |
+
|
154 |
+
/**
|
155 |
+
* Get Array of all config path details
|
156 |
+
* @param type $paths
|
157 |
+
* @return type
|
158 |
+
*/
|
159 |
+
protected function _getSystemConfigPathsParts()
|
160 |
+
{
|
161 |
+
$result = $urlParams = $prefixParts = array();
|
162 |
+
$scopeLabel = Mage::helper('adminhtml')->__('GLOBAL');
|
163 |
+
$paths = Mage::helper('bronto_email')->getTemplatePaths();
|
164 |
+
|
165 |
+
if ($paths) {
|
166 |
+
$prefixParts[] = array(
|
167 |
+
'title' => Mage::getSingleton('admin/config')->getMenuItemLabel('system/config'),
|
168 |
+
);
|
169 |
+
|
170 |
+
$pathParts = $prefixParts;
|
171 |
+
foreach ($paths as $pathData) {
|
172 |
+
list($sectionName, $groupName, $fieldName) = explode('/', $pathData);
|
173 |
+
$urlParams = array('section' => $sectionName);
|
174 |
+
$scopeParams = Mage::helper('bronto_email')->getScopeParams();
|
175 |
+
|
176 |
+
if (isset($scopeParams['store'])) {
|
177 |
+
$store = Mage::app()->getStore($scopeParams['store']);
|
178 |
+
if ($store) {
|
179 |
+
$urlParams['website'] = $store->getWebsite()->getCode();
|
180 |
+
$urlParams['store'] = $store->getCode();
|
181 |
+
$scopeLabel = $store->getWebsite()->getName() . '/' . $store->getName();
|
182 |
+
}
|
183 |
+
} else if (isset($scopeParams['website'])) {
|
184 |
+
$website = Mage::app()->getWebsite($scopeParams['website']);
|
185 |
+
if ($website) {
|
186 |
+
$urlParams['website'] = $website->getCode();
|
187 |
+
$scopeLabel = $website->getName();
|
188 |
+
}
|
189 |
+
}
|
190 |
+
|
191 |
+
$adminhtmlConfig = Mage::getSingleton('adminhtml/config');
|
192 |
+
$adminhtmlConfig->getSections();
|
193 |
+
|
194 |
+
$pathParts[] = array(
|
195 |
+
'title' => $adminhtmlConfig->getSystemConfigNodeLabel($sectionName),
|
196 |
+
'url' => $this->getUrl('adminhtml/system_config/edit', $urlParams),
|
197 |
+
);
|
198 |
+
$pathParts[] = array(
|
199 |
+
'title' => $adminhtmlConfig->getSystemConfigNodeLabel($sectionName, $groupName),
|
200 |
+
);
|
201 |
+
|
202 |
+
$result[$sectionName][$groupName]['parts'] = $pathParts;
|
203 |
+
$result[$sectionName][$groupName]['fields'][$fieldName]['path'] = $pathData;
|
204 |
+
$pathParts = $prefixParts;
|
205 |
+
}
|
206 |
+
}
|
207 |
+
|
208 |
+
return $result;
|
209 |
+
}
|
210 |
+
}
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Field.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @return string
|
13 |
+
*/
|
14 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
15 |
+
{
|
16 |
+
$realpath = str_replace('-', '/', str_replace('bronto_email_templates_', '', $element->getId()));
|
17 |
+
$realValue = Mage::helper('bronto_email')->getAdminScopedConfig($realpath);
|
18 |
+
$element->setValue($realValue);
|
19 |
+
$element->setPath($realpath);
|
20 |
+
|
21 |
+
return parent::render($element);
|
22 |
+
}
|
23 |
+
|
24 |
+
}
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Fieldset.php
ADDED
@@ -0,0 +1,390 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bronto_Email_Block_Adminhtml_System_Config_Templates_Fieldset extends Mage_Adminhtml_Block_System_Config_Form_Fieldset {
|
4 |
+
|
5 |
+
protected $_dummyElement;
|
6 |
+
protected $_dummyLabel;
|
7 |
+
protected $_fieldRenderer;
|
8 |
+
|
9 |
+
/**
|
10 |
+
* @see parent
|
11 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
12 |
+
* @return string
|
13 |
+
*/
|
14 |
+
protected function _getHeaderHtml($element) {
|
15 |
+
return '<tr id="' . $element->getId() . '"><td cellspan="5">
|
16 |
+
<fieldset><legend style="font-weight:bold; visibility:inherit; font-size:16px; width:inherit; height:inherit; line-height:inherit;">' . $element->getLabel() . '</legend>
|
17 |
+
<table class="form-list" cellspacing="0">';
|
18 |
+
}
|
19 |
+
|
20 |
+
/**
|
21 |
+
* @see parent
|
22 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
23 |
+
* @return string
|
24 |
+
*/
|
25 |
+
protected function _getFooterHtml($element) {
|
26 |
+
return '</table></fieldset></td></tr>';
|
27 |
+
}
|
28 |
+
|
29 |
+
/**
|
30 |
+
* @see parent
|
31 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
32 |
+
* @return string
|
33 |
+
*/
|
34 |
+
public function render(Varien_Data_Form_Element_Abstract $element) {
|
35 |
+
$html = $this->_getHeaderHtml($element);
|
36 |
+
$order = 0;
|
37 |
+
foreach ($element->getFieldConfig()->getGroups() as $group => $groupData) {
|
38 |
+
$order = $order + 5;
|
39 |
+
$html .= $this->_getLabelHtml($element, $element->getFieldConfig()->getSection(), $group, $groupData, $order);
|
40 |
+
foreach ($groupData['fields'] as $field) {
|
41 |
+
try {
|
42 |
+
$order = $order + 5;
|
43 |
+
$html .= $this->_getFieldHtml($element, $field, $order);
|
44 |
+
} catch (Exception $e) {
|
45 |
+
Mage::helper('bronto_customer')->writeDebug('Creating field failed: ' . $e->getMessage());
|
46 |
+
}
|
47 |
+
}
|
48 |
+
}
|
49 |
+
|
50 |
+
$html .= $this->_getFooterHtml($element);
|
51 |
+
return $html;
|
52 |
+
}
|
53 |
+
|
54 |
+
/**
|
55 |
+
* this sets the fields renderer. If you have a custom renderer you can change this.
|
56 |
+
* @return type
|
57 |
+
*/
|
58 |
+
protected function _getFieldRenderer()
|
59 |
+
{
|
60 |
+
if (empty($this->_fieldRenderer)) {
|
61 |
+
$this->_fieldRenderer = Mage::getBlockSingleton('adminhtml/system_config_form_field');
|
62 |
+
}
|
63 |
+
return $this->_fieldRenderer;
|
64 |
+
}
|
65 |
+
|
66 |
+
/**
|
67 |
+
* Get HTML for field element
|
68 |
+
* @param Varien_Data_Form_Element_Abstract $fieldset
|
69 |
+
* @param array $field
|
70 |
+
* @param int $order
|
71 |
+
* @return string
|
72 |
+
*/
|
73 |
+
protected function _getFieldHtml(Varien_Data_Form_Element_Abstract $fieldset, array $field, $order)
|
74 |
+
{
|
75 |
+
// Create Select Field
|
76 |
+
$element = $this->_getDummyElement($order);
|
77 |
+
$tempField = $this->_createField($fieldset, $element, $field);
|
78 |
+
if (!$tempField) {
|
79 |
+
return '';
|
80 |
+
}
|
81 |
+
|
82 |
+
return $tempField->toHtml();
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Get HTML for label element
|
87 |
+
* @param Varien_Data_Form_Element_Abstract $fieldset
|
88 |
+
* @param string $section
|
89 |
+
* @param string $group
|
90 |
+
* @param array $groupData
|
91 |
+
* @param int $order
|
92 |
+
* @return string
|
93 |
+
*/
|
94 |
+
protected function _getLabelHtml(Varien_Data_Form_Element_Abstract $fieldset, $section, $group, array $groupData, $order)
|
95 |
+
{
|
96 |
+
$element = $this->_getDummyLabel($order);
|
97 |
+
$label = $this->_createLabel($fieldset, $element, $groupData, $section, $group);
|
98 |
+
if (!$label) {
|
99 |
+
return '';
|
100 |
+
}
|
101 |
+
|
102 |
+
return $label->toHtml();
|
103 |
+
}
|
104 |
+
|
105 |
+
/**
|
106 |
+
* Get dummy field element to set specific configurations
|
107 |
+
* @param int $order
|
108 |
+
* @return Varien_Object
|
109 |
+
*/
|
110 |
+
protected function _getDummyElement($order)
|
111 |
+
{
|
112 |
+
if (empty($this->_dummyElement)) {
|
113 |
+
$this->_dummyElement = new Varien_Object(array(
|
114 |
+
'sort_order' => $order,
|
115 |
+
'frontend_type' => 'select',
|
116 |
+
'frontend_model' => 'bronto_email/adminhtml_system_config_templates_field',
|
117 |
+
'backend_model' => 'bronto_email/system_config_backend_templates_field',
|
118 |
+
'source_model' => 'bronto_email/system_config_source_email_template',
|
119 |
+
'show_in_default' => 1,
|
120 |
+
'show_in_website' => 1,
|
121 |
+
'show_in_store' => 1,
|
122 |
+
));
|
123 |
+
}
|
124 |
+
|
125 |
+
return $this->_dummyElement;
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Get dummy label element to set specific configurations
|
130 |
+
* @param int $order
|
131 |
+
* @return Varien_Object
|
132 |
+
*/
|
133 |
+
protected function _getDummyLabel($order)
|
134 |
+
{
|
135 |
+
if (empty($this->_dummyLabel)) {
|
136 |
+
$this->_dummyLabel = new Varien_Object(array(
|
137 |
+
'sort_order' => $order,
|
138 |
+
'frontend_type' => 'label',
|
139 |
+
'frontend_model' => 'bronto_email/adminhtml_system_config_templates_label',
|
140 |
+
'show_in_default' => 1,
|
141 |
+
'show_in_website' => 1,
|
142 |
+
'show_in_store' => 1,
|
143 |
+
));
|
144 |
+
}
|
145 |
+
|
146 |
+
return $this->_dummyLabel;
|
147 |
+
}
|
148 |
+
|
149 |
+
/**
|
150 |
+
* Create Field and Return it
|
151 |
+
* @param Varien_Data_Form_Element_Abstract $fieldset
|
152 |
+
* @param Varien_Object $element
|
153 |
+
* @param array $field
|
154 |
+
* @return Varien_Data_Form_Element_Abstract
|
155 |
+
*/
|
156 |
+
protected function _createField(
|
157 |
+
Varien_Data_Form_Element_Abstract $fieldset,
|
158 |
+
Varien_Object $element,
|
159 |
+
array $field
|
160 |
+
)
|
161 |
+
{
|
162 |
+
// Get Attribute Data and Inheritance
|
163 |
+
$path = $field['path'];
|
164 |
+
|
165 |
+
// Get Config Data
|
166 |
+
$configData = $this->getConfigData($path);
|
167 |
+
|
168 |
+
// Build Id and Code from Path
|
169 |
+
$fieldId = implode('-', explode('/', $field['path']));
|
170 |
+
$fieldCode = 'bronto_email_templates_' . $fieldId;
|
171 |
+
|
172 |
+
$data = false;
|
173 |
+
$inherit = true;
|
174 |
+
if (array_key_exists($path, $configData)) {
|
175 |
+
$data = $configData[$path]['data'];
|
176 |
+
$inherit = $configData[$path]['inherit'];
|
177 |
+
}
|
178 |
+
|
179 |
+
if (!$data) {
|
180 |
+
$data = (string)Mage::getConfig()->getNode(null, $this->getForm()->getScope(), $this->getForm()->getScopeCode())->descend($path);
|
181 |
+
$inherit = true;
|
182 |
+
}
|
183 |
+
|
184 |
+
// Get field Renderer
|
185 |
+
if ($element->frontend_model) {
|
186 |
+
$fieldRenderer = Mage::getBlockSingleton((string)$element->frontend_model);
|
187 |
+
} else {
|
188 |
+
$fieldRenderer = $this->_getFieldRenderer();
|
189 |
+
}
|
190 |
+
|
191 |
+
// Define Type, Name, and Label
|
192 |
+
$fieldType = (string)$element->frontend_type ? (string)$element->frontend_type : 'text';
|
193 |
+
$name = 'groups[templates][fields][' . $fieldId . '][value]';
|
194 |
+
|
195 |
+
// Build Field Label from path
|
196 |
+
$pathParts = explode('/', $path);
|
197 |
+
$labelPart = array_pop($pathParts);
|
198 |
+
$label = str_replace('_', ' ', uc_words($labelPart));
|
199 |
+
|
200 |
+
// Pass through backend model in case it needs to modify value
|
201 |
+
if ($element->backend_model) {
|
202 |
+
$model = Mage::getModel((string)$element->backend_model);
|
203 |
+
if (!$model instanceof Mage_Core_Model_Config_Data) {
|
204 |
+
Mage::throwException('Invalid config field backend model: ' . (string)$element->backend_model);
|
205 |
+
}
|
206 |
+
$model->setPath($path)->setValue($data)->afterLoad();
|
207 |
+
$data = $model->getValue();
|
208 |
+
}
|
209 |
+
|
210 |
+
// Select Field for Existing attributes.
|
211 |
+
$field = $fieldset->addField($fieldCode, $fieldType,
|
212 |
+
array(
|
213 |
+
'name' => $name,
|
214 |
+
'label' => $label,
|
215 |
+
'value' => $data,
|
216 |
+
'inherit' => $inherit,
|
217 |
+
'field_config' => $element,
|
218 |
+
'scope' => $this->getForm()->getScope(),
|
219 |
+
'scopeId' => $this->getForm()->getScopeId(),
|
220 |
+
'scope_label' => $this->getForm()->getScopeLabel($element),
|
221 |
+
'can_use_default_value' => $this->getForm()->canUseDefaultValue((int)$element->show_in_default),
|
222 |
+
'can_use_website_value' => $this->getForm()->canUseWebsiteValue((int)$element->show_in_website),
|
223 |
+
)
|
224 |
+
);
|
225 |
+
|
226 |
+
// Add Validation
|
227 |
+
if ($element->validate) {
|
228 |
+
$field->addClass($element->validate);
|
229 |
+
}
|
230 |
+
|
231 |
+
// Determine if value can be empty
|
232 |
+
if (isset($element->frontend_type) && 'multiselect' === (string)$element->frontend_type && isset($element->can_be_empty)) {
|
233 |
+
$field->setCanBeEmpty(true);
|
234 |
+
}
|
235 |
+
|
236 |
+
// Set Field Renderer
|
237 |
+
$field->setRenderer($fieldRenderer);
|
238 |
+
|
239 |
+
// Use Source Model to define available options
|
240 |
+
if ($element->source_model) {
|
241 |
+
$sourceModel = Mage::getSingleton((string)$element->source_model);
|
242 |
+
if ($sourceModel instanceof Varien_Object) {
|
243 |
+
$sourceModel->setPath($path);
|
244 |
+
}
|
245 |
+
|
246 |
+
$field->setValues($sourceModel->toOptionArray());
|
247 |
+
}
|
248 |
+
|
249 |
+
return $field;
|
250 |
+
}
|
251 |
+
|
252 |
+
/**
|
253 |
+
* Create Label and Return it
|
254 |
+
* @param Varien_Data_Form_Element_Abstract $fieldset
|
255 |
+
* @param Varien_Object $e
|
256 |
+
* @param array $field
|
257 |
+
* @return Varien_Data_Form_Element_Abstract
|
258 |
+
*/
|
259 |
+
protected function _createLabel(
|
260 |
+
Varien_Data_Form_Element_Abstract $fieldset,
|
261 |
+
Varien_Object $element,
|
262 |
+
array $groupData,
|
263 |
+
$section,
|
264 |
+
$group
|
265 |
+
)
|
266 |
+
{
|
267 |
+
$configCode = 'bronto_email_templates_label_' . $section . '_' . $group;
|
268 |
+
|
269 |
+
$data = $groupData['parts'][2]['title'];
|
270 |
+
$inherit = false;
|
271 |
+
|
272 |
+
// Get field Renderer
|
273 |
+
if ($element->frontend_model) {
|
274 |
+
$fieldRenderer = Mage::getBlockSingleton((string)$element->frontend_model);
|
275 |
+
} else {
|
276 |
+
$fieldRenderer = $this->_getFieldRenderer();
|
277 |
+
}
|
278 |
+
|
279 |
+
// Define Type, Name, and Label
|
280 |
+
$fieldType = 'label';
|
281 |
+
$label = $data;
|
282 |
+
|
283 |
+
try {
|
284 |
+
// Select Field for Existing attributes.
|
285 |
+
$field = $fieldset->addField($configCode, $fieldType,
|
286 |
+
array(
|
287 |
+
'label' => $label,
|
288 |
+
'inherit' => $inherit,
|
289 |
+
'field_config' => $element,
|
290 |
+
'scope' => $this->getForm()->getScope(),
|
291 |
+
'scopeId' => $this->getForm()->getScopeId(),
|
292 |
+
'can_use_default_value' => $this->getForm()->canUseDefaultValue((int)$element->show_in_default),
|
293 |
+
'can_use_website_value' => $this->getForm()->canUseWebsiteValue((int)$element->show_in_website),
|
294 |
+
)
|
295 |
+
);
|
296 |
+
|
297 |
+
// Set Field Renderer
|
298 |
+
$field->setRenderer($fieldRenderer);
|
299 |
+
} catch (Exception $e) {
|
300 |
+
Mage::helper('bronto_customer')->writeDebug('Creating field failed: ' . $e->getMessage());
|
301 |
+
return '';
|
302 |
+
}
|
303 |
+
|
304 |
+
return $field;
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Override getConfigData to handle us altering the path
|
309 |
+
* @param type $path
|
310 |
+
* @return type
|
311 |
+
*/
|
312 |
+
public function getConfigData($path)
|
313 |
+
{
|
314 |
+
$configData = array();
|
315 |
+
/* @var $configDataCollection Mage_Core_Model_Resource_Config_Data_Collection */
|
316 |
+
$configDataCollection = $this->_getConfigCollection($path);
|
317 |
+
|
318 |
+
// Get Scope
|
319 |
+
$scope = $this->getForm()->getScope();
|
320 |
+
$scopeId = $this->getForm()->getScopeId();
|
321 |
+
|
322 |
+
$inherit = false;
|
323 |
+
if ($configDataCollection->count()) {
|
324 |
+
while ($scope) {
|
325 |
+
foreach ($configDataCollection as $config) {
|
326 |
+
if (
|
327 |
+
($scope == $config->getScope() || $scope . 's' == $config->getScope()) &&
|
328 |
+
($scopeId == $config->getScopeId()) &&
|
329 |
+
(!is_null($config->getValue()))
|
330 |
+
) {
|
331 |
+
$configData[$path]['data'] = $config->getValue();
|
332 |
+
$configData[$path]['inherit'] = $inherit;
|
333 |
+
return $configData;
|
334 |
+
}
|
335 |
+
}
|
336 |
+
$scopeParent = $this->_getScopeParent($scope, $scopeId);
|
337 |
+
$scope = $scopeParent['scope'];
|
338 |
+
$scopeId = $scopeParent['scope_id'];
|
339 |
+
$inherit = true;
|
340 |
+
}
|
341 |
+
}
|
342 |
+
|
343 |
+
return $configData;
|
344 |
+
}
|
345 |
+
|
346 |
+
/**
|
347 |
+
* Get Config Data Collection for Path
|
348 |
+
* @param type $path
|
349 |
+
* @return Mage_Core_Model_Resource_Config_Data_Collection
|
350 |
+
*/
|
351 |
+
protected function _getConfigCollection($path)
|
352 |
+
{
|
353 |
+
/* @var $configDataCollection Mage_Core_Model_Resource_Config_Data_Collection */
|
354 |
+
$configDataCollection = Mage::getModel('core/config_data')->getCollection()
|
355 |
+
->addFieldToFilter('path', $path);
|
356 |
+
|
357 |
+
return $configDataCollection;
|
358 |
+
}
|
359 |
+
|
360 |
+
/**
|
361 |
+
* Get Parent Scope
|
362 |
+
* @param string $scope
|
363 |
+
* @param string|int $scopeId
|
364 |
+
* @return array
|
365 |
+
*/
|
366 |
+
protected function _getScopeParent($scope, $scopeId)
|
367 |
+
{
|
368 |
+
if ('store' == $scope || 'website' == $scope) {
|
369 |
+
$scope .= 's';
|
370 |
+
}
|
371 |
+
|
372 |
+
switch ($scope) {
|
373 |
+
case 'stores':
|
374 |
+
$scope = 'websites';
|
375 |
+
$scopeId = Mage::app()->getStore($scopeId)->getWebsiteId();
|
376 |
+
break;
|
377 |
+
case 'websites':
|
378 |
+
$scope = 'default';
|
379 |
+
$scopeId = 0;
|
380 |
+
break;
|
381 |
+
case 'default':
|
382 |
+
default:
|
383 |
+
$scope = false;
|
384 |
+
$scopeId = false;
|
385 |
+
break;
|
386 |
+
}
|
387 |
+
|
388 |
+
return array('scope' => $scope, 'scope_id' => $scopeId);
|
389 |
+
}
|
390 |
+
}
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Label.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @return string
|
13 |
+
*/
|
14 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
15 |
+
{
|
16 |
+
$label = $element->getLabel();
|
17 |
+
|
18 |
+
preg_match('/##[a-zA-Z-_]*##/', $label, $matches);
|
19 |
+
if (isset($matches[0])) {
|
20 |
+
$match = $matches[0];
|
21 |
+
$section = str_replace('#', '', $match);
|
22 |
+
$label = str_replace($match, '', $label);
|
23 |
+
|
24 |
+
$sectionUrl = Mage::helper('bronto_email')->getScopeUrl('/system_config/edit/section/' . $section);
|
25 |
+
$labelParts = explode('»', $label);
|
26 |
+
$newLabel = trim($labelParts[0]) .
|
27 |
+
" » <a href=\"{$sectionUrl}\" title=\"{$label}\"><strong>" .
|
28 |
+
trim($labelParts[1]) .
|
29 |
+
"</strong></a> » " .
|
30 |
+
trim($labelParts[2]);
|
31 |
+
|
32 |
+
$element->setLabel($newLabel);
|
33 |
+
}
|
34 |
+
|
35 |
+
return parent::render($element);
|
36 |
+
}
|
37 |
+
}
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Config/Templates/Sendtype.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @return string
|
13 |
+
*/
|
14 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
15 |
+
{
|
16 |
+
$realpath = str_replace('-', '/', str_replace('bronto_email_templates_', '', $element->getId()));
|
17 |
+
$realValue = Mage::helper('bronto_email')->getAdminScopedConfig($realpath);
|
18 |
+
if ('' == $realValue) {
|
19 |
+
$realValue = 'marketing';
|
20 |
+
}
|
21 |
+
$element->setValue($realValue);
|
22 |
+
$element->setPath($realpath);
|
23 |
+
|
24 |
+
return parent::render($element);
|
25 |
+
}
|
26 |
+
}
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @package Bronto\Email
|
5 |
+
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
+
* @version 1.1.1
|
7 |
+
*/
|
8 |
+
class Bronto_Email_Block_Adminhtml_System_Email_Import extends Mage_Adminhtml_Block_System_Email_Template
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Set transactional emails grid template
|
12 |
+
*/
|
13 |
+
protected function _construct()
|
14 |
+
{
|
15 |
+
Mage_Adminhtml_Block_Template::_construct();
|
16 |
+
$this->setTemplate('bronto/email/template/list.phtml');
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @return Mage_Core_Block_Abstract
|
21 |
+
*/
|
22 |
+
protected function _prepareLayout()
|
23 |
+
{
|
24 |
+
if (!Mage::helper('bronto_email')->isEnabledForAny()) {
|
25 |
+
return parent::_prepareLayout();
|
26 |
+
}
|
27 |
+
|
28 |
+
$this->setChild('back_button',
|
29 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
30 |
+
->setData(array(
|
31 |
+
'label' => Mage::helper('adminhtml')->__('Back'),
|
32 |
+
'onclick' => "window.location='" . $this->getBackUrl() . "'",
|
33 |
+
'class' => 'scalable back',
|
34 |
+
))
|
35 |
+
);
|
36 |
+
|
37 |
+
$this->setChild('import_button',
|
38 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
39 |
+
->setData(array(
|
40 |
+
'label' => Mage::helper('adminhtml')->__('Load Default Magento Templates'),
|
41 |
+
'onclick' => "window.location='" . $this->getLoadDefaultsUrl() . "'",
|
42 |
+
'class' => 'go'
|
43 |
+
))
|
44 |
+
);
|
45 |
+
|
46 |
+
$this->setChild('grid', $this->getLayout()->createBlock('bronto_email/adminhtml_system_email_import_grid', 'email.import.grid'));
|
47 |
+
|
48 |
+
return Mage_Adminhtml_Block_Template::_prepareLayout();
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Get transactional emails page header text
|
53 |
+
*
|
54 |
+
* @return string
|
55 |
+
*/
|
56 |
+
public function getHeaderText()
|
57 |
+
{
|
58 |
+
if (!Mage::helper('bronto_email')->isEnabledForAny()) {
|
59 |
+
return parent::getHeaderText();
|
60 |
+
}
|
61 |
+
|
62 |
+
return Mage::helper('bronto_email')->__('Import Magento Transactional Email Templates');
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Get URL to import existing email templates
|
67 |
+
*
|
68 |
+
* @return string
|
69 |
+
*/
|
70 |
+
public function getLoadDefaultsUrl()
|
71 |
+
{
|
72 |
+
return $this->getUrl('*/system_email_template/loadDefaults');
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Get URL to go back
|
77 |
+
*
|
78 |
+
* @return string
|
79 |
+
*/
|
80 |
+
public function getBackUrl()
|
81 |
+
{
|
82 |
+
return $this->getUrl('*/system_email_template/index');
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Get link to transactional email configuration
|
87 |
+
* @return type
|
88 |
+
*/
|
89 |
+
public function getConfigLink()
|
90 |
+
{
|
91 |
+
$url = $this->getUrl('/system_config/edit/section/bronto_email');
|
92 |
+
return '<strong>System › Configuration › Bronto » <a href="' . $url . '" title="Transactional Emails">Transactional Emails</a></strong>';
|
93 |
+
}
|
94 |
+
}
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import/Edit.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @package Bronto\Email
|
5 |
+
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
+
* @version 1.1.1
|
7 |
+
*/
|
8 |
+
class Bronto_Email_Block_Adminhtml_System_Email_Import_Edit
|
9 |
+
extends Mage_Adminhtml_Block_System_Email_Template_Edit
|
10 |
+
{
|
11 |
+
protected function _prepareLayout()
|
12 |
+
{
|
13 |
+
parent::_prepareLayout();
|
14 |
+
|
15 |
+
$this->setChild('back_button',
|
16 |
+
$this->getLayout()->createBlock('adminhtml/widget_button')
|
17 |
+
->setData(
|
18 |
+
array(
|
19 |
+
'label' => Mage::helper('adminhtml')->__('Back'),
|
20 |
+
'onclick' => "window.location.href = '" . $this->getUrl('*/*/import') . "'",
|
21 |
+
'class' => 'back'
|
22 |
+
)
|
23 |
+
)
|
24 |
+
);
|
25 |
+
}
|
26 |
+
}
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import/Grid.php
ADDED
@@ -0,0 +1,94 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @package Bronto\Email
|
5 |
+
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
+
* @version 1.1.1
|
7 |
+
*/
|
8 |
+
class Bronto_Email_Block_Adminhtml_System_Email_Import_Grid extends Mage_Adminhtml_Block_System_Email_Template_Grid
|
9 |
+
{
|
10 |
+
|
11 |
+
protected function _prepareCollection()
|
12 |
+
{
|
13 |
+
/* @var $collection Bronto_Email_Model_Mysql4_Template_Collection */
|
14 |
+
$collection = Mage::getModel('bronto_email/template')->getCollection();
|
15 |
+
|
16 |
+
// Apply conditional logic to handle 1.9 overriding collection _construct
|
17 |
+
if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, 9, 10))) {
|
18 |
+
$templateTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/template');
|
19 |
+
$brontoTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/message');
|
20 |
+
$collection->getSelect()->joinLeft(
|
21 |
+
$brontoTable,
|
22 |
+
"`{$templateTable}`.`template_id` = `{$brontoTable}`.`core_template_id`"
|
23 |
+
);
|
24 |
+
}
|
25 |
+
|
26 |
+
// Limit grid to show only those templates without message id assigned
|
27 |
+
$collection->addFieldToFilter('bronto_message_id', array('null' => true));
|
28 |
+
|
29 |
+
$this->setCollection($collection);
|
30 |
+
|
31 |
+
return Mage_Adminhtml_Block_Widget_Grid::_prepareCollection();
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Add columns to the grid
|
36 |
+
*
|
37 |
+
* @return Bronto_Email_Block_Adminhtml_System_Email_Template_Grid
|
38 |
+
*/
|
39 |
+
protected function _prepareColumns()
|
40 |
+
{
|
41 |
+
|
42 |
+
parent::_prepareColumns();
|
43 |
+
|
44 |
+
if (Mage::helper('bronto_email')->isEnabledForAny()) {
|
45 |
+
$this->addColumn('action', array(
|
46 |
+
'header' => Mage::helper('adminhtml')->__('Action'),
|
47 |
+
'index' => 'template_id',
|
48 |
+
'sortable' => false,
|
49 |
+
'filter' => false,
|
50 |
+
'width' => '100px',
|
51 |
+
'renderer' => 'bronto_email/adminhtml_system_email_import_grid_renderer_action'
|
52 |
+
));
|
53 |
+
}
|
54 |
+
|
55 |
+
return $this;
|
56 |
+
}
|
57 |
+
|
58 |
+
protected function _prepareMassaction()
|
59 |
+
{
|
60 |
+
$this->setMassactionIdField('template_id');
|
61 |
+
$this->getMassactionBlock()->setFormFieldName('template_id');
|
62 |
+
|
63 |
+
$stores = Mage::app()->getStores();
|
64 |
+
if (is_array($stores) && count($stores) >= 1) {
|
65 |
+
foreach ($stores as $store) {
|
66 |
+
if (Mage::helper('bronto_email')->isEnabled($store->getId())) {
|
67 |
+
$this->getMassactionBlock()->addItem('import|' . $store->getCode(), array(
|
68 |
+
'url' => $this->getUrl('*/*/massImport', array('template_id' => '', 'store_id' => $store->getId())),
|
69 |
+
'label' => Mage::helper('bronto_email')->__('Import For Store: ' . $store->getName()),
|
70 |
+
'confirm' => Mage::helper('bronto_email')->__('Are you sure? This will import the selected template(s) to Bronto for the specified store.'),
|
71 |
+
));
|
72 |
+
}
|
73 |
+
}
|
74 |
+
}
|
75 |
+
|
76 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
77 |
+
'label' => Mage::helper('bronto_email')->__('Delete'),
|
78 |
+
'url' => $this->getUrl('*/*/massDelete', array('delete_level' => 'full')),
|
79 |
+
'confirm' => Mage::helper('bronto_email')->__('Are you sure? This will permanently delete the selected template(s). Please note: default templates can be re-loaded, but custom templates will be lost.')
|
80 |
+
));
|
81 |
+
return $this;
|
82 |
+
}
|
83 |
+
|
84 |
+
/**
|
85 |
+
* get Row Url for editing template on row click
|
86 |
+
* @param type $row
|
87 |
+
* @return string
|
88 |
+
*/
|
89 |
+
public function getRowUrl($row)
|
90 |
+
{
|
91 |
+
return $this->getUrl('*/*/importEdit', array('id' => $row->getId()));
|
92 |
+
}
|
93 |
+
|
94 |
+
}
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Import/Grid/Renderer/Action.php
ADDED
@@ -0,0 +1,84 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Magento Enterprise Edition
|
4 |
+
*
|
5 |
+
* NOTICE OF LICENSE
|
6 |
+
*
|
7 |
+
* This source file is subject to the Magento Enterprise Edition License
|
8 |
+
* that is bundled with this package in the file LICENSE_EE.txt.
|
9 |
+
* It is also available through the world-wide-web at this URL:
|
10 |
+
* http://www.magentocommerce.com/license/enterprise-edition
|
11 |
+
* If you did not receive a copy of the license and are unable to
|
12 |
+
* obtain it through the world-wide-web, please send an email
|
13 |
+
* to license@magentocommerce.com so we can send you a copy immediately.
|
14 |
+
*
|
15 |
+
* DISCLAIMER
|
16 |
+
*
|
17 |
+
* Do not edit or add to this file if you wish to upgrade Magento to newer
|
18 |
+
* versions in the future. If you wish to customize Magento for your
|
19 |
+
* needs please refer to http://www.magentocommerce.com for more information.
|
20 |
+
*
|
21 |
+
* @category Mage
|
22 |
+
* @package Mage_Adminhtml
|
23 |
+
* @copyright Copyright (c) 2012 Magento Inc. (http://www.magentocommerce.com)
|
24 |
+
* @license http://www.magentocommerce.com/license/enterprise-edition
|
25 |
+
*/
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Adminhtml newsletter templates grid block action item renderer
|
29 |
+
*
|
30 |
+
* @category Mage
|
31 |
+
* @package Mage_Adminhtml
|
32 |
+
* @author Magento Core Team <core@magentocommerce.com>
|
33 |
+
*/
|
34 |
+
|
35 |
+
class Bronto_Email_Block_Adminhtml_System_Email_Import_Grid_Renderer_Action extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
|
36 |
+
{
|
37 |
+
public function render(Varien_Object $row)
|
38 |
+
{
|
39 |
+
$actions = array();
|
40 |
+
|
41 |
+
$actions[] = array(
|
42 |
+
'url' => $this->getUrl('*/*/edit', array('id' => $row->getId())),
|
43 |
+
'caption' => $this->__('Edit'),
|
44 |
+
);
|
45 |
+
|
46 |
+
$stores = Mage::app()->getStores();
|
47 |
+
if (is_array($stores) && count($stores) >= 1) {
|
48 |
+
foreach ($stores as $store) {
|
49 |
+
if (Mage::helper('bronto_email')->isEnabled($store->getId())) {
|
50 |
+
$actions[] = array(
|
51 |
+
'url' => $this->getUrl('*/*/massImport', array('template_id' => $row->getId(), 'store_id' => $store->getId())),
|
52 |
+
'caption' => $this->__('Import For Store: ' . $store->getName()),
|
53 |
+
'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to import the selected template?'),
|
54 |
+
);
|
55 |
+
}
|
56 |
+
}
|
57 |
+
}
|
58 |
+
$actions[] = array(
|
59 |
+
'url' => $this->getUrl('*/*/massDelete', array('template_id' => $row->getId(), 'delete_level' => 'full')),
|
60 |
+
'caption' => $this->__('Delete'),
|
61 |
+
'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to delete the selected template?'),
|
62 |
+
);
|
63 |
+
|
64 |
+
$this->getColumn()->setActions($actions);
|
65 |
+
|
66 |
+
return parent::render($row);
|
67 |
+
}
|
68 |
+
|
69 |
+
protected function _getEscapedValue($value)
|
70 |
+
{
|
71 |
+
return addcslashes(htmlspecialchars($value), '\\\'');
|
72 |
+
}
|
73 |
+
|
74 |
+
protected function _actionsToHtml(array $actions)
|
75 |
+
{
|
76 |
+
$html = array();
|
77 |
+
$attributesObject = new Varien_Object();
|
78 |
+
foreach ($actions as $action) {
|
79 |
+
$attributesObject->setData($action['@']);
|
80 |
+
$html[] = '<a ' . $attributesObject->serialize() . '>' . $action['#'] . '</a>';
|
81 |
+
}
|
82 |
+
return implode(' <span class="separator"> | </span> ', $html);
|
83 |
+
}
|
84 |
+
}
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log.php
CHANGED
@@ -10,7 +10,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Log extends Mage_Adminhtml_Block
|
|
10 |
/**
|
11 |
* @var string
|
12 |
*/
|
13 |
-
protected $_controller
|
14 |
|
15 |
/**
|
16 |
* @var string
|
@@ -20,7 +20,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Log extends Mage_Adminhtml_Block
|
|
20 |
/**
|
21 |
* @var string
|
22 |
*/
|
23 |
-
protected $_blockGroup
|
24 |
|
25 |
public function __construct()
|
26 |
{
|
@@ -30,9 +30,9 @@ class Bronto_Email_Block_Adminhtml_System_Email_Log extends Mage_Adminhtml_Block
|
|
30 |
|
31 |
$this->_addBackButton();
|
32 |
$this->_addButton('clear', array(
|
33 |
-
'label'
|
34 |
-
'onclick'
|
35 |
-
'class'
|
36 |
));
|
37 |
|
38 |
$this->_removeButton('add');
|
@@ -53,4 +53,14 @@ class Bronto_Email_Block_Adminhtml_System_Email_Log extends Mage_Adminhtml_Block
|
|
53 |
{
|
54 |
return $this->_clearButtonLabel;
|
55 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
}
|
10 |
/**
|
11 |
* @var string
|
12 |
*/
|
13 |
+
protected $_controller = 'adminhtml_system_email_log';
|
14 |
|
15 |
/**
|
16 |
* @var string
|
20 |
/**
|
21 |
* @var string
|
22 |
*/
|
23 |
+
protected $_blockGroup = 'bronto_email';
|
24 |
|
25 |
public function __construct()
|
26 |
{
|
30 |
|
31 |
$this->_addBackButton();
|
32 |
$this->_addButton('clear', array(
|
33 |
+
'label' => $this->getClearButtonLabel(),
|
34 |
+
'onclick' => 'setLocation(\'' . $this->getClearUrl() . '\')',
|
35 |
+
'class' => 'delete'
|
36 |
));
|
37 |
|
38 |
$this->_removeButton('add');
|
53 |
{
|
54 |
return $this->_clearButtonLabel;
|
55 |
}
|
56 |
+
|
57 |
+
/**
|
58 |
+
* Get URL to go back
|
59 |
+
*
|
60 |
+
* @return string
|
61 |
+
*/
|
62 |
+
public function getBackUrl()
|
63 |
+
{
|
64 |
+
return $this->getUrl('*/system_email_template/index');
|
65 |
+
}
|
66 |
}
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log/Grid.php
CHANGED
@@ -31,59 +31,59 @@ class Bronto_Email_Block_Adminhtml_System_Email_Log_Grid extends Mage_Adminhtml_
|
|
31 |
{
|
32 |
$this->addColumn('log_id', array(
|
33 |
'header' => Mage::helper('bronto_email')->__('ID'),
|
34 |
-
'align'
|
35 |
-
'index'
|
36 |
-
'type'
|
37 |
'filter' => false,
|
38 |
));
|
39 |
|
40 |
$this->addColumn('message_name', array(
|
41 |
'header' => Mage::helper('bronto_email')->__('Message Name'),
|
42 |
-
'align'
|
43 |
-
'index'
|
44 |
'filter' => false,
|
45 |
));
|
46 |
|
47 |
$this->addColumn('sent_at', array(
|
48 |
'header' => Mage::helper('bronto_email')->__('Sent At'),
|
49 |
-
'align'
|
50 |
-
'index'
|
51 |
-
'type'
|
52 |
));
|
53 |
|
54 |
$this->addColumn('customer_email', array(
|
55 |
-
'header'
|
56 |
-
'index'
|
57 |
'renderer' => 'bronto_email/adminhtml_system_email_log_grid_renderer_customer',
|
58 |
));
|
59 |
|
60 |
$this->addColumn('success', array(
|
61 |
-
'header'
|
62 |
-
'align'
|
63 |
-
'index'
|
64 |
'sortable' => false,
|
65 |
-
'type'
|
66 |
-
'options'
|
67 |
0 => 'No',
|
68 |
1 => 'Yes',
|
69 |
),
|
70 |
));
|
71 |
|
72 |
$this->addColumn('error', array(
|
73 |
-
'header'
|
74 |
-
'align'
|
75 |
-
'index'
|
76 |
'sortable' => false,
|
77 |
-
'filter'
|
78 |
));
|
79 |
|
80 |
$this->addColumn('data', array(
|
81 |
-
'header'
|
82 |
-
'align'
|
83 |
-
'index'
|
84 |
'renderer' => 'bronto_email/adminhtml_system_email_log_grid_renderer_fields',
|
85 |
'sortable' => false,
|
86 |
-
'filter'
|
87 |
));
|
88 |
|
89 |
return parent::_prepareColumns();
|
31 |
{
|
32 |
$this->addColumn('log_id', array(
|
33 |
'header' => Mage::helper('bronto_email')->__('ID'),
|
34 |
+
'align' => 'left',
|
35 |
+
'index' => 'log_id',
|
36 |
+
'type' => 'number',
|
37 |
'filter' => false,
|
38 |
));
|
39 |
|
40 |
$this->addColumn('message_name', array(
|
41 |
'header' => Mage::helper('bronto_email')->__('Message Name'),
|
42 |
+
'align' => 'left',
|
43 |
+
'index' => 'message_name',
|
44 |
'filter' => false,
|
45 |
));
|
46 |
|
47 |
$this->addColumn('sent_at', array(
|
48 |
'header' => Mage::helper('bronto_email')->__('Sent At'),
|
49 |
+
'align' => 'left',
|
50 |
+
'index' => 'sent_at',
|
51 |
+
'type' => 'datetime'
|
52 |
));
|
53 |
|
54 |
$this->addColumn('customer_email', array(
|
55 |
+
'header' => Mage::helper('customer')->__('Email'),
|
56 |
+
'index' => 'customer_email',
|
57 |
'renderer' => 'bronto_email/adminhtml_system_email_log_grid_renderer_customer',
|
58 |
));
|
59 |
|
60 |
$this->addColumn('success', array(
|
61 |
+
'header' => Mage::helper('bronto_email')->__('Success'),
|
62 |
+
'align' => 'left',
|
63 |
+
'index' => 'success',
|
64 |
'sortable' => false,
|
65 |
+
'type' => 'options',
|
66 |
+
'options' => array(
|
67 |
0 => 'No',
|
68 |
1 => 'Yes',
|
69 |
),
|
70 |
));
|
71 |
|
72 |
$this->addColumn('error', array(
|
73 |
+
'header' => Mage::helper('bronto_email')->__('Error'),
|
74 |
+
'align' => 'left',
|
75 |
+
'index' => 'error',
|
76 |
'sortable' => false,
|
77 |
+
'filter' => false,
|
78 |
));
|
79 |
|
80 |
$this->addColumn('data', array(
|
81 |
+
'header' => Mage::helper('bronto_email')->__('Fields'),
|
82 |
+
'align' => 'left',
|
83 |
+
'index' => 'data',
|
84 |
'renderer' => 'bronto_email/adminhtml_system_email_log_grid_renderer_fields',
|
85 |
'sortable' => false,
|
86 |
+
'filter' => false,
|
87 |
));
|
88 |
|
89 |
return parent::_prepareColumns();
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log/Grid/Renderer/Customer.php
CHANGED
@@ -17,8 +17,8 @@ class Bronto_Email_Block_Adminhtml_System_Email_Log_Grid_Renderer_Customer exten
|
|
17 |
$customerEditUrl = $this->getUrl('*/customer/edit', array('id' => $row->getCustomerId()));
|
18 |
return sprintf(
|
19 |
'<a href="%s">%s</a>',
|
20 |
-
|
21 |
-
|
22 |
);
|
23 |
}
|
24 |
|
17 |
$customerEditUrl = $this->getUrl('*/customer/edit', array('id' => $row->getCustomerId()));
|
18 |
return sprintf(
|
19 |
'<a href="%s">%s</a>',
|
20 |
+
$customerEditUrl,
|
21 |
+
parent::render($row)
|
22 |
);
|
23 |
}
|
24 |
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Log/Grid/Renderer/Fields.php
CHANGED
@@ -20,7 +20,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Log_Grid_Renderer_Fields extends
|
|
20 |
return '';
|
21 |
}
|
22 |
|
23 |
-
$fieldsHtml
|
24 |
foreach ($fields as $field) {
|
25 |
$fieldsHtml .= '<dt><strong>' . $field['name'] . '</strong></dt>';
|
26 |
$fieldsHtml .= '
|
20 |
return '';
|
21 |
}
|
22 |
|
23 |
+
$fieldsHtml = '<dl style="margin-top: 10px">';
|
24 |
foreach ($fields as $field) {
|
25 |
$fieldsHtml .= '<dt><strong>' . $field['name'] . '</strong></dt>';
|
26 |
$fieldsHtml .= '
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template.php
CHANGED
@@ -21,25 +21,25 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template extends Mage_Adminhtml_
|
|
21 |
*/
|
22 |
protected function _prepareLayout()
|
23 |
{
|
24 |
-
if (!Mage::helper('bronto_email')->
|
25 |
return parent::_prepareLayout();
|
26 |
}
|
27 |
|
28 |
$this->setChild('add_button',
|
29 |
$this->getLayout()->createBlock('adminhtml/widget_button')
|
30 |
->setData(array(
|
31 |
-
'label'
|
32 |
-
'onclick'
|
33 |
-
'class'
|
34 |
))
|
35 |
);
|
36 |
|
37 |
$this->setChild('import_button',
|
38 |
$this->getLayout()->createBlock('adminhtml/widget_button')
|
39 |
->setData(array(
|
40 |
-
'label'
|
41 |
-
'onclick'
|
42 |
-
'class'
|
43 |
))
|
44 |
);
|
45 |
|
@@ -47,14 +47,14 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template extends Mage_Adminhtml_
|
|
47 |
$this->setChild('log_button',
|
48 |
$this->getLayout()->createBlock('adminhtml/widget_button')
|
49 |
->setData(array(
|
50 |
-
'label'
|
51 |
-
'onclick'
|
52 |
-
'class'
|
53 |
))
|
54 |
);
|
55 |
}
|
56 |
|
57 |
-
$this->setChild('grid', $this->getLayout()->createBlock('
|
58 |
|
59 |
return Mage_Adminhtml_Block_Template::_prepareLayout();
|
60 |
}
|
@@ -66,7 +66,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template extends Mage_Adminhtml_
|
|
66 |
*/
|
67 |
public function getHeaderText()
|
68 |
{
|
69 |
-
if (!Mage::helper('bronto_email')->
|
70 |
return parent::getHeaderText();
|
71 |
}
|
72 |
|
@@ -76,6 +76,16 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template extends Mage_Adminhtml_
|
|
76 |
/**
|
77 |
* Get URL for create new email template
|
78 |
*
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
79 |
* @return string
|
80 |
*/
|
81 |
public function getLogUrl()
|
@@ -92,4 +102,26 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template extends Mage_Adminhtml_
|
|
92 |
{
|
93 |
return $this->getUrl('*/system_email_template/import');
|
94 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
95 |
}
|
21 |
*/
|
22 |
protected function _prepareLayout()
|
23 |
{
|
24 |
+
if (!Mage::helper('bronto_email')->isEnabledForAny()) {
|
25 |
return parent::_prepareLayout();
|
26 |
}
|
27 |
|
28 |
$this->setChild('add_button',
|
29 |
$this->getLayout()->createBlock('adminhtml/widget_button')
|
30 |
->setData(array(
|
31 |
+
'label' => Mage::helper('adminhtml')->__('Add Bronto Message'),
|
32 |
+
'onclick' => "window.location='" . $this->getCreateUrl() . "'",
|
33 |
+
'class' => 'add'
|
34 |
))
|
35 |
);
|
36 |
|
37 |
$this->setChild('import_button',
|
38 |
$this->getLayout()->createBlock('adminhtml/widget_button')
|
39 |
->setData(array(
|
40 |
+
'label' => Mage::helper('adminhtml')->__('Import Existing Templates'),
|
41 |
+
'onclick' => "window.location='" . $this->getImportUrl() . "'",
|
42 |
+
'class' => 'go'
|
43 |
))
|
44 |
);
|
45 |
|
47 |
$this->setChild('log_button',
|
48 |
$this->getLayout()->createBlock('adminhtml/widget_button')
|
49 |
->setData(array(
|
50 |
+
'label' => Mage::helper('adminhtml')->__('Delivery Log'),
|
51 |
+
'onclick' => "window.location='" . $this->getLogUrl() . "'",
|
52 |
+
'class' => 'go'
|
53 |
))
|
54 |
);
|
55 |
}
|
56 |
|
57 |
+
$this->setChild('grid', $this->getLayout()->createBlock('bronto_email/adminhtml_system_email_template_grid', 'email.template.grid'));
|
58 |
|
59 |
return Mage_Adminhtml_Block_Template::_prepareLayout();
|
60 |
}
|
66 |
*/
|
67 |
public function getHeaderText()
|
68 |
{
|
69 |
+
if (!Mage::helper('bronto_email')->isEnabledForAny()) {
|
70 |
return parent::getHeaderText();
|
71 |
}
|
72 |
|
76 |
/**
|
77 |
* Get URL for create new email template
|
78 |
*
|
79 |
+
* @return type
|
80 |
+
*/
|
81 |
+
public function getCreateUrl()
|
82 |
+
{
|
83 |
+
return $this->getUrl('*/*/brontonew');
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Get URL for transactional email log
|
88 |
+
*
|
89 |
* @return string
|
90 |
*/
|
91 |
public function getLogUrl()
|
102 |
{
|
103 |
return $this->getUrl('*/system_email_template/import');
|
104 |
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Get link to transactional email configuration
|
108 |
+
* @return type
|
109 |
+
*/
|
110 |
+
public function getConfigLink()
|
111 |
+
{
|
112 |
+
$url = $this->getUrl('/system_config/edit/section/bronto_email');
|
113 |
+
return '<strong>System › Configuration » Bronto › <a href="' . $url . '" title="Transactional Emails">Transactional Emails</a></strong>';
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Generate url by route and parameters
|
118 |
+
*
|
119 |
+
* @param string $route
|
120 |
+
* @param array $params
|
121 |
+
* @return string
|
122 |
+
*/
|
123 |
+
public function getUrl($route = '', $params = array())
|
124 |
+
{
|
125 |
+
return Mage::helper('bronto_email')->getScopeUrl($route, $params);
|
126 |
+
}
|
127 |
}
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Edit.php
CHANGED
@@ -3,13 +3,13 @@
|
|
3 |
/**
|
4 |
* @package Bronto\Email
|
5 |
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
-
* @version 1.1.
|
7 |
*/
|
8 |
class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit extends Mage_Adminhtml_Block_System_Email_Template_Edit
|
9 |
{
|
10 |
public function __construct()
|
11 |
{
|
12 |
-
if (!Mage::helper('bronto_email')->
|
13 |
return parent::__construct();
|
14 |
}
|
15 |
|
@@ -17,9 +17,13 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit extends Mage_Admin
|
|
17 |
$this->setTemplate('bronto/email/template/edit.phtml');
|
18 |
}
|
19 |
|
|
|
|
|
|
|
|
|
20 |
protected function _prepareLayout()
|
21 |
{
|
22 |
-
if (!Mage::helper('bronto_email')->
|
23 |
return parent::_prepareLayout();
|
24 |
}
|
25 |
|
@@ -28,12 +32,17 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit extends Mage_Admin
|
|
28 |
$this->unsetChild('to_plain_button');
|
29 |
$this->unsetChild('to_html_button');
|
30 |
$this->unsetChild('preview_button');
|
|
|
31 |
|
32 |
$this->setChild('save_button', $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
|
33 |
-
'label'
|
34 |
'onclick' => 'templateControl.save();',
|
35 |
-
'class'
|
36 |
)));
|
|
|
|
|
|
|
|
|
37 |
}
|
38 |
|
39 |
/**
|
@@ -43,7 +52,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit extends Mage_Admin
|
|
43 |
*/
|
44 |
public function getHeaderText()
|
45 |
{
|
46 |
-
if (!Mage::helper('bronto_email')->
|
47 |
return parent::getHeaderText();
|
48 |
}
|
49 |
|
@@ -54,10 +63,16 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit extends Mage_Admin
|
|
54 |
return Mage::helper('adminhtml')->__('New Bronto Email Message');
|
55 |
}
|
56 |
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
public function getUsedDefaultForPaths($asJSON = true)
|
58 |
{
|
59 |
$paths = $this->getEmailTemplate()->getSystemConfigPathsWhereUsedAsDefault();
|
60 |
-
if (Mage::helper('bronto_email')->
|
61 |
if ($this->getEmailTemplate()->hasData('store_id')) {
|
62 |
$paths[0]['scope_id'] = $this->getEmailTemplate()->getData('store_id');
|
63 |
$paths[0]['scope'] = 'stores';
|
@@ -65,11 +80,122 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit extends Mage_Admin
|
|
65 |
}
|
66 |
|
67 |
$pathsParts = $this->_getSystemConfigPathsParts($paths);
|
68 |
-
|
69 |
-
if($asJSON){
|
70 |
return Mage::helper('core')->jsonEncode($pathsParts);
|
71 |
}
|
72 |
|
73 |
return $pathsParts;
|
74 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
75 |
}
|
3 |
/**
|
4 |
* @package Bronto\Email
|
5 |
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
+
* @version 1.1.4
|
7 |
*/
|
8 |
class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit extends Mage_Adminhtml_Block_System_Email_Template_Edit
|
9 |
{
|
10 |
public function __construct()
|
11 |
{
|
12 |
+
if (!Mage::helper('bronto_email')->isEnabledForAny()) {
|
13 |
return parent::__construct();
|
14 |
}
|
15 |
|
17 |
$this->setTemplate('bronto/email/template/edit.phtml');
|
18 |
}
|
19 |
|
20 |
+
/**
|
21 |
+
* Prepare the layout, removing unneeded elements and changing button/form
|
22 |
+
* @return null
|
23 |
+
*/
|
24 |
protected function _prepareLayout()
|
25 |
{
|
26 |
+
if (!Mage::helper('bronto_email')->isEnabledForAny()) {
|
27 |
return parent::_prepareLayout();
|
28 |
}
|
29 |
|
32 |
$this->unsetChild('to_plain_button');
|
33 |
$this->unsetChild('to_html_button');
|
34 |
$this->unsetChild('preview_button');
|
35 |
+
$this->unsetChild('form');
|
36 |
|
37 |
$this->setChild('save_button', $this->getLayout()->createBlock('adminhtml/widget_button')->setData(array(
|
38 |
+
'label' => Mage::helper('adminhtml')->__('Save Message'),
|
39 |
'onclick' => 'templateControl.save();',
|
40 |
+
'class' => 'save'
|
41 |
)));
|
42 |
+
|
43 |
+
$this->setChild('form',
|
44 |
+
$this->getLayout()->createBlock('bronto_email/adminhtml_system_email_template_edit_form')
|
45 |
+
);
|
46 |
}
|
47 |
|
48 |
/**
|
52 |
*/
|
53 |
public function getHeaderText()
|
54 |
{
|
55 |
+
if (!Mage::helper('bronto_email')->isEnabledForAny()) {
|
56 |
return parent::getHeaderText();
|
57 |
}
|
58 |
|
63 |
return Mage::helper('adminhtml')->__('New Bronto Email Message');
|
64 |
}
|
65 |
|
66 |
+
/**
|
67 |
+
* Get array or Json of path data
|
68 |
+
*
|
69 |
+
* @param boolean $asJSON
|
70 |
+
* @return array|json
|
71 |
+
*/
|
72 |
public function getUsedDefaultForPaths($asJSON = true)
|
73 |
{
|
74 |
$paths = $this->getEmailTemplate()->getSystemConfigPathsWhereUsedAsDefault();
|
75 |
+
if (Mage::helper('bronto_email')->isEnabledForAny()) {
|
76 |
if ($this->getEmailTemplate()->hasData('store_id')) {
|
77 |
$paths[0]['scope_id'] = $this->getEmailTemplate()->getData('store_id');
|
78 |
$paths[0]['scope'] = 'stores';
|
80 |
}
|
81 |
|
82 |
$pathsParts = $this->_getSystemConfigPathsParts($paths);
|
83 |
+
|
84 |
+
if ($asJSON) {
|
85 |
return Mage::helper('core')->jsonEncode($pathsParts);
|
86 |
}
|
87 |
|
88 |
return $pathsParts;
|
89 |
}
|
90 |
+
|
91 |
+
/**
|
92 |
+
* Get paths of where current template is currently used
|
93 |
+
*
|
94 |
+
* @param bool $asJSON
|
95 |
+
* @return string
|
96 |
+
*/
|
97 |
+
public function getUsedCurrentlyForPaths($asJSON = true)
|
98 |
+
{
|
99 |
+
$paths = $this->getEmailTemplate()->getSystemConfigPathsWhereUsedCurrently();
|
100 |
+
$pathsParts = $this->_getSystemConfigPathsParts($paths);
|
101 |
+
if ($asJSON) {
|
102 |
+
return Mage::helper('core')->jsonEncode($pathsParts);
|
103 |
+
}
|
104 |
+
return $pathsParts;
|
105 |
+
}
|
106 |
+
|
107 |
+
/**
|
108 |
+
* Convert xml config pathes to decorated names
|
109 |
+
*
|
110 |
+
* @param array $paths
|
111 |
+
* @return array
|
112 |
+
*/
|
113 |
+
protected function _getSystemConfigPathsParts($paths)
|
114 |
+
{
|
115 |
+
$result = $urlParams = $prefixParts = array();
|
116 |
+
$scopeLabel = Mage::helper('adminhtml')->__('GLOBAL');
|
117 |
+
if ($paths) {
|
118 |
+
// create prefix path parts
|
119 |
+
// Add "System" to path
|
120 |
+
$prefixParts[] = array(
|
121 |
+
'title' => Mage::getSingleton('admin/config')->getMenuItemLabel('system'),
|
122 |
+
);
|
123 |
+
// Add "Configuration" to path
|
124 |
+
$prefixParts[] = array(
|
125 |
+
'title' => Mage::getSingleton('admin/config')->getMenuItemLabel('system/config'),
|
126 |
+
'url' => $this->getUrl('adminhtml/system_config/'),
|
127 |
+
);
|
128 |
+
|
129 |
+
// Cycle through paths to add them to the path details
|
130 |
+
$pathParts = $prefixParts;
|
131 |
+
foreach ($paths as $pathData) {
|
132 |
+
if (!array_key_exists('path', $pathData)) {
|
133 |
+
continue;
|
134 |
+
}
|
135 |
+
|
136 |
+
list($sectionName, $groupName, $fieldName) = explode('/', $pathData['path']);
|
137 |
+
$urlParams = array('section' => $sectionName);
|
138 |
+
if (isset($pathData['scope']) && isset($pathData['scope_id'])) {
|
139 |
+
switch ($pathData['scope']) {
|
140 |
+
case 'stores':
|
141 |
+
$store = Mage::app()->getStore($pathData['scope_id']);
|
142 |
+
if ($store) {
|
143 |
+
$urlParams['website'] = $store->getWebsite()->getCode();
|
144 |
+
$urlParams['store'] = $store->getCode();
|
145 |
+
$scopeLabel = $store->getWebsite()->getName() . '/' . $store->getName();
|
146 |
+
}
|
147 |
+
break;
|
148 |
+
case 'websites':
|
149 |
+
$website = Mage::app()->getWebsite($pathData['scope_id']);
|
150 |
+
if ($website) {
|
151 |
+
$urlParams['website'] = $website->getCode();
|
152 |
+
$scopeLabel = $website->getName();
|
153 |
+
}
|
154 |
+
break;
|
155 |
+
default:
|
156 |
+
break;
|
157 |
+
}
|
158 |
+
}
|
159 |
+
$adminhtmlConfig = Mage::getSingleton('adminhtml/config');
|
160 |
+
$adminhtmlConfig->getSections();
|
161 |
+
|
162 |
+
// Check if titles are set to prevent "[Object]" from displaying in their place
|
163 |
+
// If Section Name is set, add it to path
|
164 |
+
if ($sectionTitle = $adminhtmlConfig->getSystemConfigNodeLabel($sectionName)) {
|
165 |
+
$pathParts[] = array(
|
166 |
+
'title' => $sectionTitle,
|
167 |
+
'url' => $this->getUrl('adminhtml/system_config/edit', $urlParams),
|
168 |
+
);
|
169 |
+
}
|
170 |
+
// If Group Name is set, add it to path
|
171 |
+
if ($groupTitle = $adminhtmlConfig->getSystemConfigNodeLabel($sectionName, $groupName)) {
|
172 |
+
$pathParts[] = array(
|
173 |
+
'title' => $groupTitle,
|
174 |
+
);
|
175 |
+
}
|
176 |
+
// If Field Name is set, add it to path
|
177 |
+
if ($fieldTitle = $adminhtmlConfig->getSystemConfigNodeLabel($sectionName, $groupName, $fieldName)) {
|
178 |
+
$pathParts[] = array(
|
179 |
+
'title' => $fieldTitle,
|
180 |
+
'scope' => $scopeLabel
|
181 |
+
);
|
182 |
+
}
|
183 |
+
|
184 |
+
$result[] = $pathParts;
|
185 |
+
$pathParts = $prefixParts;
|
186 |
+
}
|
187 |
+
}
|
188 |
+
|
189 |
+
return $result;
|
190 |
+
}
|
191 |
+
|
192 |
+
/**
|
193 |
+
* Return action url for form
|
194 |
+
*
|
195 |
+
* @return string
|
196 |
+
*/
|
197 |
+
public function getSaveUrl()
|
198 |
+
{
|
199 |
+
return $this->getUrl('*/*/brontoSave', array('_current' => true));
|
200 |
+
}
|
201 |
}
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Edit/Form.php
CHANGED
@@ -5,36 +5,67 @@
|
|
5 |
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
* @version 1.1.1
|
7 |
*/
|
8 |
-
class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends
|
9 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
/**
|
11 |
* @return Mage_Adminhtml_Block_Widget_Form
|
12 |
*/
|
13 |
protected function _prepareForm()
|
14 |
{
|
15 |
-
|
16 |
-
|
|
|
|
|
17 |
}
|
18 |
|
19 |
-
|
20 |
-
|
21 |
-
/* @var $form Varien_Data_Form */
|
22 |
-
$form = $this->getForm();
|
23 |
|
24 |
-
|
25 |
-
$fieldset = $form->
|
|
|
|
|
|
|
26 |
|
|
|
27 |
$templateId = $this->getEmailTemplate()->getId();
|
28 |
|
|
|
29 |
if ($templateId) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
if (!$this->getEmailTemplate()->getSystemConfigPathsWhereUsedCurrently()) {
|
31 |
$fieldset->addField('used_default_for', 'label', array(
|
32 |
'label' => Mage::helper('adminhtml')->__('Used as Default For'),
|
33 |
'container_id' => 'used_default_for',
|
34 |
'after_element_html' =>
|
35 |
-
|
36 |
-
|
37 |
-
|
38 |
));
|
39 |
|
40 |
$fieldset->addField('note_used_currently', 'label', array(
|
@@ -43,70 +74,227 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_
|
|
43 |
'after_element_html' => '<div style="color:red;"><strong>Note:</strong> This Email Message is currently not used.</div>',
|
44 |
));
|
45 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
46 |
}
|
47 |
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
52 |
|
53 |
-
|
54 |
-
$fieldset->addField('
|
55 |
-
'name'
|
56 |
-
'label'
|
57 |
-
'
|
|
|
|
|
|
|
58 |
));
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
73 |
new Ajax.Request(reloadurl, {
|
74 |
method: 'get',
|
75 |
onLoading: function (transport) {
|
76 |
$('bronto_message_id').update('Searching...');
|
77 |
},
|
78 |
onComplete: function(transport) {
|
79 |
-
|
80 |
}
|
81 |
});
|
82 |
}
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
|
|
|
|
|
|
90 |
|
|
|
|
|
|
|
|
|
|
|
|
|
91 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
$fieldset->addField('bronto_message_id', 'select', array(
|
93 |
-
'name'
|
94 |
-
'label'
|
95 |
-
'
|
|
|
|
|
96 |
'required' => true,
|
97 |
));
|
98 |
|
|
|
99 |
$fieldset->addField('template_variables_key', 'label', array(
|
100 |
'container_id' => 'template_variables_key_row',
|
101 |
'label' => Mage::helper('adminhtml')->__('Variables'),
|
102 |
'after_element_html' => '<div id="template_variables_key_list"></div>' .
|
103 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
104 |
));
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
if ($templateId) {
|
107 |
$form->addValues($this->getEmailTemplate()->getData());
|
108 |
$form->addValues(array(
|
109 |
'template_variables' => Zend_Json::encode($this->getEmailTemplate()->getVariablesOptionArray(true)),
|
|
|
|
|
|
|
|
|
|
|
110 |
));
|
111 |
}
|
112 |
|
@@ -114,6 +302,100 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_
|
|
114 |
$form->setValues($values);
|
115 |
}
|
116 |
|
117 |
-
|
|
|
|
|
118 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
119 |
}
|
5 |
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
* @version 1.1.1
|
7 |
*/
|
8 |
+
class Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
|
9 |
{
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Prepare layout.
|
13 |
+
* Add files to use dialog windows
|
14 |
+
*
|
15 |
+
* @return Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form
|
16 |
+
*/
|
17 |
+
protected function _prepareLayout()
|
18 |
+
{
|
19 |
+
if ($head = $this->getLayout()->getBlock('head')) {
|
20 |
+
$head->addItem('js', 'prototype/window.js')
|
21 |
+
->addItem('js_css', 'prototype/windows/themes/default.css')
|
22 |
+
->addCss('lib/prototype/windows/themes/magento.css')
|
23 |
+
->addItem('js', 'mage/adminhtml/variables.js');
|
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 |
+
return $parent->_prepareForm();
|
37 |
}
|
38 |
|
39 |
+
// Create New Form Element
|
40 |
+
$form = new Varien_Data_Form();
|
|
|
|
|
41 |
|
42 |
+
// Create New Form Fieldset Element
|
43 |
+
$fieldset = $form->addFieldset('base_fieldset', array(
|
44 |
+
'legend' => Mage::helper('adminhtml')->__('Template Information'),
|
45 |
+
'class' => 'fieldset-wide'
|
46 |
+
));
|
47 |
|
48 |
+
// Get the TemplateID
|
49 |
$templateId = $this->getEmailTemplate()->getId();
|
50 |
|
51 |
+
// Build "Used Current/Default For"
|
52 |
if ($templateId) {
|
53 |
+
$fieldset->addField('used_currently_for', 'label', array(
|
54 |
+
'label' => Mage::helper('adminhtml')->__('Used Currently For'),
|
55 |
+
'container_id' => 'used_currently_for',
|
56 |
+
'after_element_html' =>
|
57 |
+
'<script type="text/javascript">' .
|
58 |
+
(!$this->getEmailTemplate()->getSystemConfigPathsWhereUsedCurrently() ? '$(\'' . 'used_currently_for' . '\').hide(); ' : '') .
|
59 |
+
'</script>',
|
60 |
+
));
|
61 |
if (!$this->getEmailTemplate()->getSystemConfigPathsWhereUsedCurrently()) {
|
62 |
$fieldset->addField('used_default_for', 'label', array(
|
63 |
'label' => Mage::helper('adminhtml')->__('Used as Default For'),
|
64 |
'container_id' => 'used_default_for',
|
65 |
'after_element_html' =>
|
66 |
+
'<script type="text/javascript">' .
|
67 |
+
(!(bool)$this->getEmailTemplate()->getOrigTemplateCode() ? '$(\'' . 'used_default_for' . '\').hide(); ' : '') .
|
68 |
+
'</script>',
|
69 |
));
|
70 |
|
71 |
$fieldset->addField('note_used_currently', 'label', array(
|
74 |
'after_element_html' => '<div style="color:red;"><strong>Note:</strong> This Email Message is currently not used.</div>',
|
75 |
));
|
76 |
}
|
77 |
+
} else {
|
78 |
+
$fieldset->addField('used_default_for', 'label', array(
|
79 |
+
'label' => Mage::helper('adminhtml')->__('Used as Default For'),
|
80 |
+
'container_id' => 'used_default_for',
|
81 |
+
'after_element_html' =>
|
82 |
+
'<script type="text/javascript">' .
|
83 |
+
(!(bool)$this->getEmailTemplate()->getOrigTemplateCode() ? '$(\'' . 'used_default_for' . '\').hide(); ' : '') .
|
84 |
+
'</script>',
|
85 |
+
));
|
86 |
}
|
87 |
|
88 |
+
// If has more than one store, provide store select field,
|
89 |
+
// Otherwise set hidden field with single store Id
|
90 |
+
if (!Mage::app()->isSingleStoreMode()) {
|
91 |
+
$fieldset->addField('store_id', 'select', array(
|
92 |
+
'name' => 'store_id',
|
93 |
+
'label' => Mage::helper('adminhtml')->__('Store View'),
|
94 |
+
'title' => Mage::helper('adminhtml')->__('Store View'),
|
95 |
+
'onchange' => "updateMessages();",
|
96 |
+
'required' => true,
|
97 |
+
'values' => $this->_getActiveStoreValuesForForm(false, false),
|
98 |
+
));
|
99 |
+
} else {
|
100 |
+
$fieldset->addField('store_id', 'hidden', array(
|
101 |
+
'name' => 'store_id',
|
102 |
+
'value' => Mage::app()->getStore(true)->getId()
|
103 |
+
));
|
104 |
+
}
|
105 |
|
106 |
+
// Create field for selecting How the template will be sent
|
107 |
+
$sendtype = $fieldset->addField('template_send_type', 'select', array(
|
108 |
+
'name' => 'template_send_type',
|
109 |
+
'label' => Mage::helper('adminhtml')->__('Send Type'),
|
110 |
+
'title' => Mage::helper('adminhtml')->__('Send Type'),
|
111 |
+
'onchange' => "updateMessages();",
|
112 |
+
'required' => true,
|
113 |
+
'values' => array('magento' => 'Magento Email', 'marketing' => 'Bronto Marketing', 'transactional' => 'Bronto Transactional'),
|
114 |
));
|
115 |
|
116 |
+
// Add Script after send type field to handle updating form
|
117 |
+
$sendtype->setAfterElementHtml("
|
118 |
+
<script type=\"text/javascript\">
|
119 |
+
Event.observe(window, 'load', function() {
|
120 |
+
triggerSendType($('template_send_type').value);
|
121 |
+
});
|
122 |
+
|
123 |
+
function triggerSendType(sendType) {
|
124 |
+
if (sendType == 'magento') {
|
125 |
+
// Disable Some
|
126 |
+
$('bronto_message_id').disable();
|
127 |
+
$('orig_template_text').disable();
|
128 |
+
$('container_bronto_message_id').hide();
|
129 |
+
$('container_orig_template_text').hide();
|
130 |
+
|
131 |
+
// Enable Others
|
132 |
+
$('template_subject').enable();
|
133 |
+
$('template_text').enable();
|
134 |
+
$('container_template_subject').show();
|
135 |
+
$('container_template_text').show();
|
136 |
+
$('insert_variable').show();
|
137 |
+
|
138 |
+
if ($('field_template_styles') != undefined) {
|
139 |
+
$('field_template_styles').show();
|
140 |
+
$('template_styles').enable();
|
141 |
+
}
|
142 |
+
} else {
|
143 |
+
// Enable Some
|
144 |
+
$('bronto_message_id').enable();
|
145 |
+
$('orig_template_text').enable();
|
146 |
+
$('container_bronto_message_id').show();
|
147 |
+
$('container_orig_template_text').show();
|
148 |
+
|
149 |
+
// Disable Others
|
150 |
+
$('template_subject').disable();
|
151 |
+
$('template_text').disable();
|
152 |
+
$('container_template_subject').hide();
|
153 |
+
$('container_template_text').hide();
|
154 |
+
$('insert_variable').hide();
|
155 |
+
|
156 |
+
if ($('field_template_styles') != undefined) {
|
157 |
+
$('template_styles').disable();
|
158 |
+
$('field_template_styles').hide();
|
159 |
+
}
|
160 |
+
}
|
161 |
+
}
|
162 |
+
|
163 |
+
function updateMessages(){
|
164 |
+
var storeId = $('store_id').value;
|
165 |
+
var sendType = $('template_send_type').value;
|
166 |
+
var template = '{$templateId}';
|
167 |
+
|
168 |
+
triggerSendType(sendType);
|
169 |
+
|
170 |
+
if (sendType != 'magento') {
|
171 |
+
var reloadurl = '" . $this->getUrl('adminhtml/system_email_template/ajaxlist') . "template_id/'+template+'/id/'+storeId+'/type/'+sendType;
|
172 |
new Ajax.Request(reloadurl, {
|
173 |
method: 'get',
|
174 |
onLoading: function (transport) {
|
175 |
$('bronto_message_id').update('Searching...');
|
176 |
},
|
177 |
onComplete: function(transport) {
|
178 |
+
$('bronto_message_id').update(transport.responseText);
|
179 |
}
|
180 |
});
|
181 |
}
|
182 |
+
}
|
183 |
+
|
184 |
+
function syncHiddenValue(element) {
|
185 |
+
var fieldValue = element.value;
|
186 |
+
|
187 |
+
if ($(element.id + '_hidden') != undefined) {
|
188 |
+
$(element.id + '_hidden').value = fieldValue;
|
189 |
+
}
|
190 |
+
}
|
191 |
+
</script>");
|
192 |
|
193 |
+
// Template Name/Code
|
194 |
+
$fieldset->addField('template_code', 'text', array(
|
195 |
+
'name' => 'template_code',
|
196 |
+
'label' => Mage::helper('adminhtml')->__('Name'),
|
197 |
+
'required' => true
|
198 |
+
));
|
199 |
|
200 |
+
// Add hidden fields to hold backups of the necessary values
|
201 |
+
$fieldset->addField('bronto_message_id_hidden', 'hidden', array('name' => 'bronto_message_id_hidden'));
|
202 |
+
$fieldset->addField('template_subject_hidden', 'hidden', array('name' => 'template_subject_hidden'));
|
203 |
+
$fieldset->addField('template_text_hidden', 'hidden', array('name' => 'template_text_hidden'));
|
204 |
+
$fieldset->addField('template_styles_hidden', 'hidden', array('name' => 'template_styles_hidden'));
|
205 |
+
|
206 |
+
// Used for magento send type
|
207 |
+
$fieldset->addField('template_subject', 'text', array(
|
208 |
+
'name' => 'template_subject',
|
209 |
+
'label' => Mage::helper('adminhtml')->__('Template Subject'),
|
210 |
+
'onchange' => "syncHiddenValue(this);",
|
211 |
+
'container_id' => 'container_template_subject',
|
212 |
+
'required' => true,
|
213 |
+
));
|
214 |
+
|
215 |
+
// Create field to allow selecting Bronto Message to bind to template
|
216 |
$fieldset->addField('bronto_message_id', 'select', array(
|
217 |
+
'name' => 'bronto_message_id',
|
218 |
+
'label' => Mage::helper('adminhtml')->__('Bronto Message'),
|
219 |
+
'container_id' => 'container_bronto_message_id',
|
220 |
+
'onchange' => "syncHiddenValue(this);",
|
221 |
+
'values' => Mage::helper('bronto_email/message')->getAllMessageOptions(),
|
222 |
'required' => true,
|
223 |
));
|
224 |
|
225 |
+
// Display Variables that are available for the original template
|
226 |
$fieldset->addField('template_variables_key', 'label', array(
|
227 |
'container_id' => 'template_variables_key_row',
|
228 |
'label' => Mage::helper('adminhtml')->__('Variables'),
|
229 |
'after_element_html' => '<div id="template_variables_key_list"></div>' .
|
230 |
+
($templateId ? '' : '<script>$("template_variables_key_row").hide();</script>')
|
231 |
+
));
|
232 |
+
|
233 |
+
// Display template text that was imported into Bronto
|
234 |
+
$fieldset->addField('orig_template_text', 'textarea', array(
|
235 |
+
'name' => 'orig_template_text',
|
236 |
+
'label' => Mage::helper('adminhtml')->__('Original Template Content'),
|
237 |
+
'note' => $this->__('<strong>For Reference Only</strong>'),
|
238 |
+
'container_id' => 'container_orig_template_text',
|
239 |
+
'onchange' => "syncHiddenValue(this);",
|
240 |
+
'readonly' => true,
|
241 |
+
'style' => 'height:24em;background-color:#efefef;',
|
242 |
+
));
|
243 |
+
|
244 |
+
$fieldset->addField('orig_template_variables', 'hidden', array(
|
245 |
+
'name' => 'orig_template_variables',
|
246 |
+
));
|
247 |
+
|
248 |
+
$fieldset->addField('variables', 'hidden', array(
|
249 |
+
'name' => 'variables',
|
250 |
+
'value' => Zend_Json::encode($this->getVariables())
|
251 |
+
));
|
252 |
+
|
253 |
+
$fieldset->addField('template_variables', 'hidden', array(
|
254 |
+
'name' => 'template_variables',
|
255 |
));
|
256 |
|
257 |
+
// Used for magento send type
|
258 |
+
$insertVariableButton = $this->getLayout()
|
259 |
+
->createBlock('adminhtml/widget_button', '', array(
|
260 |
+
'type' => 'button',
|
261 |
+
'label' => Mage::helper('adminhtml')->__('Insert Variable...'),
|
262 |
+
'container_id' => 'container_widget_button',
|
263 |
+
'onclick' => 'templateControl.openVariableChooser();return false;',
|
264 |
+
));
|
265 |
+
|
266 |
+
$fieldset->addField('insert_variable', 'note', array(
|
267 |
+
'text' => $insertVariableButton->toHtml()
|
268 |
+
));
|
269 |
+
|
270 |
+
$fieldset->addField('template_text', 'textarea', array(
|
271 |
+
'name' => 'template_text',
|
272 |
+
'label' => Mage::helper('adminhtml')->__('Template Content'),
|
273 |
+
'title' => Mage::helper('adminhtml')->__('Template Content'),
|
274 |
+
'container_id' => 'container_template_text',
|
275 |
+
'onchange' => "syncHiddenValue(this);",
|
276 |
+
'required' => true,
|
277 |
+
'style' => 'height:24em',
|
278 |
+
));
|
279 |
+
|
280 |
+
if (!$this->getEmailTemplate()->isPlain()) {
|
281 |
+
$fieldset->addField('template_styles', 'textarea', array(
|
282 |
+
'name' => 'template_styles',
|
283 |
+
'label' => Mage::helper('adminhtml')->__('Template Styles'),
|
284 |
+
'container_id' => 'field_template_styles',
|
285 |
+
'onchange' => "syncHiddenValue(this);",
|
286 |
+
));
|
287 |
+
}
|
288 |
+
|
289 |
if ($templateId) {
|
290 |
$form->addValues($this->getEmailTemplate()->getData());
|
291 |
$form->addValues(array(
|
292 |
'template_variables' => Zend_Json::encode($this->getEmailTemplate()->getVariablesOptionArray(true)),
|
293 |
+
// Populate hidden fields
|
294 |
+
'bronto_message_id_hidden' => $this->getEmailTemplate()->getBrontoMessageId(),
|
295 |
+
'template_subject_hidden' => $this->getEmailTemplate()->getTemplateSubject(),
|
296 |
+
'template_text_hidden' => $this->getEmailTemplate()->getTemplateText(),
|
297 |
+
'template_styles_hidden' => $this->getEmailTemplate()->getTemplateStyles(),
|
298 |
));
|
299 |
}
|
300 |
|
302 |
$form->setValues($values);
|
303 |
}
|
304 |
|
305 |
+
$this->setForm($form);
|
306 |
+
|
307 |
+
return parent::_prepareForm();
|
308 |
}
|
309 |
+
|
310 |
+
/**
|
311 |
+
* Return current email template model
|
312 |
+
*
|
313 |
+
* @return Mage_Core_Model_Email_Template
|
314 |
+
*/
|
315 |
+
public function getEmailTemplate()
|
316 |
+
{
|
317 |
+
return Mage::registry('current_email_template');
|
318 |
+
}
|
319 |
+
|
320 |
+
/**
|
321 |
+
* Filter Store Options by stores where module is enabled
|
322 |
+
* @param bool $empty
|
323 |
+
* @param bool $all
|
324 |
+
*
|
325 |
+
* @return array
|
326 |
+
*/
|
327 |
+
protected function _getActiveStoreValuesForForm($empty = false, $all = false)
|
328 |
+
{
|
329 |
+
$storeOptions = Mage::getSingleton('adminhtml/system_store')->getStoreValuesForForm($empty, $all);
|
330 |
+
$curWebsite = 0;
|
331 |
+
$curWebCount = 0;
|
332 |
+
|
333 |
+
// Cycle Through Options
|
334 |
+
foreach ($storeOptions as $optionId => $option) {
|
335 |
+
if (is_array($option['value']) && empty($option['value'])) {
|
336 |
+
if ($optionId != $curWebsite) {
|
337 |
+
if ($curWebCount == 0) {
|
338 |
+
unset($storeOptions[$curWebsite]);
|
339 |
+
}
|
340 |
+
$curWebCount = 0;
|
341 |
+
}
|
342 |
+
|
343 |
+
$curWebsite = $optionId;
|
344 |
+
}
|
345 |
+
|
346 |
+
// If Option has an array value with items
|
347 |
+
if (is_array($option['value']) && count($option['value']) >= 1) {
|
348 |
+
$curWebCount++;
|
349 |
+
// Cycle Through Sub-Options
|
350 |
+
foreach ($option['value'] as $subId => $subOption) {
|
351 |
+
// If Sub-Option value is a string and is numeric
|
352 |
+
if (is_string($subOption['value']) && is_numeric($subOption['value'])) {
|
353 |
+
// If Sub-Option Value is a store id and that store is not enabled, unset it's value
|
354 |
+
if (!Mage::helper('bronto_email')->isEnabled($subOption['value'])) {
|
355 |
+
unset($storeOptions[$optionId]['value'][$subId]);
|
356 |
+
// If Option no longer has any values, remove Option
|
357 |
+
if (count($storeOptions[$optionId]['value']) < 1) {
|
358 |
+
$curWebCount--;
|
359 |
+
unset($storeOptions[$optionId]);
|
360 |
+
}
|
361 |
+
}
|
362 |
+
}
|
363 |
+
}
|
364 |
+
}
|
365 |
+
}
|
366 |
+
|
367 |
+
// If the last website has no groups, remove it
|
368 |
+
if ($curWebCount == 0) {
|
369 |
+
if (array_key_exists($curWebsite, $storeOptions)) {
|
370 |
+
unset($storeOptions[$curWebsite]);
|
371 |
+
}
|
372 |
+
}
|
373 |
+
|
374 |
+
return $storeOptions;
|
375 |
+
}
|
376 |
+
|
377 |
+
/**
|
378 |
+
* Retrieve variables to insert into email
|
379 |
+
*
|
380 |
+
* @return array
|
381 |
+
*/
|
382 |
+
public function getVariables()
|
383 |
+
{
|
384 |
+
$variables = array();
|
385 |
+
$variables[] = Mage::getModel('core/source_email_variables')
|
386 |
+
->toOptionArray(true);
|
387 |
+
$customVariables = Mage::getModel('core/variable')
|
388 |
+
->getVariablesOptionArray(true);
|
389 |
+
if ($customVariables) {
|
390 |
+
$variables[] = $customVariables;
|
391 |
+
}
|
392 |
+
/* @var $template Mage_Core_Model_Email_Template */
|
393 |
+
$template = Mage::registry('current_email_template');
|
394 |
+
if ($template->getId() && $templateVariables = $template->getVariablesOptionArray(true)) {
|
395 |
+
$variables[] = $templateVariables;
|
396 |
+
}
|
397 |
+
|
398 |
+
return $variables;
|
399 |
+
}
|
400 |
+
|
401 |
}
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid.php
CHANGED
@@ -7,33 +7,30 @@
|
|
7 |
*/
|
8 |
class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid extends Mage_Adminhtml_Block_System_Email_Template_Grid
|
9 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
protected function _prepareCollection()
|
11 |
{
|
12 |
-
/* @var $collection
|
13 |
-
$collection = Mage::
|
14 |
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
$
|
|
|
|
|
|
|
|
|
19 |
}
|
20 |
|
21 |
-
//
|
22 |
-
|
23 |
-
$resource = Mage::getSingleton('core/resource');
|
24 |
-
$tableName = $resource->getTableName('core/store');
|
25 |
-
$mainTable = $resource->getTableName('core/email_template');
|
26 |
-
$version = Mage::getVersionInfo();
|
27 |
-
|
28 |
-
if (1 == $version['major'] && 9 != $version['minor'] && 10 != $version['minor']) {
|
29 |
-
$mainTable = 'main_table';
|
30 |
-
}
|
31 |
-
$collection->getSelect()
|
32 |
-
->join(
|
33 |
-
array('core_store' => $tableName),
|
34 |
-
"`$mainTable`.store_id=`core_store`.store_id",
|
35 |
-
array('storename' => 'core_store.name')
|
36 |
-
);
|
37 |
|
38 |
$this->setCollection($collection);
|
39 |
|
@@ -47,21 +44,20 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid extends Mage_Admin
|
|
47 |
*/
|
48 |
protected function _prepareColumns()
|
49 |
{
|
50 |
-
if (!Mage::helper('bronto_email')->
|
51 |
return parent::_prepareColumns();
|
52 |
}
|
53 |
|
54 |
$this->addColumn(
|
55 |
-
'template_id',
|
56 |
-
array(
|
57 |
'header' => Mage::helper('adminhtml')->__('ID'),
|
58 |
-
'index' => 'template_id'
|
|
|
59 |
)
|
60 |
);
|
61 |
|
62 |
$this->addColumn(
|
63 |
-
'added_at',
|
64 |
-
array(
|
65 |
'header' => Mage::helper('adminhtml')->__('Date Added'),
|
66 |
'index' => 'added_at',
|
67 |
'gmtoffset' => true,
|
@@ -70,8 +66,7 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid extends Mage_Admin
|
|
70 |
);
|
71 |
|
72 |
$this->addColumn(
|
73 |
-
'modified_at',
|
74 |
-
array(
|
75 |
'header' => Mage::helper('adminhtml')->__('Date Updated'),
|
76 |
'index' => 'modified_at',
|
77 |
'gmtoffset' => true,
|
@@ -80,29 +75,99 @@ class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid extends Mage_Admin
|
|
80 |
);
|
81 |
|
82 |
$this->addColumn(
|
83 |
-
'
|
84 |
-
array(
|
85 |
'header' => Mage::helper('adminhtml')->__('Name'),
|
86 |
'index' => 'template_code'
|
87 |
)
|
88 |
);
|
89 |
|
90 |
$this->addColumn(
|
91 |
-
'message_name',
|
92 |
-
array(
|
93 |
'header' => Mage::helper('adminhtml')->__('Bronto Message'),
|
94 |
-
'index' => 'bronto_message_name'
|
95 |
)
|
96 |
);
|
97 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
$this->addColumn(
|
99 |
-
'store',
|
100 |
-
array(
|
101 |
'header' => Mage::helper('adminhtml')->__('Store'),
|
102 |
-
'index' => '
|
|
|
|
|
|
|
103 |
)
|
104 |
);
|
105 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
106 |
return $this;
|
107 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
108 |
}
|
7 |
*/
|
8 |
class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid extends Mage_Adminhtml_Block_System_Email_Template_Grid
|
9 |
{
|
10 |
+
protected function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
|
14 |
+
$this->setId('systemBrontoEmailTemplateGrid');
|
15 |
+
}
|
16 |
+
|
17 |
protected function _prepareCollection()
|
18 |
{
|
19 |
+
/* @var $collection Bronto_Email_Model_Mysql4_Template_Collection */
|
20 |
+
$collection = Mage::getModel('bronto_email/template')->getCollection();
|
21 |
|
22 |
+
// Apply conditional logic to handle 1.9 overriding collection _construct
|
23 |
+
if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, 9, 10))) {
|
24 |
+
$templateTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/template');
|
25 |
+
$brontoTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/message');
|
26 |
+
$collection->getSelect()->joinLeft(
|
27 |
+
$brontoTable,
|
28 |
+
"`{$templateTable}`.`template_id` = `{$brontoTable}`.`core_template_id`"
|
29 |
+
);
|
30 |
}
|
31 |
|
32 |
+
// Limit grid to show only those templates with message id assigned
|
33 |
+
$collection->addFieldToFilter('bronto_message_id', array('notnull' => true));
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
|
35 |
$this->setCollection($collection);
|
36 |
|
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,
|
66 |
);
|
67 |
|
68 |
$this->addColumn(
|
69 |
+
'modified_at', array(
|
|
|
70 |
'header' => Mage::helper('adminhtml')->__('Date Updated'),
|
71 |
'index' => 'modified_at',
|
72 |
'gmtoffset' => true,
|
75 |
);
|
76 |
|
77 |
$this->addColumn(
|
78 |
+
'temlate_code', array(
|
|
|
79 |
'header' => Mage::helper('adminhtml')->__('Name'),
|
80 |
'index' => 'template_code'
|
81 |
)
|
82 |
);
|
83 |
|
84 |
$this->addColumn(
|
85 |
+
'message_name', array(
|
|
|
86 |
'header' => Mage::helper('adminhtml')->__('Bronto Message'),
|
87 |
+
'index' => 'bronto_message_name',
|
88 |
)
|
89 |
);
|
90 |
|
91 |
+
$storeCodes = array();
|
92 |
+
foreach (Mage::app()->getStores() as $id => $store) {
|
93 |
+
$storeName = $store->getName();
|
94 |
+
if (!Mage::helper('bronto_email')->isEnabled($store->getId())) {
|
95 |
+
$storeName .= ' (Disabled)';
|
96 |
+
}
|
97 |
+
$storeCodes[$id] = $storeName;
|
98 |
+
}
|
99 |
+
|
100 |
$this->addColumn(
|
101 |
+
'store', array(
|
|
|
102 |
'header' => Mage::helper('adminhtml')->__('Store'),
|
103 |
+
'index' => 'store_id',
|
104 |
+
'type' => 'options',
|
105 |
+
'options' => $storeCodes,
|
106 |
+
'renderer' => 'bronto_email/adminhtml_system_email_template_grid_renderer_storename',
|
107 |
)
|
108 |
);
|
109 |
|
110 |
+
$this->addColumn(
|
111 |
+
'template_send_type',
|
112 |
+
array(
|
113 |
+
'header' => Mage::helper('adminhtml')->__('Send Type'),
|
114 |
+
'index' => 'template_send_type',
|
115 |
+
'type' => 'options',
|
116 |
+
'options' => array(
|
117 |
+
'marketing' => 'Bronto Marketing',
|
118 |
+
'transactional' => 'Bronto Transactional',
|
119 |
+
'magento' => 'Magento Email',
|
120 |
+
),
|
121 |
+
)
|
122 |
+
);
|
123 |
+
|
124 |
+
$this->addColumn('action', array(
|
125 |
+
'header' => Mage::helper('adminhtml')->__('Action'),
|
126 |
+
'index' => 'template_id',
|
127 |
+
'sortable' => false,
|
128 |
+
'filter' => false,
|
129 |
+
'width' => '130px',
|
130 |
+
'renderer' => 'bronto_email/adminhtml_system_email_template_grid_renderer_action'
|
131 |
+
));
|
132 |
+
|
133 |
+
return $this;
|
134 |
+
}
|
135 |
+
|
136 |
+
protected function _prepareMassaction()
|
137 |
+
{
|
138 |
+
$this->setMassactionIdField('template_id');
|
139 |
+
$this->getMassactionBlock()->setFormFieldName('template_id');
|
140 |
+
$this->getMassactionBlock()->addItem('marketing', array(
|
141 |
+
'label' => Mage::helper('bronto_email')->__('Set to send as Bronto Marketing'),
|
142 |
+
'url' => $this->getUrl('*/*/updateSendType', array('send_type' => 'marketing')),
|
143 |
+
'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set the selected template(s) to send through Bronto as a marketing message?')
|
144 |
+
));
|
145 |
+
$this->getMassactionBlock()->addItem('transactional', array(
|
146 |
+
'label' => Mage::helper('bronto_email')->__('Set to send as Bronto Transactional'),
|
147 |
+
'url' => $this->getUrl('*/*/updateSendType', array('send_type' => 'transactional')),
|
148 |
+
'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set the selected template(s) to send through Bronto as a transactional message?')
|
149 |
+
));
|
150 |
+
$this->getMassactionBlock()->addItem('magento', array(
|
151 |
+
'label' => Mage::helper('bronto_email')->__('Set to send as Magento Email'),
|
152 |
+
'url' => $this->getUrl('*/*/updateSendType', array('send_type' => 'magento')),
|
153 |
+
'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to set the selected template(s) to send through Magento?')
|
154 |
+
));
|
155 |
+
$this->getMassactionBlock()->addItem('delete', array(
|
156 |
+
'label' => Mage::helper('bronto_email')->__('Delete'),
|
157 |
+
'url' => $this->getUrl('*/*/massDelete', array('' => '')),
|
158 |
+
'confirm' => Mage::helper('bronto_email')->__('Are you sure you want to delete the selected template(s)? If any of the selected template(s) are currently assigned to be used, those will automatically be reassigned to the default Magento template(s).')
|
159 |
+
));
|
160 |
return $this;
|
161 |
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* get Row Url for editing template on row click
|
165 |
+
* @param type $row
|
166 |
+
* @return string
|
167 |
+
*/
|
168 |
+
public function getRowUrl($row)
|
169 |
+
{
|
170 |
+
return $this->getUrl('*/*/brontoEdit', array('id' => $row->getId()));
|
171 |
+
}
|
172 |
+
|
173 |
}
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid/Renderer/Action.php
ADDED
@@ -0,0 +1,66 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/Message.php
DELETED
@@ -1,30 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* @package Bronto\Email
|
5 |
-
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
-
* @version 1.1.1
|
7 |
-
*/
|
8 |
-
class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid_Renderer_Message extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
9 |
-
{
|
10 |
-
/**
|
11 |
-
* @param Varien_Object $row
|
12 |
-
* @return string
|
13 |
-
*/
|
14 |
-
public function render(Varien_Object $row)
|
15 |
-
{
|
16 |
-
$skinUrl = Mage::getBaseUrl(Mage_Core_Model_Store::URL_TYPE_SKIN) . 'adminhtml/default/default/bronto/';
|
17 |
-
|
18 |
-
if ($row->getBrontoMessageApproved()) {
|
19 |
-
return '
|
20 |
-
<img src="' . $skinUrl . 'images/message_approved.gif" style="vertical-align:top;padding-right:1px" />
|
21 |
-
<strong>Approved!</strong>
|
22 |
-
';
|
23 |
-
} else {
|
24 |
-
return '
|
25 |
-
<img src="' . $skinUrl . 'images/message_not_approved.gif" style="vertical-align:top;padding-right:1px" />
|
26 |
-
<strong>Not Approved!</strong>
|
27 |
-
';
|
28 |
-
}
|
29 |
-
}
|
30 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/Email/Block/Adminhtml/System/Email/Template/Grid/Renderer/Storename.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @package Bronto\Email
|
5 |
+
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
+
* @version 1.1.1
|
7 |
+
*/
|
8 |
+
class Bronto_Email_Block_Adminhtml_System_Email_Template_Grid_Renderer_Storename extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* @param Varien_Object $row
|
12 |
+
* @return string
|
13 |
+
*/
|
14 |
+
public function render(Varien_Object $row)
|
15 |
+
{
|
16 |
+
$store = Mage::getModel('core/store')->load($row->getStoreId());
|
17 |
+
$storeName = $store->getName();
|
18 |
+
if (!Mage::helper('bronto_email')->isEnabled($store->getId())) {
|
19 |
+
$storeName .= ' (Disabled)';
|
20 |
+
}
|
21 |
+
|
22 |
+
return $storeName;
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Bronto/Email/Helper/Contact.php
CHANGED
@@ -18,7 +18,7 @@ class Bronto_Email_Helper_Contact extends Bronto_Common_Helper_Contact
|
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
-
* @param string
|
22 |
* @return Bronto_Api_Contact_Row
|
23 |
*/
|
24 |
public function getContactByEmail($email, $customSource = 'bronto_email', $store = null)
|
18 |
}
|
19 |
|
20 |
/**
|
21 |
+
* @param string $email
|
22 |
* @return Bronto_Api_Contact_Row
|
23 |
*/
|
24 |
public function getContactByEmail($email, $customSource = 'bronto_email', $store = null)
|
app/code/community/Bronto/Email/Helper/Data.php
CHANGED
@@ -7,10 +7,25 @@
|
|
7 |
*/
|
8 |
class Bronto_Email_Helper_Data extends Bronto_Common_Helper_Data implements Bronto_Common_Helper_DataInterface
|
9 |
{
|
10 |
-
const XML_PATH_ENABLED
|
11 |
-
const
|
|
|
12 |
const XML_PATH_LOG_FIELDS_ENABLED = 'bronto_email/settings/log_fields_enabled';
|
13 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
/**
|
15 |
* Retrieve helper module name
|
16 |
*
|
@@ -22,21 +37,111 @@ class Bronto_Email_Helper_Data extends Bronto_Common_Helper_Data implements Bron
|
|
22 |
}
|
23 |
|
24 |
/**
|
25 |
-
*
|
26 |
*
|
27 |
* @return bool
|
28 |
*/
|
29 |
-
public function
|
30 |
{
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
}
|
33 |
|
34 |
/**
|
|
|
|
|
35 |
* @return bool
|
36 |
*/
|
37 |
-
public function isEnabled()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
{
|
39 |
-
|
|
|
|
|
|
|
|
|
40 |
}
|
41 |
|
42 |
/**
|
@@ -44,7 +149,7 @@ class Bronto_Email_Helper_Data extends Bronto_Common_Helper_Data implements Bron
|
|
44 |
*/
|
45 |
public function isLogEnabled()
|
46 |
{
|
47 |
-
return (bool)
|
48 |
}
|
49 |
|
50 |
/**
|
@@ -52,6 +157,92 @@ class Bronto_Email_Helper_Data extends Bronto_Common_Helper_Data implements Bron
|
|
52 |
*/
|
53 |
public function isLogFieldsEnabled()
|
54 |
{
|
55 |
-
return (bool)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
}
|
57 |
}
|
7 |
*/
|
8 |
class Bronto_Email_Helper_Data extends Bronto_Common_Helper_Data implements Bronto_Common_Helper_DataInterface
|
9 |
{
|
10 |
+
const XML_PATH_ENABLED = 'bronto_email/settings/enabled';
|
11 |
+
const XML_PATH_USE_BRONTO = 'bronto_email/settings/use_bronto';
|
12 |
+
const XML_PATH_LOG_ENABLED = 'bronto_email/settings/log_enabled';
|
13 |
const XML_PATH_LOG_FIELDS_ENABLED = 'bronto_email/settings/log_fields_enabled';
|
14 |
|
15 |
+
/**
|
16 |
+
* @param string $path
|
17 |
+
* @return bool
|
18 |
+
*/
|
19 |
+
public function disableModule($scope = 'default', $scopeId = 0)
|
20 |
+
{
|
21 |
+
return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId);
|
22 |
+
}
|
23 |
+
|
24 |
+
/**
|
25 |
+
* Xml path to email template nodes
|
26 |
+
*/
|
27 |
+
const XML_PATH_TEMPLATE_EMAIL = '//sections/*/groups/*/fields/*[source_model="adminhtml/system_config_source_email_template"]';
|
28 |
+
|
29 |
/**
|
30 |
* Retrieve helper module name
|
31 |
*
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
+
* Determine if any stores have module enabled
|
41 |
*
|
42 |
* @return bool
|
43 |
*/
|
44 |
+
public function isEnabledForAny()
|
45 |
{
|
46 |
+
$stores = Mage::app()->getStores();
|
47 |
+
if (is_array($stores) && count($stores) >= 1) {
|
48 |
+
foreach ($stores as $store) {
|
49 |
+
if ($this->isEnabled($store->getId())) {
|
50 |
+
return true;
|
51 |
+
}
|
52 |
+
}
|
53 |
+
}
|
54 |
+
return false;
|
55 |
}
|
56 |
|
57 |
/**
|
58 |
+
* @param string|int $store
|
59 |
+
* @param string|int $website
|
60 |
* @return bool
|
61 |
*/
|
62 |
+
public function isEnabled($store = null, $website = null)
|
63 |
+
{
|
64 |
+
if (!$this->getApiToken($store, $website)) {
|
65 |
+
return false;
|
66 |
+
}
|
67 |
+
|
68 |
+
return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED, $store, $website);
|
69 |
+
}
|
70 |
+
|
71 |
+
/*
|
72 |
+
* Get Text to display in notice when enabling module
|
73 |
+
*
|
74 |
+
* @return string
|
75 |
+
*/
|
76 |
+
public function getModuleEnabledText()
|
77 |
+
{
|
78 |
+
$message = parent::getModuleEnabledText();
|
79 |
+
$scopeData = $this->getScopeParams();
|
80 |
+
if ($scopeData['scope'] != 'default') {
|
81 |
+
$message = $this->__(
|
82 |
+
'If the API token being used for this configuration scope is different from that of the Default Config scope, ' .
|
83 |
+
'you should un-check the `Use Website` or `Use Default` for ALL options in the <em>Assign Templates</em> group on this page ' .
|
84 |
+
'and select the desired templates.'
|
85 |
+
);
|
86 |
+
}
|
87 |
+
return $message;
|
88 |
+
}
|
89 |
+
|
90 |
+
/**
|
91 |
+
* Get Config setting for sending through bronto
|
92 |
+
*
|
93 |
+
* @param string|int $store
|
94 |
+
* @param string|int $website
|
95 |
+
* @return boolean
|
96 |
+
*/
|
97 |
+
public function canUseBronto($store = null, $website = null)
|
98 |
+
{
|
99 |
+
if (!$this->getApiToken($store, $website)) {
|
100 |
+
return false;
|
101 |
+
}
|
102 |
+
|
103 |
+
return (bool)$this->getAdminScopedConfig(self::XML_PATH_USE_BRONTO, $store, $website);
|
104 |
+
}
|
105 |
+
|
106 |
+
/**
|
107 |
+
* Sets the "Send through Bronto" option for any config scope
|
108 |
+
*
|
109 |
+
* @param boolean $brontoSend
|
110 |
+
* @param int $storeId
|
111 |
+
* @param int $websiteId
|
112 |
+
* @return Bronto_Email_Helper_Data
|
113 |
+
*/
|
114 |
+
public function setUseBronto($brontoSend, $storeId = null, $websiteId = null)
|
115 |
+
{
|
116 |
+
if (!is_null($storeId)) {
|
117 |
+
$scope = 'stores';
|
118 |
+
$scopeId = $storeId;
|
119 |
+
} else if (!is_null($websiteId)) {
|
120 |
+
$scope = 'websites';
|
121 |
+
$scopeId = $websiteId;
|
122 |
+
} else {
|
123 |
+
$scope = 'default';
|
124 |
+
$scopeId = '0';
|
125 |
+
}
|
126 |
+
|
127 |
+
$config = Mage::getModel('core/config');
|
128 |
+
$config->saveConfig(self::XML_PATH_USE_BRONTO, $brontoSend ? '1' : '0', $scope, $scopeId);
|
129 |
+
return $this;
|
130 |
+
}
|
131 |
+
|
132 |
+
/**
|
133 |
+
* Determine if email can be sent through bronto
|
134 |
+
*
|
135 |
+
* @param Mage_Core_Model_Email_Template $template
|
136 |
+
* @return boolean
|
137 |
+
*/
|
138 |
+
public function canSendBronto(Mage_Core_Model_Email_Template $template, $storeId = null)
|
139 |
{
|
140 |
+
if ($this->isEnabled($storeId) && $this->canUseBronto($storeId) && $template->getTemplateSendType() != 'magento') {
|
141 |
+
return true;
|
142 |
+
}
|
143 |
+
|
144 |
+
return false;
|
145 |
}
|
146 |
|
147 |
/**
|
149 |
*/
|
150 |
public function isLogEnabled()
|
151 |
{
|
152 |
+
return (bool)$this->getAdminScopedConfig(self::XML_PATH_LOG_ENABLED);
|
153 |
}
|
154 |
|
155 |
/**
|
157 |
*/
|
158 |
public function isLogFieldsEnabled()
|
159 |
{
|
160 |
+
return (bool)$this->getAdminScopedConfig(self::XML_PATH_LOG_FIELDS_ENABLED);
|
161 |
+
}
|
162 |
+
|
163 |
+
/**
|
164 |
+
* @see parent
|
165 |
+
* @return bool
|
166 |
+
*/
|
167 |
+
public function hasCustomConfig() {
|
168 |
+
return true;
|
169 |
+
}
|
170 |
+
|
171 |
+
/**
|
172 |
+
* Gets any saved emails, and reports it
|
173 |
+
*
|
174 |
+
* @return array
|
175 |
+
*/
|
176 |
+
public function getCustomConfig() {
|
177 |
+
$emails = array();
|
178 |
+
$templates = Mage::getModel('bronto_email/template')->getCollection();
|
179 |
+
|
180 |
+
if ($this->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 5, 9, 10))) {
|
181 |
+
$templateTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/template');
|
182 |
+
$brontoTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/message');
|
183 |
+
$templates->getSelect()->joinLeft(
|
184 |
+
$brontoTable,
|
185 |
+
"`{$templateTable}`.`template_id` = `{$brontoTable}`.`core_template_id`"
|
186 |
+
);
|
187 |
+
}
|
188 |
+
|
189 |
+
$templates->addFieldToFilter('bronto_message_id', array('notnull' => true));
|
190 |
+
|
191 |
+
foreach ($templates as $template) {
|
192 |
+
$emails[] = array(
|
193 |
+
'template_id' => $template->getTemplateId(),
|
194 |
+
'template_code' => $template->getTemplateCode(),
|
195 |
+
'bronto_message_id' => $template->getBrontoMessageId(),
|
196 |
+
'bronto_message_name' => $template->getBrontoMessageName(),
|
197 |
+
'send_type' => $template->getTemplateSendType(),
|
198 |
+
);
|
199 |
+
}
|
200 |
+
|
201 |
+
$settings = array();
|
202 |
+
foreach ($this->getTemplatePaths() as $configPath) {
|
203 |
+
$data = Mage::getStoreConfig($configPath);
|
204 |
+
if (str_replace('/', '_', $configPath) == $data) {
|
205 |
+
$data = 'Default';
|
206 |
+
}
|
207 |
+
$settings[$configPath] = $data;
|
208 |
+
}
|
209 |
+
|
210 |
+
return array(
|
211 |
+
'templates' => $emails,
|
212 |
+
'settings' => $settings,
|
213 |
+
);
|
214 |
+
}
|
215 |
+
|
216 |
+
/**
|
217 |
+
* Get array of all template config paths
|
218 |
+
* @return array
|
219 |
+
*/
|
220 |
+
public function getTemplatePaths()
|
221 |
+
{
|
222 |
+
$templatePaths = array();
|
223 |
+
|
224 |
+
$configSections = Mage::getSingleton('adminhtml/config')->getSections();
|
225 |
+
|
226 |
+
// look for node entries in all system.xml that use source_model=adminhtml/system_config_source_email_template
|
227 |
+
// they are will be templates, what we try find
|
228 |
+
$sysCfgNodes = $configSections->xpath(self::XML_PATH_TEMPLATE_EMAIL);
|
229 |
+
if (!is_array($sysCfgNodes)) {
|
230 |
+
return array();
|
231 |
+
}
|
232 |
+
|
233 |
+
foreach ($sysCfgNodes as $fieldNode) {
|
234 |
+
|
235 |
+
$groupNode = $fieldNode->getParent()->getParent();
|
236 |
+
$sectionNode = $groupNode->getParent()->getParent();
|
237 |
+
|
238 |
+
// create email template path in system.xml
|
239 |
+
$sectionName = $sectionNode->getName();
|
240 |
+
$groupName = $groupNode->getName();
|
241 |
+
$fieldName = $fieldNode->getName();
|
242 |
+
|
243 |
+
$templatePaths[] = implode('/', array($sectionName, $groupName, $fieldName));
|
244 |
+
}
|
245 |
+
|
246 |
+
return $templatePaths;
|
247 |
}
|
248 |
}
|
app/code/community/Bronto/Email/Model/Email/Message.php
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* @package Bronto\Email
|
5 |
-
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
-
* @version 1.1.1
|
7 |
-
*/
|
8 |
-
class Bronto_Email_Model_Email_Message extends Bronto_Common_Model_Email_Message
|
9 |
-
{
|
10 |
-
/**
|
11 |
-
* @var string
|
12 |
-
*/
|
13 |
-
protected $_helper = 'bronto_email';
|
14 |
-
|
15 |
-
/**
|
16 |
-
* Log about the functionality of sending the email before it goes out
|
17 |
-
*
|
18 |
-
* @param Bronto_Api_Contact_Row $contact
|
19 |
-
* @param Bronto_Api_Message_Row $message
|
20 |
-
*
|
21 |
-
* @return void
|
22 |
-
*/
|
23 |
-
protected function _beforeSend(Bronto_Api_Contact_Row $contact, Bronto_Api_Message_Row $message)
|
24 |
-
{
|
25 |
-
Mage::dispatchEvent('bronto_email_send_before');
|
26 |
-
|
27 |
-
if (Mage::helper('bronto_email')->isLogEnabled()) {
|
28 |
-
$this->_log = Mage::getModel('bronto_email/log');
|
29 |
-
$this->_log->setCustomerEmail($contact->email);
|
30 |
-
$this->_log->setContactId($contact->id);
|
31 |
-
$this->_log->setMessageId($message->id);
|
32 |
-
$this->_log->setMessageName($message->name);
|
33 |
-
$this->_log->setSuccess(0);
|
34 |
-
$this->_log->setSentAt(new Zend_Db_Expr('NOW()'));
|
35 |
-
$this->_log->save();
|
36 |
-
}
|
37 |
-
}
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Log data on sending message
|
41 |
-
*
|
42 |
-
* @param bool $success
|
43 |
-
* @param string $error
|
44 |
-
* @param Bronto_Api_Delivery_Row $delivery
|
45 |
-
*
|
46 |
-
* @return void
|
47 |
-
*/
|
48 |
-
protected function _afterSend($success, $error = null, Bronto_Api_Delivery_Row $delivery = null)
|
49 |
-
{
|
50 |
-
Mage::dispatchEvent('bronto_email_send_after');
|
51 |
-
|
52 |
-
if (Mage::helper('bronto_email')->isLogEnabled()) {
|
53 |
-
$this->_log->setSuccess((int) $success);
|
54 |
-
if (!empty($error)) {
|
55 |
-
$this->_log->setError($error);
|
56 |
-
}
|
57 |
-
if ($delivery) {
|
58 |
-
$this->_log->setDeliveryId($delivery->id);
|
59 |
-
if (Mage::helper('bronto_email')->isLogFieldsEnabled()) {
|
60 |
-
$this->_log->setFields(serialize($delivery->getFields()));
|
61 |
-
}
|
62 |
-
}
|
63 |
-
$this->_log->save();
|
64 |
-
$this->_log = null;
|
65 |
-
}
|
66 |
-
}
|
67 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/Email/Model/Message.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @package Bronto\Email
|
5 |
+
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
+
* @version 1.1.6
|
7 |
+
*/
|
8 |
+
class Bronto_Email_Model_Message extends Mage_Core_Model_Abstract
|
9 |
+
{
|
10 |
+
public function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_init('bronto_email/message');
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Bronto/Email/Model/Mysql4/Log/Collection.php
CHANGED
@@ -17,8 +17,8 @@ class Bronto_Email_Model_Mysql4_Log_Collection extends Mage_Core_Model_Mysql4_Co
|
|
17 |
* Specify collection select order by attribute value
|
18 |
* Backward compatibility with EAV collection
|
19 |
*
|
20 |
-
* @param string
|
21 |
-
* @param string
|
22 |
* @return Bronto_Email_Model_Mysql4_Log_Collection
|
23 |
*/
|
24 |
public function addAttributeToSort($attribute, $dir = 'asc')
|
17 |
* Specify collection select order by attribute value
|
18 |
* Backward compatibility with EAV collection
|
19 |
*
|
20 |
+
* @param string $attribute
|
21 |
+
* @param string $dir
|
22 |
* @return Bronto_Email_Model_Mysql4_Log_Collection
|
23 |
*/
|
24 |
public function addAttributeToSort($attribute, $dir = 'asc')
|
app/code/community/Bronto/Email/Model/Mysql4/Message.php
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @package Bronto\Email
|
5 |
+
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
+
* @version 1.1.6
|
7 |
+
*/
|
8 |
+
class Bronto_Email_Model_Mysql4_Message extends Mage_Core_Model_Mysql4_Abstract
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Primery key auto increment flag
|
12 |
+
*
|
13 |
+
* @var bool
|
14 |
+
*/
|
15 |
+
protected $_isPkAutoIncrement = false;
|
16 |
+
|
17 |
+
public function _construct()
|
18 |
+
{
|
19 |
+
|
20 |
+
$this->_init('bronto_email/message', 'core_template_id');
|
21 |
+
}
|
22 |
+
}
|
app/code/community/Bronto/Email/Model/Mysql4/Message/Collection.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @package Bronto\Email
|
5 |
+
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
+
* @version 1.1.1
|
7 |
+
*/
|
8 |
+
class Bronto_Email_Model_Mysql4_Message_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
9 |
+
{
|
10 |
+
protected function _construct()
|
11 |
+
{
|
12 |
+
parent::_construct();
|
13 |
+
$this->_init('bronto_email/message');
|
14 |
+
}
|
15 |
+
}
|
app/code/community/Bronto/Email/Model/Mysql4/Template.php
ADDED
@@ -0,0 +1,72 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @package Bronto\Email
|
5 |
+
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
+
* @version 1.1.1
|
7 |
+
*/
|
8 |
+
class Bronto_Email_Model_Mysql4_Template extends Mage_Core_Model_Mysql4_Email_Template
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Initialize email template resource model
|
12 |
+
*
|
13 |
+
*/
|
14 |
+
protected function _construct()
|
15 |
+
{
|
16 |
+
parent::_construct();
|
17 |
+
$this->_init('bronto_email/template', 'template_id');
|
18 |
+
$this->_setMainTable('core/email_template', 'template_id');
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Get Template from original template code and store Id
|
23 |
+
* @param string $templateCode
|
24 |
+
* @param int|bool $storeId
|
25 |
+
* @return array
|
26 |
+
*/
|
27 |
+
public function loadByOriginalCode($templateCode, $storeId = false)
|
28 |
+
{
|
29 |
+
$select = $this->_getReadAdapter()->select()
|
30 |
+
->from($this->getTable('core/email_template'))
|
31 |
+
->where("`{$this->getTable('core/email_template')}`.`orig_template_code` = :orig_template_code")
|
32 |
+
->joinLeft(
|
33 |
+
$this->getTable('bronto_email/message'),
|
34 |
+
"`{$this->getTable('core/email_template')}`.`template_id` = `{$this->getTable('bronto_email/message')}`.`core_template_id`"
|
35 |
+
);
|
36 |
+
|
37 |
+
// Filter by store_id if provided
|
38 |
+
if ($storeId) {
|
39 |
+
$select->where("`{$this->getTable('bronto_email/message')}`.`store_id` = ?", $storeId);
|
40 |
+
}
|
41 |
+
|
42 |
+
$result = $this->_getReadAdapter()->fetchRow($select, array('orig_template_code' => $templateCode));
|
43 |
+
|
44 |
+
if (!$result) {
|
45 |
+
return array();
|
46 |
+
}
|
47 |
+
|
48 |
+
return $result;
|
49 |
+
}
|
50 |
+
|
51 |
+
/**
|
52 |
+
* Retrieve select object for load object data
|
53 |
+
*
|
54 |
+
* @param string $field
|
55 |
+
* @param mixed $value
|
56 |
+
* @param Mage_Core_Model_Abstract $object
|
57 |
+
* @return Zend_Db_Select
|
58 |
+
*/
|
59 |
+
protected function _getLoadSelect($field, $value, $object)
|
60 |
+
{
|
61 |
+
$field = $this->_getReadAdapter()->quoteIdentifier(sprintf('%s.%s', $this->getMainTable(), $field));
|
62 |
+
$select = $this->_getReadAdapter()->select()
|
63 |
+
->from($this->getMainTable())
|
64 |
+
->where($field . '=?', $value)
|
65 |
+
->joinLeft(
|
66 |
+
array($this->getTable('bronto_email/message')),
|
67 |
+
"`{$this->getMainTable()}`.`template_id` = `{$this->getTable('bronto_email/message')}`.`core_template_id`"
|
68 |
+
);
|
69 |
+
|
70 |
+
return $select;
|
71 |
+
}
|
72 |
+
}
|
app/code/community/Bronto/Email/Model/Mysql4/Template/Collection.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @package Bronto\Email
|
5 |
+
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
+
* @version 1.1.1
|
7 |
+
*/
|
8 |
+
class Bronto_Email_Model_Mysql4_Template_Collection extends Mage_Core_Model_Mysql4_Email_Template_Collection
|
9 |
+
{
|
10 |
+
protected $_brontoTable;
|
11 |
+
|
12 |
+
public function _construct()
|
13 |
+
{
|
14 |
+
parent::_construct();
|
15 |
+
$this->_templateTable = $this->getResource()->getTable('bronto_email/template');
|
16 |
+
$this->_brontoTable = $this->getResource()->getTable('bronto_email/message');
|
17 |
+
if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 9))) {
|
18 |
+
$this->_select->joinLeft(
|
19 |
+
array($this->_brontoTable),
|
20 |
+
"`{this->_templateTable}`.`template_id` = `{$this->_brontoTable}`.`core_template_id`"
|
21 |
+
);
|
22 |
+
}
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* Init collection select
|
27 |
+
*
|
28 |
+
* @return Bronto_Email_Model_Mysql4_Template_Collection
|
29 |
+
*/
|
30 |
+
protected function _initSelect()
|
31 |
+
{
|
32 |
+
$this->getSelect()->from(array('main_table' => $this->getMainTable()))
|
33 |
+
->joinLeft(
|
34 |
+
array($this->_brontoTable),
|
35 |
+
"`main_table`.`template_id` = `{$this->_brontoTable}`.`core_template_id`"
|
36 |
+
);
|
37 |
+
|
38 |
+
return $this;
|
39 |
+
}
|
40 |
+
}
|
app/code/community/Bronto/Email/Model/Observer.php
CHANGED
@@ -24,4 +24,86 @@ class Bronto_Email_Model_Observer
|
|
24 |
return;
|
25 |
}
|
26 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
24 |
return;
|
25 |
}
|
26 |
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Observes module becoming enabled and displays message warning user to configure settings
|
30 |
+
* @param Varien_Event_Observer $observer
|
31 |
+
*/
|
32 |
+
public function watchEnableAction(Varien_Event_Observer $observer)
|
33 |
+
{
|
34 |
+
Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('bronto_email')->__(Mage::helper('bronto_email')->getModuleEnabledText()));
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Grab Config Data Object before save and handle the 'Create New...' value for
|
39 |
+
* fields that were generated dynamically
|
40 |
+
* @param Varien_Event_Observer $observer
|
41 |
+
* @return Varien_Event_Observer
|
42 |
+
*/
|
43 |
+
public function saveDynamicField(Varien_Event_Observer $observer)
|
44 |
+
{
|
45 |
+
if (!Mage::helper(self::NOTICE_IDENTIFER)->isEnabled()) {
|
46 |
+
return $observer;
|
47 |
+
}
|
48 |
+
|
49 |
+
$action = $observer->getEvent()->getControllerAction();
|
50 |
+
|
51 |
+
if ($action->getRequest()->getParam('section') == 'bronto_email') {
|
52 |
+
$groups = $action->getRequest()->getPost('groups');
|
53 |
+
$website = $action->getRequest()->getParam('website');
|
54 |
+
$store = $action->getRequest()->getParam('store');
|
55 |
+
|
56 |
+
// Handle saving as real path values
|
57 |
+
$this->_handleAttributes($website, $store, $groups);
|
58 |
+
|
59 |
+
// Unset groups for bronto_email template paths
|
60 |
+
unset($groups['templates']);
|
61 |
+
$observer->getEvent()->getControllerAction()
|
62 |
+
->getRequest()->setPost('groups', $groups);
|
63 |
+
|
64 |
+
// reinit configuration
|
65 |
+
Mage::getConfig()->reinit();
|
66 |
+
Mage::app()->reinitStores();
|
67 |
+
}
|
68 |
+
|
69 |
+
return $observer;
|
70 |
+
}
|
71 |
+
|
72 |
+
/**
|
73 |
+
* Get Section, Group, and field from field path and save to "real" path
|
74 |
+
* @param type $website
|
75 |
+
* @param type $store
|
76 |
+
* @param type $groups
|
77 |
+
*/
|
78 |
+
protected function _handleAttributes($website, $store, $groups)
|
79 |
+
{
|
80 |
+
$fields = $groups['templates']['fields'];
|
81 |
+
$config = Mage::getModel('core/config');
|
82 |
+
$scopeParams = Mage::helper('bronto_common')->getScopeParams();
|
83 |
+
|
84 |
+
// Cycle through template fields
|
85 |
+
foreach ($fields as $field => $fieldData) {
|
86 |
+
// Get Section, Group and Field
|
87 |
+
list($sectionName, $groupName, $fieldName) = explode('-', $field);
|
88 |
+
$sectionName = str_replace('bronto_email_templates_', '', $sectionName);
|
89 |
+
if (is_array($fieldData) && !array_key_exists('value', $fieldData)) {
|
90 |
+
continue;
|
91 |
+
}
|
92 |
+
|
93 |
+
// Because send_type values aren't arrays, we have to
|
94 |
+
$value = (is_array($fieldData)) ? $fieldData['value'] : $fieldData;
|
95 |
+
|
96 |
+
$scope = $scopeParams['scope'];
|
97 |
+
if ($scope != 'default') {
|
98 |
+
$scope .= 's';
|
99 |
+
}
|
100 |
+
|
101 |
+
$config->saveConfig(
|
102 |
+
$sectionName.'/'.$groupName.'/'.$fieldName,
|
103 |
+
$value,
|
104 |
+
$scope,
|
105 |
+
$scopeParams[$scopeParams['scope'].'_id']
|
106 |
+
);
|
107 |
+
}
|
108 |
+
}
|
109 |
}
|
app/code/community/Bronto/Email/Model/Resource/Setup.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bronto_Email_Model_Resource_Setup extends Mage_Core_Model_Resource_Setup
|
4 |
+
{
|
5 |
+
/**
|
6 |
+
* Sets the Bronto sending for all available scopes if the module is enabled
|
7 |
+
*
|
8 |
+
* @return Bronto_Email_Model_Resource_Setup
|
9 |
+
*/
|
10 |
+
public function setDefaultSending()
|
11 |
+
{
|
12 |
+
$this->_reloadNewConfig()->_setDefaultSending()->_reloadNewConfig();
|
13 |
+
foreach (Mage::app()->getWebsites() as $website) {
|
14 |
+
$this->_setDefaultSending(null, $website->getId());
|
15 |
+
}
|
16 |
+
|
17 |
+
$this->_reloadNewConfig();
|
18 |
+
foreach (Mage::app()->getStores() as $store) {
|
19 |
+
$this->_setDefaultSending($store->getId());
|
20 |
+
}
|
21 |
+
|
22 |
+
return $this;
|
23 |
+
}
|
24 |
+
|
25 |
+
/**
|
26 |
+
* @return Bronto_Email_Model_Resource_Setup
|
27 |
+
*/
|
28 |
+
protected function _reloadNewConfig()
|
29 |
+
{
|
30 |
+
Mage::getConfig()->reinit();
|
31 |
+
Mage::app()->reinitStores();
|
32 |
+
return $this;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Sets the default sending to bronto is the module is enabled
|
37 |
+
*
|
38 |
+
* @param string|int $storeId
|
39 |
+
* @param string|int $websiteId
|
40 |
+
* @return Bronto_Email_Model_Resource_Setup
|
41 |
+
*/
|
42 |
+
protected function _setDefaultSending($storeId = null, $websiteId = null)
|
43 |
+
{
|
44 |
+
$helper = Mage::helper('bronto_email');
|
45 |
+
if (
|
46 |
+
$helper->isEnabled($storeId, $websiteId) &&
|
47 |
+
!$helper->canUseBronto($storeId, $websiteId)
|
48 |
+
) {
|
49 |
+
$helper->setUseBronto(true, $storeId, $websiteId);
|
50 |
+
}
|
51 |
+
return $this;
|
52 |
+
}
|
53 |
+
}
|
app/code/community/Bronto/Email/Model/System/Config/Backend/Templates/Field.php
ADDED
@@ -0,0 +1,40 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @param type $path
|
26 |
+
* @param type $value
|
27 |
+
* @return Bronto_Email_Model_System_Config_Backend_Templates_Field
|
28 |
+
*/
|
29 |
+
protected function _saveConfigData($path, $value)
|
30 |
+
{
|
31 |
+
Mage::getModel('core/config_data')
|
32 |
+
->load($path, 'path')
|
33 |
+
->setValue($value)
|
34 |
+
->setPath($path)
|
35 |
+
->save();
|
36 |
+
|
37 |
+
return $this;
|
38 |
+
}
|
39 |
+
|
40 |
+
}
|
app/code/community/Bronto/Email/Model/System/Config/Backend/Templates/Sendtype.php
ADDED
@@ -0,0 +1,37 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @param type $path
|
24 |
+
* @param type $value
|
25 |
+
* @return Bronto_Email_Model_System_Config_Backend_Templates_Field
|
26 |
+
*/
|
27 |
+
protected function _saveConfigData($path, $value)
|
28 |
+
{
|
29 |
+
Mage::getModel('core/config_data')
|
30 |
+
->load($path, 'path')
|
31 |
+
->setValue($value)
|
32 |
+
->setPath($path)
|
33 |
+
->save();
|
34 |
+
|
35 |
+
return $this;
|
36 |
+
}
|
37 |
+
}
|
app/code/community/Bronto/Email/Model/System/Config/Backend/Usebronto.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @package Bronto\Email
|
5 |
+
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
+
* @version 1.1.6
|
7 |
+
*/
|
8 |
+
class Bronto_Email_Model_System_Config_Backend_Usebronto extends Mage_Core_Model_Config_Data
|
9 |
+
{
|
10 |
+
|
11 |
+
protected $_eventPrefix = 'bronto_email_usebronto';
|
12 |
+
|
13 |
+
}
|
app/code/community/Bronto/Email/Model/System/Config/Source/Email/Template.php
CHANGED
@@ -1,8 +1,7 @@
|
|
1 |
<?php
|
2 |
|
3 |
-
|
4 |
class Bronto_Email_Model_System_Config_Source_Email_Template extends Mage_Adminhtml_Model_System_Config_Source_Email_Template
|
5 |
-
{
|
6 |
|
7 |
/**
|
8 |
* Generate list of email templates
|
@@ -10,40 +9,78 @@ class Bronto_Email_Model_System_Config_Source_Email_Template extends Mage_Adminh
|
|
10 |
* @return array
|
11 |
*/
|
12 |
public function toOptionArray()
|
13 |
-
{
|
14 |
-
if(!$collection = Mage::registry('config_system_email_template')) {
|
15 |
if (Mage::helper('bronto_email')->isEnabled() && Mage::app()->getRequest()->getParam('store')) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
if ($storeCode = Mage::app()->getRequest()->getParam('store')) {
|
17 |
-
$store
|
18 |
$storeId = $store->getId();
|
19 |
-
|
20 |
-
|
21 |
-
|
22 |
-
|
23 |
-
|
|
|
24 |
Mage::register('config_system_email_template', $collection);
|
25 |
} else {
|
26 |
-
$collection = Mage::
|
27 |
-
->load();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
28 |
|
29 |
Mage::register('config_system_email_template', $collection);
|
30 |
}
|
31 |
}
|
32 |
-
|
|
|
|
|
33 |
$templateName = Mage::helper('adminhtml')->__('Default Template from Locale');
|
34 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
$templateLabelNode = Mage::app()->getConfig()->getNode(self::XML_PATH_TEMPLATE_EMAIL . $nodeName . '/label');
|
36 |
if ($templateLabelNode) {
|
37 |
$templateName = Mage::helper('adminhtml')->__((string)$templateLabelNode);
|
38 |
$templateName = Mage::helper('adminhtml')->__('%s (Default Template from Locale)', $templateName);
|
39 |
}
|
|
|
40 |
array_unshift(
|
41 |
-
$options,
|
42 |
-
|
43 |
-
'value'=> $nodeName,
|
44 |
'label' => $templateName
|
45 |
)
|
46 |
);
|
|
|
47 |
return $options;
|
48 |
}
|
49 |
|
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
|
9 |
* @return array
|
10 |
*/
|
11 |
public function toOptionArray()
|
12 |
+
{
|
13 |
+
if (!$collection = Mage::registry('config_system_email_template')) {
|
14 |
if (Mage::helper('bronto_email')->isEnabled() && Mage::app()->getRequest()->getParam('store')) {
|
15 |
+
$collection = Mage::getModel('bronto_email/template')->getCollection();
|
16 |
+
|
17 |
+
// Apply conditional logic to handle 1.9 overriding collection _construct
|
18 |
+
if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 9))) {
|
19 |
+
$templateTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/template');
|
20 |
+
$brontoTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/message');
|
21 |
+
$collection->getSelect()->joinLeft(
|
22 |
+
$brontoTable,
|
23 |
+
"`{$templateTable}`.`template_id` = `{$brontoTable}`.`core_template_id`"
|
24 |
+
);
|
25 |
+
}
|
26 |
+
|
27 |
+
// if Store ID Specified, filter collection
|
28 |
if ($storeCode = Mage::app()->getRequest()->getParam('store')) {
|
29 |
+
$store = Mage::app()->getStore($storeCode);
|
30 |
$storeId = $store->getId();
|
31 |
+
|
32 |
+
$collection->addFieldToFilter('store_id', $storeId);
|
33 |
+
}
|
34 |
+
|
35 |
+
$collection->addOrder('template_code', 'asc')->load();
|
36 |
+
|
37 |
Mage::register('config_system_email_template', $collection);
|
38 |
} else {
|
39 |
+
$collection = Mage::getModel('bronto_email/template')->getCollection()
|
40 |
+
->addOrder('template_code', 'asc')->load();
|
41 |
+
|
42 |
+
// Apply conditional logic to handle 1.9 overriding collection _construct
|
43 |
+
if (Mage::helper('bronto_common')->isVersionMatch(Mage::getVersionInfo(), 1, array(4, 9))) {
|
44 |
+
$templateTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/template');
|
45 |
+
$brontoTable = Mage::getSingleton('core/resource')->getTableName('bronto_email/message');
|
46 |
+
$collection->getSelect()->joinLeft(
|
47 |
+
$brontoTable,
|
48 |
+
"`{$templateTable}`.`template_id` = `{$brontoTable}`.`core_template_id`"
|
49 |
+
);
|
50 |
+
}
|
51 |
|
52 |
Mage::register('config_system_email_template', $collection);
|
53 |
}
|
54 |
}
|
55 |
+
|
56 |
+
$options = $collection->toOptionArray();
|
57 |
+
|
58 |
$templateName = Mage::helper('adminhtml')->__('Default Template from Locale');
|
59 |
+
|
60 |
+
// Add support for Template configuration page
|
61 |
+
$pathParts = explode('/', $this->getPath());
|
62 |
+
|
63 |
+
if ('bronto_email' == $pathParts[0] && 'templates' == $pathParts[1]) {
|
64 |
+
$path = str_replace('-', '/', array_pop($pathParts));
|
65 |
+
} else {
|
66 |
+
$path = $this->getPath();
|
67 |
+
}
|
68 |
+
|
69 |
+
$nodeName = str_replace('/', '_', $path);
|
70 |
+
|
71 |
$templateLabelNode = Mage::app()->getConfig()->getNode(self::XML_PATH_TEMPLATE_EMAIL . $nodeName . '/label');
|
72 |
if ($templateLabelNode) {
|
73 |
$templateName = Mage::helper('adminhtml')->__((string)$templateLabelNode);
|
74 |
$templateName = Mage::helper('adminhtml')->__('%s (Default Template from Locale)', $templateName);
|
75 |
}
|
76 |
+
|
77 |
array_unshift(
|
78 |
+
$options, array(
|
79 |
+
'value' => $nodeName,
|
|
|
80 |
'label' => $templateName
|
81 |
)
|
82 |
);
|
83 |
+
|
84 |
return $options;
|
85 |
}
|
86 |
|
app/code/community/Bronto/Email/Model/System/Config/Source/Sendtype.php
ADDED
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @package Bronto\Customer
|
5 |
+
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
+
* @version 1.1.5
|
7 |
+
*/
|
8 |
+
class Bronto_Email_Model_System_Config_Source_Sendtype
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* @return array
|
12 |
+
*/
|
13 |
+
public function toOptionArray()
|
14 |
+
{
|
15 |
+
return array(
|
16 |
+
array('value' => 'transactional', 'label' => Mage::helper('adminhtml')->__('Transactional')),
|
17 |
+
array('value' => 'marketing', 'label' => Mage::helper('adminhtml')->__('Marketing')),
|
18 |
+
);
|
19 |
+
}
|
20 |
+
}
|
app/code/community/Bronto/Email/Model/Template.php
ADDED
@@ -0,0 +1,212 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
public function _construct()
|
10 |
+
{
|
11 |
+
$this->_init('bronto_email/template');
|
12 |
+
}
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Get Template from original template code and store Id
|
16 |
+
* @param string $templateCode
|
17 |
+
* @param int|bool $storeId
|
18 |
+
* @return array
|
19 |
+
*/
|
20 |
+
public function loadByOriginalCode($templateCode, $storeId = false, $locale = null)
|
21 |
+
{
|
22 |
+
$originalTemplate = $this->getResource()->loadByOriginalCode($templateCode, $storeId);
|
23 |
+
|
24 |
+
if (count($originalTemplate)) {
|
25 |
+
$this->addData($originalTemplate);
|
26 |
+
} else {
|
27 |
+
$this->loadDefault($templateCode, $locale);
|
28 |
+
$this->setOrigTemplateCode($templateCode);
|
29 |
+
}
|
30 |
+
|
31 |
+
return $this;
|
32 |
+
}
|
33 |
+
|
34 |
+
/**
|
35 |
+
* Handle loading Existing and Default Magento templates
|
36 |
+
* @return boolean
|
37 |
+
*/
|
38 |
+
public function handleDefaultTemplates()
|
39 |
+
{
|
40 |
+
/** @var $templateMode Bronto_Email_Model_Template_Import */
|
41 |
+
$templateModel = Mage::getModel('bronto_email/template_import');
|
42 |
+
|
43 |
+
// Process Templates
|
44 |
+
try {
|
45 |
+
$templateModel->handleDefaults();
|
46 |
+
} catch (Exception $e) {
|
47 |
+
Mage::throwException($e->getMessage());
|
48 |
+
}
|
49 |
+
|
50 |
+
return true;
|
51 |
+
}
|
52 |
+
|
53 |
+
/**
|
54 |
+
* Load default email template from locale translate
|
55 |
+
*
|
56 |
+
* @param string $templateId
|
57 |
+
* @param string $locale
|
58 |
+
*/
|
59 |
+
public function loadDefault($templateId, $locale = null)
|
60 |
+
{
|
61 |
+
$defaultTemplates = self::getDefaultTemplates();
|
62 |
+
|
63 |
+
if (!is_string($templateId) || !array_key_exists($templateId, $defaultTemplates)) {
|
64 |
+
return $this;
|
65 |
+
}
|
66 |
+
|
67 |
+
$data = & $defaultTemplates[$templateId];
|
68 |
+
$this->setTemplateType($data['type'] == 'html' ? self::TYPE_HTML : self::TYPE_TEXT);
|
69 |
+
|
70 |
+
$templateText = Mage::app()->getTranslator()->getTemplateFile(
|
71 |
+
$data['file'], 'email', $locale
|
72 |
+
);
|
73 |
+
|
74 |
+
if (preg_match('/<!--@subject\s*(.*?)\s*@-->/', $templateText, $matches)) {
|
75 |
+
$this->setTemplateSubject($matches[1]);
|
76 |
+
$templateText = str_replace($matches[0], '', $templateText);
|
77 |
+
}
|
78 |
+
|
79 |
+
if (preg_match('/<!--@vars\n((?:.)*?)\n@-->/us', $templateText, $matches)) {
|
80 |
+
$this->setData('orig_template_variables', str_replace("\n", '', $matches[1]));
|
81 |
+
$templateText = str_replace($matches[0], '', $templateText);
|
82 |
+
}
|
83 |
+
|
84 |
+
if (preg_match('/<!--@styles\s*(.*?)\s*@-->/sm', $templateText, $matches)) {
|
85 |
+
$this->setTemplateStyles($matches[1]);
|
86 |
+
$templateText = str_replace($matches[0], '', $templateText);
|
87 |
+
}
|
88 |
+
|
89 |
+
/**
|
90 |
+
* Remove comment lines
|
91 |
+
*/
|
92 |
+
$templateText = preg_replace('#\{\*.*\*\}#suU', '', $templateText);
|
93 |
+
|
94 |
+
$this->setTemplateText($templateText);
|
95 |
+
$this->setOrigTemplateText($templateText);
|
96 |
+
$this->setId($templateId);
|
97 |
+
|
98 |
+
return $this;
|
99 |
+
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Collect all system config pathes where current template is used as default
|
103 |
+
*
|
104 |
+
* @return array
|
105 |
+
*/
|
106 |
+
public function getSystemConfigPathsWhereUsedAsDefault()
|
107 |
+
{
|
108 |
+
$templateCode = $this->getOrigTemplateCode();
|
109 |
+
if (!$templateCode) {
|
110 |
+
return array();
|
111 |
+
}
|
112 |
+
|
113 |
+
$templatePaths = Mage::helper($this->_helper)->getTemplatePaths();
|
114 |
+
$paths = array();
|
115 |
+
|
116 |
+
// find nodes which are using $templateCode value
|
117 |
+
$defaultCfgNodes = Mage::getConfig()->getXpath('default/*/*[*="' . $templateCode . '"]');
|
118 |
+
|
119 |
+
if (!is_array($defaultCfgNodes)) {
|
120 |
+
return array();
|
121 |
+
}
|
122 |
+
|
123 |
+
foreach ($defaultCfgNodes as $node) {
|
124 |
+
// create email template path in system.xml
|
125 |
+
$sectionName = $node->getParent()->getName();
|
126 |
+
$groupName = $node->getName();
|
127 |
+
$fieldName = substr($templateCode, strlen($sectionName . '_' . $groupName . '_'));
|
128 |
+
$path = implode('/', array($sectionName, $groupName, $fieldName));
|
129 |
+
|
130 |
+
if (in_array($path, $templatePaths)) {
|
131 |
+
$paths[] = array('path' => $path);
|
132 |
+
}
|
133 |
+
}
|
134 |
+
|
135 |
+
return $paths;
|
136 |
+
}
|
137 |
+
|
138 |
+
/**
|
139 |
+
* Collect all system config pathes where current template is currently used
|
140 |
+
*
|
141 |
+
* @return array
|
142 |
+
*/
|
143 |
+
public function getSystemConfigPathsWhereUsedCurrently()
|
144 |
+
{
|
145 |
+
$templateCode = $this->getTemplateId();
|
146 |
+
if (!$templateCode) {
|
147 |
+
return array();
|
148 |
+
}
|
149 |
+
|
150 |
+
$paths = Mage::helper($this->_helper)->getTemplatePaths();
|
151 |
+
|
152 |
+
$configData = $this->_getResource()->getSystemConfigByPathsAndTemplateId($paths, $templateCode);
|
153 |
+
if (!$configData) {
|
154 |
+
return array();
|
155 |
+
}
|
156 |
+
|
157 |
+
return $configData;
|
158 |
+
}
|
159 |
+
|
160 |
+
/**
|
161 |
+
* Log about the functionality of sending the email before it goes out
|
162 |
+
*
|
163 |
+
* @param Bronto_Api_Contact_Row $contact
|
164 |
+
* @param Bronto_Api_Message_Row $message
|
165 |
+
*
|
166 |
+
* @return void
|
167 |
+
*/
|
168 |
+
protected function _beforeSend(Bronto_Api_Contact_Row $contact, Bronto_Api_Message_Row $message)
|
169 |
+
{
|
170 |
+
Mage::dispatchEvent('bronto_email_send_before');
|
171 |
+
|
172 |
+
if (Mage::helper('bronto_email')->isLogEnabled()) {
|
173 |
+
$this->_log = Mage::getModel('bronto_email/log');
|
174 |
+
$this->_log->setCustomerEmail($contact->email);
|
175 |
+
$this->_log->setContactId($contact->id);
|
176 |
+
$this->_log->setMessageId($message->id);
|
177 |
+
$this->_log->setMessageName($message->name);
|
178 |
+
$this->_log->setSuccess(0);
|
179 |
+
$this->_log->setSentAt(new Zend_Db_Expr('NOW()'));
|
180 |
+
$this->_log->save();
|
181 |
+
}
|
182 |
+
}
|
183 |
+
|
184 |
+
/**
|
185 |
+
* Log data on sending message
|
186 |
+
*
|
187 |
+
* @param bool $success
|
188 |
+
* @param string $error
|
189 |
+
* @param Bronto_Api_Delivery_Row $delivery
|
190 |
+
*
|
191 |
+
* @return void
|
192 |
+
*/
|
193 |
+
protected function _afterSend($success, $error = null, Bronto_Api_Delivery_Row $delivery = null)
|
194 |
+
{
|
195 |
+
Mage::dispatchEvent('bronto_email_send_after');
|
196 |
+
|
197 |
+
if (Mage::helper('bronto_email')->isLogEnabled()) {
|
198 |
+
$this->_log->setSuccess((int)$success);
|
199 |
+
if (!empty($error)) {
|
200 |
+
$this->_log->setError($error);
|
201 |
+
}
|
202 |
+
if ($delivery) {
|
203 |
+
$this->_log->setDeliveryId($delivery->id);
|
204 |
+
if (Mage::helper('bronto_email')->isLogFieldsEnabled()) {
|
205 |
+
$this->_log->setFields(serialize($delivery->getFields()));
|
206 |
+
}
|
207 |
+
}
|
208 |
+
$this->_log->save();
|
209 |
+
$this->_log = null;
|
210 |
+
}
|
211 |
+
}
|
212 |
+
}
|
app/code/community/Bronto/Email/Model/Template/Import.php
CHANGED
@@ -1,155 +1,290 @@
|
|
1 |
<?php
|
2 |
-
|
3 |
/**
|
4 |
* @package Bronto\Email
|
5 |
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
-
* @version 1.1.
|
7 |
*/
|
8 |
-
class Bronto_Email_Model_Template_Import extends
|
9 |
{
|
10 |
/**
|
11 |
-
* @var
|
12 |
*/
|
13 |
-
private $
|
14 |
|
15 |
/**
|
16 |
-
*
|
|
|
|
|
|
|
17 |
*/
|
18 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
|
20 |
/**
|
21 |
-
*
|
|
|
|
|
22 |
*/
|
23 |
-
|
24 |
-
|
25 |
-
public function _construct()
|
26 |
{
|
27 |
-
|
28 |
-
|
29 |
-
|
30 |
-
|
31 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
32 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
34 |
|
35 |
-
|
36 |
}
|
37 |
|
38 |
-
|
|
|
|
|
|
|
39 |
{
|
40 |
-
|
41 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
42 |
}
|
43 |
-
|
|
|
44 |
}
|
45 |
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
47 |
{
|
48 |
-
$
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
'api' => new Bronto_Api($token)
|
55 |
-
));
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
$template->setStoreId(1);
|
61 |
-
$this->processMessage($template);
|
62 |
-
}
|
63 |
-
}
|
64 |
-
|
65 |
-
//process defaults
|
66 |
-
foreach (array_keys($allStores) as $_eachStoreId)
|
67 |
-
{
|
68 |
-
$_storeCode = Mage::app()->getStore($_eachStoreId)->getCode();
|
69 |
-
$_storeId = Mage::app()->getStore($_eachStoreId)->getId();
|
70 |
-
|
71 |
-
$token = Mage::helper('bronto_common')->getApiToken($_storeId);
|
72 |
-
if($token) {
|
73 |
-
$this->_apiObject = new Bronto_Api_Message(array(
|
74 |
-
'api' => new Bronto_Api($token)
|
75 |
-
));
|
76 |
-
|
77 |
-
//process default
|
78 |
-
$templates = Mage::getModel('bronto_common/email_message')->getDefaultTemplates();
|
79 |
-
foreach(array_keys($templates) as $templateToLoad) {
|
80 |
-
$template = Mage::getModel('bronto_common/email_message');
|
81 |
-
$template->loadDefault($templateToLoad);
|
82 |
-
$template->setOrigTemplateCode($templateToLoad);
|
83 |
-
$template->setTemplateCode($_storeCode . '_' . $templateToLoad);
|
84 |
-
$template->setAddedAt(Mage::getModel('core/date')->date('Y-m-d H:i:s'));
|
85 |
-
//$template->unsTemplateId();
|
86 |
-
$template->setStoreId($_storeId);
|
87 |
-
$this->processMessage($template);
|
88 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
89 |
}
|
90 |
}
|
91 |
|
92 |
-
return
|
93 |
}
|
94 |
|
95 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
96 |
{
|
97 |
-
$
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
105 |
-
|
106 |
-
|
107 |
-
|
108 |
-
|
109 |
-
|
110 |
-
$
|
111 |
-
|
112 |
-
//
|
113 |
-
$
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
// Template has invalid or missing required attributes
|
118 |
-
if ('' == $templateSubject || '' == $templateText || '' == $templateTextRip) {
|
119 |
-
return;
|
120 |
}
|
121 |
-
|
122 |
-
|
123 |
-
|
124 |
-
|
125 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
'type' => 'text',
|
130 |
-
'subject' => $templateSubject,
|
131 |
-
'content' => $templateTextRip,
|
132 |
-
)
|
133 |
-
);
|
134 |
-
$message->subject = $templateSubject;
|
135 |
-
$message->save();
|
136 |
-
$template->setBrontoMessageId($message->id);
|
137 |
-
$template->setBrontoMessageName($message->name);
|
138 |
-
$template->setBrontoMessageApproved(0);
|
139 |
$template->save();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
140 |
}
|
141 |
}
|
142 |
-
catch(Exception $e) {
|
143 |
-
Mage::log('Bronto Import:' . $e->getMessage());
|
144 |
-
}
|
145 |
}
|
|
|
|
|
146 |
}
|
147 |
|
|
|
|
|
|
|
|
|
|
|
148 |
protected function ripTags($string)
|
149 |
{
|
150 |
-
$string = preg_replace
|
151 |
// ----- remove multiple spaces -----
|
152 |
$string = trim(preg_replace('/ {2,}/', ' ', $string));
|
153 |
return $string;
|
154 |
}
|
|
|
155 |
}
|
1 |
<?php
|
|
|
2 |
/**
|
3 |
* @package Bronto\Email
|
4 |
* @copyright 2011-2013 Bronto Software, Inc.
|
5 |
+
* @version 1.1.6
|
6 |
*/
|
7 |
+
class Bronto_Email_Model_Template_Import extends Bronto_Email_Model_Template
|
8 |
{
|
9 |
/**
|
10 |
+
* @var Bronto_Api_Object
|
11 |
*/
|
12 |
+
private $_apiObject;
|
13 |
|
14 |
/**
|
15 |
+
* Load Template to import into Bronto
|
16 |
+
* @param int $templateId
|
17 |
+
* @param string|int $storeId
|
18 |
+
* @throws Exception
|
19 |
*/
|
20 |
+
public function importTemplate($templateId, $storeId = false)
|
21 |
+
{
|
22 |
+
/** @var $template Bronto_Email_Model_Template_Import */
|
23 |
+
$template = $this->load($templateId);
|
24 |
+
|
25 |
+
try {
|
26 |
+
return $this->processMessage($template, $storeId);
|
27 |
+
} catch (Exception $e) {
|
28 |
+
throw new Exception($e->getMessage());
|
29 |
+
}
|
30 |
+
}
|
31 |
|
32 |
/**
|
33 |
+
* Import template into Bronto
|
34 |
+
* @param Bronto_Email_Model_Template $template
|
35 |
+
* @return type
|
36 |
*/
|
37 |
+
protected function processMessage(Bronto_Email_Model_Template $template, $storeId = false)
|
|
|
|
|
38 |
{
|
39 |
+
$data = $template->getData();
|
40 |
+
$emt = Mage::getModel('bronto_common/email_template_templatefilter');
|
41 |
+
|
42 |
+
// Get Store
|
43 |
+
if ($storeId) {
|
44 |
+
$store = Mage::app()->getStore($storeId);
|
45 |
+
} elseif (isset($data['store_id'])) {
|
46 |
+
$store = Mage::app()->getStore($data['store_id']);
|
47 |
+
} else {
|
48 |
+
$store = Mage::app()->getDefaultStoreView();
|
49 |
+
}
|
50 |
+
|
51 |
+
// If module is not enabled for this store, don't proceed
|
52 |
+
if (!Mage::helper('bronto_email')->isEnabled($store->getId())) {
|
53 |
+
return false;
|
54 |
+
}
|
55 |
+
|
56 |
+
// Get Token
|
57 |
+
$token = Mage::helper('bronto_common')->getApiToken($store->getId());
|
58 |
+
if ($token) {
|
59 |
+
$this->_apiObject = new Bronto_Api_Message(array(
|
60 |
+
'api' => new Bronto_Api($token)
|
61 |
+
));
|
62 |
+
} else {
|
63 |
+
return false;
|
64 |
+
}
|
65 |
+
|
66 |
+
// Send message template to Bronto
|
67 |
+
try {
|
68 |
+
$message = new Bronto_Api_Message_Row(array(
|
69 |
+
'apiObject' => $this->_apiObject
|
70 |
+
));
|
71 |
+
} catch (Exception $e) {
|
72 |
+
Mage::log('Bronto Failed creating apiObject:' . $e->getMessage());
|
73 |
+
return false;
|
74 |
+
}
|
75 |
+
|
76 |
+
// Add Check for required fields
|
77 |
+
if (array_key_exists('template_text', $data) && array_key_exists('template_subject', $data)) {
|
78 |
+
$message->name = $data['template_code'];
|
79 |
+
$message->status = 'active';
|
80 |
+
|
81 |
+
// Define variables for filtered Subject and Text
|
82 |
+
$templateSubject = $emt->filter($data['template_subject']);
|
83 |
+
$templateText = $emt->filter($data['template_text']);
|
84 |
+
$templateTextRip = $emt->filter($this->ripTags($data['template_text']));
|
85 |
+
|
86 |
+
// If message missing subject, use template code
|
87 |
+
if ('' == $templateSubject) {
|
88 |
+
$templateSubject = $data['template_code'];
|
89 |
+
$template->setTemplateSubject($data['template_code']);
|
90 |
}
|
91 |
+
|
92 |
+
try {
|
93 |
+
// Template has invalid or missing required attributes
|
94 |
+
if ('' == $templateText || '' == $templateTextRip) {
|
95 |
+
Mage::throwException('Template is missing body');
|
96 |
+
}
|
97 |
+
|
98 |
+
$message->content = array(
|
99 |
+
array(
|
100 |
+
'type' => 'html',
|
101 |
+
'subject' => $templateSubject,
|
102 |
+
'content' => $templateText,
|
103 |
+
),
|
104 |
+
array(
|
105 |
+
'type' => 'text',
|
106 |
+
'subject' => $templateSubject,
|
107 |
+
'content' => $templateTextRip,
|
108 |
+
)
|
109 |
+
);
|
110 |
+
$message->subject = $templateSubject;
|
111 |
+
$message->save();
|
112 |
+
|
113 |
+
if ($message->hasError()) {
|
114 |
+
Mage::throwException($message->getErrorCode() . ' ' . $message->getErrorMessage());
|
115 |
+
return false;
|
116 |
+
}
|
117 |
+
} catch (Exception $e) {
|
118 |
+
Mage::throwException("Failed Importing Template `{$data['template_code']}` : [Bronto] " . $e->getMessage());
|
119 |
+
return false;
|
120 |
+
}
|
121 |
+
|
122 |
+
// Create Bronto Template Entry
|
123 |
+
$brontoTemplate = Mage::getModel('bronto_email/message')
|
124 |
+
->load($template->getId())
|
125 |
+
->setCoreTemplateId($template->getId())
|
126 |
+
->setOrigTemplateText($templateText)
|
127 |
+
->setBrontoMessageId($message->id)
|
128 |
+
->setBrontoMessageName($message->name)
|
129 |
+
->setBrontoMessageApproved(1)
|
130 |
+
->setStoreId($store->getId())
|
131 |
+
->save();
|
132 |
+
|
133 |
+
// Clean Up
|
134 |
+
unset($brontoTemplate);
|
135 |
}
|
136 |
|
137 |
+
return true;
|
138 |
}
|
139 |
|
140 |
+
/**
|
141 |
+
* Collect all existing and default templates from magento and add to new table
|
142 |
+
*/
|
143 |
+
public function handleDefaults()
|
144 |
{
|
145 |
+
// process existing
|
146 |
+
try {
|
147 |
+
$this->_processExisting();
|
148 |
+
} catch (Exception $e) {
|
149 |
+
Mage::throwException($this->__('Failed loading existing templates'));
|
150 |
+
}
|
151 |
+
|
152 |
+
// process defaults
|
153 |
+
try {
|
154 |
+
$allStores = Mage::app()->getStores();
|
155 |
+
$this->_processDefaults($allStores);
|
156 |
+
} catch (Exception $e) {
|
157 |
+
Mage::throwException($this->__('Failed loading default templates'));
|
158 |
}
|
159 |
+
|
160 |
+
return true;
|
161 |
}
|
162 |
|
163 |
+
/**
|
164 |
+
* Load Existing templates into Bronto Email Template table
|
165 |
+
* @param Bronto_Email_Model_Template $messageModel
|
166 |
+
* @return boolean
|
167 |
+
*/
|
168 |
+
protected function _processExisting()
|
169 |
{
|
170 |
+
$customTemplates = $this->getCollection();
|
171 |
+
foreach ($customTemplates as $customTemplate) {
|
172 |
+
try {
|
173 |
+
/** @var $template Bronto_Email_Model_Message */
|
174 |
+
$template = Mage::getModel('bronto_email/message')
|
175 |
+
->load($customTemplate->getId());
|
|
|
|
|
176 |
|
177 |
+
// If we didn't get a template match, set the Id
|
178 |
+
if (is_null($template->getId())) {
|
179 |
+
$template->setId($customTemplate->getId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
180 |
}
|
181 |
+
|
182 |
+
// If message does not already exist, then proceed
|
183 |
+
if (!$template->getBrontoMessageId() || is_null($template->getBrontoMessageId())) {
|
184 |
+
$template->setTemplateSendType('magento')
|
185 |
+
->setOrigTemplateText($customTemplate->getTemplateText())
|
186 |
+
->setBrontoMessageId(null)
|
187 |
+
->setBrontoMessageName(null)
|
188 |
+
->setBrontoMessageApproved(0)
|
189 |
+
->save();
|
190 |
+
}
|
191 |
+
|
192 |
+
// Clean up
|
193 |
+
unset($template);
|
194 |
+
} catch (Exception $e) {
|
195 |
+
Mage::helper('bronto_email')->writeDebug('Bronto Import Existing Templates:' . $e->getMessage());
|
196 |
}
|
197 |
}
|
198 |
|
199 |
+
return true;
|
200 |
}
|
201 |
|
202 |
+
/**
|
203 |
+
* Load Default templates into Bronto Email Template table
|
204 |
+
* @param Bronto_Email_Model_Template $messageModel
|
205 |
+
* @param array $allStores
|
206 |
+
* @return boolean
|
207 |
+
*/
|
208 |
+
protected function _processDefaults(array $allStores)
|
209 |
{
|
210 |
+
foreach ($allStores as $_eachStoreId) {
|
211 |
+
$_store = Mage::app()->getStore($_eachStoreId);
|
212 |
+
$_storeCode = $_store->getCode();
|
213 |
+
$_storeId = $_store->getId();
|
214 |
+
$_locale = $_store->getConfig('general/locale/code');
|
215 |
+
|
216 |
+
//process default
|
217 |
+
$templates = $this->getDefaultTemplates();
|
218 |
+
foreach (array_keys($templates) as $templateToLoad) {
|
219 |
+
try {
|
220 |
+
/** @var $template Bronto_Email_Model_Template */
|
221 |
+
$template = Mage::getModel('bronto_email/template');
|
222 |
+
|
223 |
+
$template->loadByOriginalCode($templateToLoad, $_storeId, $_locale);
|
224 |
+
|
225 |
+
// Ensure Defaults use pretty label
|
226 |
+
$label = $templates[$templateToLoad]['label'] . ' (' . $_storeCode . ')';
|
227 |
+
if ('en_US' != $_locale) {
|
228 |
+
$label .= ' [' . $_locale . ']';
|
|
|
|
|
|
|
|
|
229 |
}
|
230 |
+
|
231 |
+
// Create Core Template
|
232 |
+
$template->setTemplateCode($label);
|
233 |
+
$templateText = trim($template->getTemplateText());
|
234 |
+
$template->setTemplateText($templateText);
|
235 |
+
$template->setAddedAt(Mage::getModel('core/date')->date('Y-m-d H:i:s'));
|
236 |
+
$template->unsTemplateId(); // template ID may be template code, so unset it
|
237 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
238 |
$template->save();
|
239 |
+
|
240 |
+
// Get Template ID from Core Template
|
241 |
+
$templateId = $template->getId();
|
242 |
+
|
243 |
+
// Build Bronto Template
|
244 |
+
/** @var $brontoTemplate Bronto_Email_Model_Message */
|
245 |
+
$brontoTemplate = Mage::getModel('bronto_email/message')
|
246 |
+
->load($templateId);
|
247 |
+
|
248 |
+
// If we didn't get a template match, set the Id
|
249 |
+
if (is_null($brontoTemplate->getId())) {
|
250 |
+
$brontoTemplate->setId($templateId);
|
251 |
+
}
|
252 |
+
|
253 |
+
// If message does not already exist, then proceed
|
254 |
+
if (!$brontoTemplate->getBrontoMessageId() || is_null($brontoTemplate->getBrontoMessageId())) {
|
255 |
+
$brontoTemplate->setTemplateSendType('magento')
|
256 |
+
->setOrigTemplateText($templateText)
|
257 |
+
->setBrontoMessageId(null)
|
258 |
+
->setBrontoMessageName(null)
|
259 |
+
->setBrontoMessageApproved(0)
|
260 |
+
->setStoreId($_storeId)
|
261 |
+
->save();
|
262 |
+
}
|
263 |
+
|
264 |
+
// Clean up
|
265 |
+
unset($template);
|
266 |
+
unset($brontoTemplate);
|
267 |
+
} catch (Exception $e) {
|
268 |
+
|
269 |
+
Mage::helper('bronto_email')->writeDebug('Bronto Import Default Templates:' . $e->getMessage());
|
270 |
}
|
271 |
}
|
|
|
|
|
|
|
272 |
}
|
273 |
+
|
274 |
+
return true;
|
275 |
}
|
276 |
|
277 |
+
/**
|
278 |
+
* Remove HTML and multiple spaces
|
279 |
+
* @param string $string
|
280 |
+
* @return string
|
281 |
+
*/
|
282 |
protected function ripTags($string)
|
283 |
{
|
284 |
+
$string = preg_replace('/<[^>]*>/', ' ', $string);
|
285 |
// ----- remove multiple spaces -----
|
286 |
$string = trim(preg_replace('/ {2,}/', ' ', $string));
|
287 |
return $string;
|
288 |
}
|
289 |
+
|
290 |
}
|
app/code/community/Bronto/Email/Model/Template/Mailer.php
ADDED
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* @package Bronto\Email
|
4 |
+
* @copyright 2011-2013 Bronto Software, Inc.
|
5 |
+
* @version 1.1.6
|
6 |
+
*/
|
7 |
+
class Bronto_Email_Model_Template_Mailer
|
8 |
+
extends Mage_Core_Model_Email_Template_Mailer
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Send all emails from email list
|
12 |
+
* @see self::$_emailInfos
|
13 |
+
*
|
14 |
+
* @return Bronto_Email_Model_Template_Mailer
|
15 |
+
*/
|
16 |
+
public function send()
|
17 |
+
{
|
18 |
+
// Try loading template
|
19 |
+
$emailTemplate = Mage::getModel('bronto_email/template');
|
20 |
+
$emailTemplate->load($this->getTemplateId());
|
21 |
+
|
22 |
+
// If sending through bronto is not enabled, push through parent
|
23 |
+
if (!Mage::helper('bronto_email')->canSendBronto($emailTemplate)) {
|
24 |
+
return parent::send();
|
25 |
+
}
|
26 |
+
|
27 |
+
// Load Bronto Message
|
28 |
+
$store = Mage::getModel('core/store')->load($this->getStoreId());
|
29 |
+
|
30 |
+
// Load Bronto Message
|
31 |
+
/* @var $messageObject Bronto_Api_Message */
|
32 |
+
$messageObject = Mage::helper('bronto_email/message')->getApi(
|
33 |
+
NULL,
|
34 |
+
$store->getId(),
|
35 |
+
$store->getWebsiteId()
|
36 |
+
)->getMessageObject();
|
37 |
+
|
38 |
+
// Load Message
|
39 |
+
try {
|
40 |
+
/* @var $message Bronto_Api_Message_Row */
|
41 |
+
$message = $messageObject->createRow();
|
42 |
+
$message->id = $emailTemplate->getBrontoMessageId();
|
43 |
+
$message->read();
|
44 |
+
}
|
45 |
+
catch (Exception $e) {
|
46 |
+
Mage::helper('bronto_email')->writeDebug('Falling Back to Magento Sending: ' . $e);
|
47 |
+
|
48 |
+
return parent::send();
|
49 |
+
}
|
50 |
+
|
51 |
+
// Send all emails from corresponding list
|
52 |
+
while (!empty($this->_emailInfos)) {
|
53 |
+
$emailInfo = array_pop($this->_emailInfos);
|
54 |
+
|
55 |
+
// Handle "Bcc" recepients of the current email
|
56 |
+
if ($emailTemplate->getTemplateSendType() == 'magento') {
|
57 |
+
$emailTemplate->addBcc($emailInfo->getBccEmails());
|
58 |
+
}
|
59 |
+
else {
|
60 |
+
foreach ($emailInfo->getBccEmails() as $bcc) {
|
61 |
+
$emailInfo->addTo($bcc);
|
62 |
+
}
|
63 |
+
}
|
64 |
+
|
65 |
+
// Set required design parameters and delegate email sending to Mage_Core_Model_Email_Template
|
66 |
+
$emailTemplate->setDesignConfig(array('area' => 'frontend', 'store' => $this->getStoreId()))
|
67 |
+
->sendTransactional(
|
68 |
+
$message,
|
69 |
+
$this->getSender(),
|
70 |
+
$emailInfo->getToEmails(),
|
71 |
+
$emailInfo->getToNames(),
|
72 |
+
$this->getTemplateParams(),
|
73 |
+
$this->getStoreId()
|
74 |
+
);
|
75 |
+
}
|
76 |
+
|
77 |
+
return $this;
|
78 |
+
}
|
79 |
+
}
|
app/code/community/Bronto/Email/Test/Config/Config.php
DELETED
@@ -1,216 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Bronto_Email_Test_Config_Config
|
3 |
-
extends EcomDev_PHPUnit_Test_Case_Config
|
4 |
-
{
|
5 |
-
public function blocksProvider()
|
6 |
-
{
|
7 |
-
return array(
|
8 |
-
array('bronto_email/adminhtml_system_config_about', 'Bronto_Email_Block_Adminhtml_System_Config_About'),
|
9 |
-
array('bronto_email/adminhtml_system_email_log', 'Bronto_Email_Block_Adminhtml_System_Email_Log'),
|
10 |
-
array('bronto_email/adminhtml_system_email_log_grid', 'Bronto_Email_Block_Adminhtml_System_Email_Log_Grid'),
|
11 |
-
array('bronto_email/adminhtml_system_email_log_grid_renderer_customer', 'Bronto_Email_Block_Adminhtml_System_Email_Log_Grid_Renderer_Customer'),
|
12 |
-
array('bronto_email/adminhtml_system_email_log_grid_renderer_fields', 'Bronto_Email_Block_Adminhtml_System_Email_Log_Grid_Renderer_Fields'),
|
13 |
-
array('bronto_email/adminhtml_system_email_template', 'Bronto_Email_Block_Adminhtml_System_Email_Template'),
|
14 |
-
array('bronto_email/adminhtml_system_email_template_edit', 'Bronto_Email_Block_Adminhtml_System_Email_Template_Edit'),
|
15 |
-
array('bronto_email/adminhtml_system_email_template_edit_form', 'Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form'),
|
16 |
-
array('bronto_email/adminhtml_system_email_template_grid', 'Bronto_Email_Block_Adminhtml_System_Email_Template_Grid'),
|
17 |
-
array('bronto_email/adminhtml_system_email_template_grid_renderer_message', 'Bronto_Email_Block_Adminhtml_System_Email_Template_Grid_Renderer_Message'),
|
18 |
-
);
|
19 |
-
}
|
20 |
-
|
21 |
-
public function resourceModelProvider()
|
22 |
-
{
|
23 |
-
return array(
|
24 |
-
array('bronto_email_mysql4/log', 'Bronto_Email_Model_Mysql4_Log'),
|
25 |
-
array('bronto_email_mysql4/log_collection', 'Bronto_Email_Model_Mysql4_Log_Collection'),
|
26 |
-
);
|
27 |
-
}
|
28 |
-
|
29 |
-
public function modelsProvider()
|
30 |
-
{
|
31 |
-
return array(
|
32 |
-
array('bronto_email/log', 'Bronto_Email_Model_Log'),
|
33 |
-
array('bronto_email/email_message', 'Bronto_Email_Model_Email_Message'),
|
34 |
-
array('bronto_email/template_import', 'Bronto_Email_Model_Template_Import'),
|
35 |
-
array('bronto_email/observer', 'Bronto_Email_Model_Observer'),
|
36 |
-
);
|
37 |
-
}
|
38 |
-
|
39 |
-
public function helpersProvider()
|
40 |
-
{
|
41 |
-
return array(
|
42 |
-
array('bronto_email/data', 'Bronto_Email_Helper_Data'),
|
43 |
-
array('bronto_email/email', 'Bronto_Email_Helper_Email'),
|
44 |
-
array('bronto_email/field', 'Bronto_Email_Helper_Field'),
|
45 |
-
array('bronto_email/message', 'Bronto_Email_Helper_Message'),
|
46 |
-
array('bronto_email/contact', 'Bronto_Email_Helper_Contact'),
|
47 |
-
);
|
48 |
-
}
|
49 |
-
|
50 |
-
public function observersProvider()
|
51 |
-
{
|
52 |
-
return array(
|
53 |
-
array('adminhtml', 'controller_action_predispatch', 'bronto_email/observer', 'checkBrontoRequirements')
|
54 |
-
);
|
55 |
-
}
|
56 |
-
|
57 |
-
public function definedLayoutFilesProvider()
|
58 |
-
{
|
59 |
-
return array(
|
60 |
-
array('adminhtml', 'bronto/email.xml'),
|
61 |
-
);
|
62 |
-
}
|
63 |
-
|
64 |
-
public function themeLayoutFilesExistProvider()
|
65 |
-
{
|
66 |
-
return array(
|
67 |
-
array('adminhtml', 'bronto/email.xml', 'default', 'default'),
|
68 |
-
);
|
69 |
-
}
|
70 |
-
|
71 |
-
public function dependsProvider()
|
72 |
-
{
|
73 |
-
return array(
|
74 |
-
array('Bronto_Common'),
|
75 |
-
);
|
76 |
-
}
|
77 |
-
|
78 |
-
/**
|
79 |
-
* @test
|
80 |
-
* @group amd
|
81 |
-
* @group config
|
82 |
-
*/
|
83 |
-
public function assertEmailModuleVersionGreaterThanOrEquals()
|
84 |
-
{
|
85 |
-
$this->assertModuleVersionGreaterThanOrEquals('1.1.1');
|
86 |
-
}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* @test
|
90 |
-
* @group amd
|
91 |
-
* @group config
|
92 |
-
*/
|
93 |
-
public function assertEmailModuleInCommunityCodePool()
|
94 |
-
{
|
95 |
-
$this->assertModuleCodePool('community');
|
96 |
-
}
|
97 |
-
|
98 |
-
/**
|
99 |
-
* @test
|
100 |
-
* @group amd
|
101 |
-
* @group config
|
102 |
-
* @dataProvider dependsProvider
|
103 |
-
*/
|
104 |
-
public function assertEmailModuleDepends(
|
105 |
-
$requiredModuleName
|
106 |
-
) {
|
107 |
-
$this->assertModuleDepends($requiredModuleName);
|
108 |
-
}
|
109 |
-
|
110 |
-
/**
|
111 |
-
* @test
|
112 |
-
* @group amd
|
113 |
-
* @group config
|
114 |
-
* @dataProvider modelsProvider
|
115 |
-
*/
|
116 |
-
public function assertEmailModelAliases(
|
117 |
-
$classAlias,
|
118 |
-
$expectedClassName
|
119 |
-
) {
|
120 |
-
$this->assertModelAlias($classAlias, $expectedClassName);
|
121 |
-
}
|
122 |
-
|
123 |
-
/**
|
124 |
-
* @test
|
125 |
-
* @group amd
|
126 |
-
* @group config
|
127 |
-
* @dataProvider resourceModelProvider
|
128 |
-
*/
|
129 |
-
public function assertEmailResourceModelAliases(
|
130 |
-
$classAlias,
|
131 |
-
$expectedClassName
|
132 |
-
) {
|
133 |
-
$this->assertResourceModelAlias($classAlias, $expectedClassName);
|
134 |
-
}
|
135 |
-
|
136 |
-
|
137 |
-
/**
|
138 |
-
* @test
|
139 |
-
* @group amd
|
140 |
-
* @group config
|
141 |
-
* @dataProvider blocksProvider
|
142 |
-
*/
|
143 |
-
public function assertEmailBlockAliases(
|
144 |
-
$classAlias,
|
145 |
-
$expectedClassName
|
146 |
-
) {
|
147 |
-
$this->assertBlockAlias($classAlias, $expectedClassName);
|
148 |
-
}
|
149 |
-
|
150 |
-
/**
|
151 |
-
* @test
|
152 |
-
* @group amd
|
153 |
-
* @group config
|
154 |
-
* @dataProvider helpersProvider
|
155 |
-
*/
|
156 |
-
public function assertEmailHelperAliases(
|
157 |
-
$classAlias,
|
158 |
-
$expectedClassName
|
159 |
-
) {
|
160 |
-
$this->assertHelperAlias($classAlias, $expectedClassName);
|
161 |
-
}
|
162 |
-
|
163 |
-
/**
|
164 |
-
* @test
|
165 |
-
* @group amd
|
166 |
-
* @group config
|
167 |
-
* @dataProvider observersProvider
|
168 |
-
*/
|
169 |
-
function assertEmailEventObserverDefined (
|
170 |
-
$area,
|
171 |
-
$eventName,
|
172 |
-
$observerClassAlias,
|
173 |
-
$observerMethod
|
174 |
-
) {
|
175 |
-
$this->assertEventObserverDefined(
|
176 |
-
$area,
|
177 |
-
$eventName,
|
178 |
-
$observerClassAlias,
|
179 |
-
$observerMethod
|
180 |
-
);
|
181 |
-
}
|
182 |
-
|
183 |
-
/**
|
184 |
-
* @test
|
185 |
-
* @group amd
|
186 |
-
* @group config
|
187 |
-
* @dataProvider definedLayoutFilesProvider
|
188 |
-
*/
|
189 |
-
public function assertEmailLayoutFileDefined (
|
190 |
-
$area,
|
191 |
-
$expectedFileName
|
192 |
-
) {
|
193 |
-
$this->assertLayoutFileDefined($area, $expectedFileName);
|
194 |
-
}
|
195 |
-
|
196 |
-
/**
|
197 |
-
* @test
|
198 |
-
* @group amd
|
199 |
-
* @group config
|
200 |
-
* @dataProvider themeLayoutFilesExistProvider
|
201 |
-
*/
|
202 |
-
public function assertEmailLayoutFileExistsInTheme (
|
203 |
-
$area,
|
204 |
-
$filename,
|
205 |
-
$theme,
|
206 |
-
$designPackage
|
207 |
-
) {
|
208 |
-
$this->assertLayoutFileExistsInTheme(
|
209 |
-
$area,
|
210 |
-
$filename,
|
211 |
-
$theme,
|
212 |
-
$designPackage
|
213 |
-
);
|
214 |
-
}
|
215 |
-
|
216 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/Email/Test/Model/Email/Message.php
DELETED
@@ -1,37 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
class Bronto_Email_Test_Model_Email_Message
|
4 |
-
extends Bronto_Common_Test_Model_Checkout
|
5 |
-
{
|
6 |
-
/**
|
7 |
-
* @test
|
8 |
-
*/
|
9 |
-
public function testOrderEmailSent()
|
10 |
-
{
|
11 |
-
$this->markTestIncomplete('need to mock/replace sessions before this will work.');
|
12 |
-
$mockOrder = $this->getModelMock('sales/order', array('sendNewOrderEmail'));
|
13 |
-
$mockOrder->expects($this->any())
|
14 |
-
->method('sendNewOrderEmail')
|
15 |
-
->will($this->returnCallback(array($this, '')));
|
16 |
-
$this->replaceByMock('model', 'sales/order', $mockOrder);
|
17 |
-
|
18 |
-
$order = $this->createRandomGuestOrder();
|
19 |
-
|
20 |
-
$this->assertEventDispatchedExactly('bronto_email_send_before', 1);
|
21 |
-
$this->assertEventDispatchedExactly('bronto_email_send_after', 1);
|
22 |
-
|
23 |
-
return $order;
|
24 |
-
}
|
25 |
-
|
26 |
-
/**
|
27 |
-
* @test
|
28 |
-
* @depends testOrderEmailSent
|
29 |
-
*/
|
30 |
-
public function testShipmentEmailSent(Mage_Sales_Model_Order $order)
|
31 |
-
{
|
32 |
-
$this->createShipmentForOrder($order);
|
33 |
-
|
34 |
-
$this->assertEventDispatchedExactly('bronto_email_send_before', 1);
|
35 |
-
$this->assertEventDispatchedExactly('bronto_email_send_after', 1);
|
36 |
-
}
|
37 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/Email/controllers/Adminhtml/System/Email/LogController.php
CHANGED
@@ -11,11 +11,11 @@ class Bronto_Email_Adminhtml_System_Email_LogController extends Mage_Adminhtml_C
|
|
11 |
{
|
12 |
$this->_title($this->__('Bronto Deliveries'))->_title($this->__('Logs'));
|
13 |
$this->loadLayout()
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
return $this;
|
20 |
}
|
21 |
|
11 |
{
|
12 |
$this->_title($this->__('Bronto Deliveries'))->_title($this->__('Logs'));
|
13 |
$this->loadLayout()
|
14 |
+
->_setActiveMenu('system/email/log')
|
15 |
+
->_addBreadcrumb(
|
16 |
+
Mage::helper('bronto_email')->__('Bronto Delivery Log'),
|
17 |
+
Mage::helper('bronto_email')->__('Bronto Delivery Log')
|
18 |
+
);
|
19 |
return $this;
|
20 |
}
|
21 |
|
app/code/community/Bronto/Email/controllers/Adminhtml/System/Email/TemplateController.php
CHANGED
@@ -8,20 +8,176 @@ require_once 'Mage/Adminhtml/controllers/System/Email/TemplateController.php';
|
|
8 |
/**
|
9 |
* @package Bronto\Email
|
10 |
* @copyright 2011-2013 Bronto Software, Inc.
|
11 |
-
* @version 1.1.
|
12 |
*/
|
13 |
class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminhtml_System_Email_TemplateController
|
14 |
{
|
15 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
{
|
17 |
-
if (!Mage::helper('bronto_email')->
|
18 |
-
return parent::
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
}
|
20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
21 |
$request = $this->getRequest();
|
22 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
23 |
|
|
|
|
|
24 |
$template = $this->_initTemplate('id');
|
|
|
25 |
if (!$template->getId() && $id) {
|
26 |
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('This Email template no longer exists.'));
|
27 |
$this->_redirect('*/*/');
|
@@ -29,38 +185,146 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
|
|
29 |
}
|
30 |
|
31 |
try {
|
32 |
-
|
33 |
-
|
34 |
-
$messages = Mage::helper('bronto_common/message')->getAllMessageOptions();
|
35 |
-
foreach ($messages as $message) {
|
36 |
-
if ($message['value'] == $request->getParam('bronto_message_id')) {
|
37 |
-
$messageName = $message['label'];
|
38 |
-
break;
|
39 |
-
}
|
40 |
-
}
|
41 |
-
|
42 |
$template->setTemplateCode($request->getParam('template_code'))
|
43 |
-
->setBrontoMessageId($request->getParam('bronto_message_id'))
|
44 |
-
->setBrontoMessageName(isset($messageName) ? $messageName : 'Unknown')
|
45 |
->setModifiedAt(Mage::getSingleton('core/date')->gmtDate())
|
|
|
|
|
|
|
46 |
->setOrigTemplateCode($request->getParam('orig_template_code'))
|
47 |
-
->setOrigTemplateVariables($request->getParam('orig_template_variables'))
|
|
|
|
|
|
|
|
|
48 |
->setStoreId($request->getParam('store_id'));
|
49 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
50 |
if (!$template->getId() || !$template->getAddedAt()) {
|
51 |
$template->setAddedAt(Mage::getSingleton('core/date')->gmtDate());
|
52 |
}
|
53 |
|
|
|
54 |
$template->save();
|
|
|
|
|
|
|
|
|
|
|
55 |
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
56 |
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('The email template has been saved.'));
|
57 |
$this->_redirect('*/*');
|
58 |
-
|
59 |
} catch (Exception $e) {
|
60 |
Mage::getSingleton('adminhtml/session')->setData('email_template_form_data', $this->getRequest()->getParams());
|
61 |
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
62 |
-
$this->_forward('
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
63 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
64 |
}
|
65 |
|
66 |
/**
|
@@ -68,7 +332,7 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
|
|
68 |
*/
|
69 |
public function defaultTemplateAction()
|
70 |
{
|
71 |
-
if (!Mage::helper('bronto_email')->
|
72 |
return parent::defaultTemplateAction();
|
73 |
}
|
74 |
|
@@ -82,36 +346,185 @@ class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminh
|
|
82 |
$templateBlock = $this->getLayout()->createBlock('adminhtml/system_email_template_edit');
|
83 |
$template->setData('orig_template_used_default_for', $templateBlock->getUsedDefaultForPaths(false));
|
84 |
|
85 |
-
// Edit: Remove unneeded variables
|
86 |
-
$template->unsetData('template_styles');
|
87 |
-
$template->unsetData('template_text');
|
88 |
-
$template->unsetData('template_type');
|
89 |
-
$template->unsetData('template_subject');
|
90 |
-
// End
|
91 |
-
|
92 |
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($template->getData()));
|
93 |
}
|
94 |
|
95 |
-
|
|
|
|
|
|
|
96 |
{
|
97 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
98 |
$importModel = Mage::getModel('bronto_email/template_import');
|
99 |
-
$
|
100 |
-
|
101 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
102 |
|
|
|
|
|
|
|
103 |
} catch (Exception $e) {
|
104 |
-
Mage::
|
105 |
-
$this->_redirect('*/*');
|
106 |
}
|
|
|
|
|
107 |
}
|
108 |
|
109 |
-
|
|
|
|
|
|
|
110 |
{
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
116 |
}
|
|
|
117 |
}
|
8 |
/**
|
9 |
* @package Bronto\Email
|
10 |
* @copyright 2011-2013 Bronto Software, Inc.
|
11 |
+
* @version 1.1.4
|
12 |
*/
|
13 |
class Bronto_Email_Adminhtml_System_Email_TemplateController extends Mage_Adminhtml_System_Email_TemplateController
|
14 |
{
|
15 |
+
|
16 |
+
protected $_returnableActions = array('save', 'delete');
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Main Grid view for Transactional Email Templates
|
20 |
+
* Overwritten to show Bronto Templates
|
21 |
+
* @return null
|
22 |
+
*/
|
23 |
+
public function indexAction()
|
24 |
{
|
25 |
+
if (!Mage::helper('bronto_email')->isEnabledForAny()) {
|
26 |
+
return parent::indexAction();
|
27 |
+
}
|
28 |
+
|
29 |
+
$this->_title($this->__('System'))->_title($this->__('Transactional Emails'));
|
30 |
+
Mage::getSingleton('adminhtml/session')->setPostRedirect('*/*/');
|
31 |
+
|
32 |
+
if ($this->getRequest()->getQuery('ajax')) {
|
33 |
+
$this->_forward('brontoGrid');
|
34 |
+
return;
|
35 |
+
}
|
36 |
+
|
37 |
+
$this->loadLayout();
|
38 |
+
$this->_setActiveMenu('system/email_template');
|
39 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Bronto Transactional Emails'), Mage::helper('adminhtml')->__('Bronto Transactional Emails'));
|
40 |
+
|
41 |
+
$this->_addContent($this->getLayout()->createBlock('bronto_email/adminhtml_system_email_template', 'template'));
|
42 |
+
$this->renderLayout();
|
43 |
+
}
|
44 |
+
|
45 |
+
/**
|
46 |
+
* Main Grid view for Importing Transactional Email Templates into Bronto
|
47 |
+
* @return null
|
48 |
+
*/
|
49 |
+
public function importAction()
|
50 |
+
{
|
51 |
+
$this->_title($this->__('System'))->_title($this->__('Import Transactional Emails'));
|
52 |
+
Mage::getSingleton('adminhtml/session')->setPostRedirect('*/*/import');
|
53 |
+
|
54 |
+
if ($this->getRequest()->getQuery('ajax')) {
|
55 |
+
$this->_forward('grid');
|
56 |
+
return;
|
57 |
+
}
|
58 |
+
|
59 |
+
$this->loadLayout();
|
60 |
+
$this->_setActiveMenu('system/email_template');
|
61 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Import Transactional Emails'), Mage::helper('adminhtml')->__('Import Transactional Emails'));
|
62 |
+
|
63 |
+
$this->_addContent($this->getLayout()->createBlock('bronto_email/adminhtml_system_email_import', 'import'));
|
64 |
+
$this->renderLayout();
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Override Ajax grid for import to show custom grid for Magento Templates
|
69 |
+
* @return type
|
70 |
+
*/
|
71 |
+
public function gridAction()
|
72 |
+
{
|
73 |
+
if (!Mage::helper('bronto_email')->isEnabledForAny()) {
|
74 |
+
return parent::gridAction();
|
75 |
}
|
76 |
|
77 |
+
$this->getResponse()->setBody($this->getLayout()->createBlock('bronto_email/adminhtml_system_email_import_grid')->toHtml());
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* Override Ajax grid for index to show Bronto Templates
|
82 |
+
* @return type
|
83 |
+
*/
|
84 |
+
public function brontoGridAction()
|
85 |
+
{
|
86 |
+
if (!Mage::helper('bronto_email')->isEnabledForAny()) {
|
87 |
+
return parent::gridAction();
|
88 |
+
}
|
89 |
+
|
90 |
+
$this->getResponse()->setBody($this->getLayout()->createBlock('bronto_email/adminhtml_system_email_template_grid')->toHtml());
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Create drop-down of templates
|
95 |
+
*/
|
96 |
+
public function ajaxlistAction()
|
97 |
+
{
|
98 |
+
$template = $this->_initTemplate();
|
99 |
$request = $this->getRequest();
|
100 |
+
$filter = array();
|
101 |
+
$storeId = $request->getParam('id', null);
|
102 |
+
$sendType = $request->getParam('type', false);
|
103 |
+
if ('transactional' == $sendType) {
|
104 |
+
$filter = array('transactional_approval' => 'accepted');
|
105 |
+
}
|
106 |
+
|
107 |
+
$messages = Mage::helper('bronto_email/message')->getMessagesOptionsArray($storeId, null, $filter, true);
|
108 |
+
foreach ($messages as $message) {
|
109 |
+
if ($message['value'] == $template->getBrontoMessageId()) {
|
110 |
+
echo sprintf('<option value="%s" selected="selected">%s</option>', $message['value'], $message['label']);
|
111 |
+
} else {
|
112 |
+
echo sprintf('<option value="%s">%s</option>', $message['value'], $message['label']);
|
113 |
+
}
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
/**
|
118 |
+
* Populate 'Original Template Text' field with Bronto Message Content on template change
|
119 |
+
*
|
120 |
+
* @access public
|
121 |
+
*/
|
122 |
+
public function ajaxtemplateAction()
|
123 |
+
{
|
124 |
+
$templateId = $this->getRequest()->getParam('template_id', false);
|
125 |
+
|
126 |
+
if ($templateId) {
|
127 |
+
$template = Mage::getModel('bronto_email/template')->loadDefault($templateId);
|
128 |
+
|
129 |
+
$templateContent = trim($template->getTemplateText());
|
130 |
+
// echo Template Content
|
131 |
+
echo $templateContent;
|
132 |
+
}
|
133 |
+
|
134 |
+
echo '';
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Determines if this action is a returnable action
|
139 |
+
*
|
140 |
+
* @return boolean
|
141 |
+
*/
|
142 |
+
protected function _isReturnableAction()
|
143 |
+
{
|
144 |
+
return in_array($this->getRequest()->getActionName(), $this->_returnableActions);
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Sends the user back to the Post-Redirect location, if the action is returnable
|
149 |
+
*/
|
150 |
+
protected function _postReturn()
|
151 |
+
{
|
152 |
+
$session = Mage::getSingleton('adminhtml/session');
|
153 |
+
if ($this->_isReturnableAction() && $session->hasPostRedirect()) {
|
154 |
+
$this->_redirect($session->getPostRedirect());
|
155 |
+
}
|
156 |
+
}
|
157 |
+
|
158 |
+
/**
|
159 |
+
* Override to route back to Post-Redirect location
|
160 |
+
*/
|
161 |
+
public function postDispatch()
|
162 |
+
{
|
163 |
+
parent::postDispatch();
|
164 |
+
$this->_postReturn();
|
165 |
+
}
|
166 |
+
|
167 |
+
/**
|
168 |
+
* Override Save Action for Bronto Templates
|
169 |
+
* @return type
|
170 |
+
*/
|
171 |
+
public function brontoSaveAction()
|
172 |
+
{
|
173 |
+
if (!Mage::helper('bronto_email')->isEnabledForAny()) {
|
174 |
+
return parent::saveAction();
|
175 |
+
}
|
176 |
|
177 |
+
$request = $this->getRequest();
|
178 |
+
$id = $this->getRequest()->getParam('id');
|
179 |
$template = $this->_initTemplate('id');
|
180 |
+
|
181 |
if (!$template->getId() && $id) {
|
182 |
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('This Email template no longer exists.'));
|
183 |
$this->_redirect('*/*/');
|
185 |
}
|
186 |
|
187 |
try {
|
188 |
+
// Add Template Settings
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
189 |
$template->setTemplateCode($request->getParam('template_code'))
|
|
|
|
|
190 |
->setModifiedAt(Mage::getSingleton('core/date')->gmtDate())
|
191 |
+
->setTemplateText($request->getParam('template_text'))
|
192 |
+
->setTemplateSubject($request->getParam('template_subject'))
|
193 |
+
->setTemplateStyles($request->getParam('template_styles'))
|
194 |
->setOrigTemplateCode($request->getParam('orig_template_code'))
|
195 |
+
->setOrigTemplateVariables($request->getParam('orig_template_variables'));
|
196 |
+
|
197 |
+
// Get Bronto Template and Add Template Settings
|
198 |
+
$brontoTemplate = Mage::getModel('bronto_email/message')
|
199 |
+
->setTemplateSendType($request->getParam('template_send_type'))
|
200 |
->setStoreId($request->getParam('store_id'));
|
201 |
|
202 |
+
// Handle Template Type Settings
|
203 |
+
if (!$template->getId()) {
|
204 |
+
$template->setTemplateType(Mage_Core_Model_Email_Template::TYPE_HTML);
|
205 |
+
}
|
206 |
+
|
207 |
+
if ($request->getParam('_change_type_flag')) {
|
208 |
+
$template->setTemplateType(Mage_Core_Model_Email_Template::TYPE_TEXT);
|
209 |
+
$template->setTemplateStyles('');
|
210 |
+
}
|
211 |
+
|
212 |
+
// Add appropriate values based on send type
|
213 |
+
switch ($request->getParam('template_send_type')) {
|
214 |
+
case 'magento':
|
215 |
+
$brontoTemplate
|
216 |
+
->setBrontoMessageId($request->getParam('bronto_message_id_hidden'))
|
217 |
+
->setOrigTemplateText($request->getParam('template_text'))
|
218 |
+
->setBrontoMessageName($this->_getMessageName($request->getParam('bronto_message_id_hidden')));
|
219 |
+
break;
|
220 |
+
|
221 |
+
default:
|
222 |
+
$template->setTemplateText($request->getParam('template_text_hidden'))
|
223 |
+
->setTemplateSubject($request->getParam('template_subject_hidden'))
|
224 |
+
->setTemplateStyles($request->getParam('template_styles_hidden'));
|
225 |
+
|
226 |
+
if ('_new_' == $request->getParam('bronto_message_id')) {
|
227 |
+
$template->save();
|
228 |
+
|
229 |
+
$importModel = Mage::getModel('bronto_email/template_import');
|
230 |
+
$importModel->importTemplate($template->getId(), $request->getParam('store_id'));
|
231 |
+
} else {
|
232 |
+
$brontoTemplate->setBrontoMessageId($request->getParam('bronto_message_id'))
|
233 |
+
->setBrontoMessageName($this->_getMessageName($request->getParam('bronto_message_id')))
|
234 |
+
->setOrigTemplateText($request->getParam('orig_template_text', null));
|
235 |
+
}
|
236 |
+
|
237 |
+
break;
|
238 |
+
}
|
239 |
+
|
240 |
if (!$template->getId() || !$template->getAddedAt()) {
|
241 |
$template->setAddedAt(Mage::getSingleton('core/date')->gmtDate());
|
242 |
}
|
243 |
|
244 |
+
// Save Template
|
245 |
$template->save();
|
246 |
+
|
247 |
+
// Set Bronto Template ID to match newly saved Template and then save
|
248 |
+
$brontoTemplate->setId($template->getId());
|
249 |
+
$brontoTemplate->save();
|
250 |
+
|
251 |
Mage::getSingleton('adminhtml/session')->setFormData(false);
|
252 |
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('The email template has been saved.'));
|
253 |
$this->_redirect('*/*');
|
|
|
254 |
} catch (Exception $e) {
|
255 |
Mage::getSingleton('adminhtml/session')->setData('email_template_form_data', $this->getRequest()->getParams());
|
256 |
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
257 |
+
$this->_forward('brontoNew');
|
258 |
+
}
|
259 |
+
}
|
260 |
+
|
261 |
+
/**
|
262 |
+
* Get Message Name from Message ID
|
263 |
+
* @param type $messageId
|
264 |
+
* @return type
|
265 |
+
*/
|
266 |
+
private function _getMessageName($messageId)
|
267 |
+
{
|
268 |
+
$messages = Mage::helper('bronto_common/message')->getAllMessageOptions();
|
269 |
+
foreach ($messages as $message) {
|
270 |
+
if ($message['value'] == $messageId) {
|
271 |
+
return $message['label'];
|
272 |
+
}
|
273 |
+
}
|
274 |
+
}
|
275 |
+
|
276 |
+
/**
|
277 |
+
* Edit Default Templates
|
278 |
+
*/
|
279 |
+
public function importEditAction()
|
280 |
+
{
|
281 |
+
$this->loadLayout();
|
282 |
+
$template = $this->_initTemplate('id');
|
283 |
+
$this->_setActiveMenu('system/email_template');
|
284 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Transactional Emails'), Mage::helper('adminhtml')->__('Transactional Emails'), $this->getUrl('*/*'));
|
285 |
+
|
286 |
+
if ($this->getRequest()->getParam('id')) {
|
287 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Edit Template'), Mage::helper('adminhtml')->__('Edit System Template'));
|
288 |
+
} else {
|
289 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('New Template'), Mage::helper('adminhtml')->__('New System Template'));
|
290 |
+
}
|
291 |
+
|
292 |
+
$this->_title($template->getId() ? $template->getTemplateCode() : $this->__('New Template'));
|
293 |
+
|
294 |
+
$this->_addContent($this->getLayout()->createBlock('bronto_email/adminhtml_system_email_import_edit', 'template_edit')
|
295 |
+
->setEditMode((bool)$this->getRequest()->getParam('id')));
|
296 |
+
$this->renderLayout();
|
297 |
+
}
|
298 |
+
|
299 |
+
/**
|
300 |
+
* Edit transactioanl email action
|
301 |
+
*/
|
302 |
+
public function brontoEditAction()
|
303 |
+
{
|
304 |
+
$this->_forward('brontonew');
|
305 |
+
}
|
306 |
+
|
307 |
+
/**
|
308 |
+
* Create transactional email action
|
309 |
+
*/
|
310 |
+
public function brontoNewAction()
|
311 |
+
{
|
312 |
+
$this->loadLayout();
|
313 |
+
$template = $this->_initTemplate('id');
|
314 |
+
$this->_setActiveMenu('system/email_template');
|
315 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Transactional Emails'), Mage::helper('adminhtml')->__('Transactional Emails'), $this->getUrl('*/*'));
|
316 |
+
|
317 |
+
if ($this->getRequest()->getParam('id')) {
|
318 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('Edit Template'), Mage::helper('adminhtml')->__('Edit System Template'));
|
319 |
+
} else {
|
320 |
+
$this->_addBreadcrumb(Mage::helper('adminhtml')->__('New Template'), Mage::helper('adminhtml')->__('New System Template'));
|
321 |
}
|
322 |
+
|
323 |
+
$this->_title($template->getId() ? $template->getTemplateCode() : $this->__('New Template'));
|
324 |
+
|
325 |
+
$this->_addContent($this->getLayout()->createBlock('bronto_email/adminhtml_system_email_template_edit', 'template_edit')
|
326 |
+
->setEditMode((bool)$this->getRequest()->getParam('id')));
|
327 |
+
$this->renderLayout();
|
328 |
}
|
329 |
|
330 |
/**
|
332 |
*/
|
333 |
public function defaultTemplateAction()
|
334 |
{
|
335 |
+
if (!Mage::helper('bronto_email')->isEnabledForAny()) {
|
336 |
return parent::defaultTemplateAction();
|
337 |
}
|
338 |
|
346 |
$templateBlock = $this->getLayout()->createBlock('adminhtml/system_email_template_edit');
|
347 |
$template->setData('orig_template_used_default_for', $templateBlock->getUsedDefaultForPaths(false));
|
348 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
349 |
$this->getResponse()->setBody(Mage::helper('core')->jsonEncode($template->getData()));
|
350 |
}
|
351 |
|
352 |
+
/**
|
353 |
+
* Mass Action for Import
|
354 |
+
*/
|
355 |
+
public function massImportAction()
|
356 |
{
|
357 |
+
$templateIds = $this->getRequest()->getParam('template_id', array());
|
358 |
+
$storeId = $this->getRequest()->getParam('store_id', null);
|
359 |
+
$imported = 0;
|
360 |
+
|
361 |
+
// If single ID, set as array
|
362 |
+
if (is_numeric($templateIds)) {
|
363 |
+
$templateIds = array($templateIds);
|
364 |
+
}
|
365 |
+
|
366 |
+
// Begin Processing Templates
|
367 |
+
if (count($templateIds) > 0) {
|
368 |
$importModel = Mage::getModel('bronto_email/template_import');
|
369 |
+
foreach ($templateIds as $templateId) {
|
370 |
+
try {
|
371 |
+
if ($importModel->importTemplate($templateId, $storeId)) {
|
372 |
+
$imported++;
|
373 |
+
}
|
374 |
+
} catch (Exception $e) {
|
375 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
376 |
+
}
|
377 |
+
}
|
378 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__(
|
379 |
+
'Total of %d email template(s) have been successfully imported.', $imported
|
380 |
+
));
|
381 |
+
} else {
|
382 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('bronto_email')->__('Please select template(s).'));
|
383 |
+
}
|
384 |
+
|
385 |
+
$this->_redirect('*/*/index');
|
386 |
+
}
|
387 |
+
|
388 |
+
/**
|
389 |
+
* Mass Action for Import
|
390 |
+
*/
|
391 |
+
public function massDeleteAction()
|
392 |
+
{
|
393 |
+
$templateIds = $this->getRequest()->getParam('template_id', array());
|
394 |
+
$deleteLevel = $this->getRequest()->getParam('delete_level', 'message');
|
395 |
+
$deleted = 0;
|
396 |
+
|
397 |
+
// If single ID, set as array
|
398 |
+
if (is_numeric($templateIds)) {
|
399 |
+
$templateIds = array($templateIds);
|
400 |
+
}
|
401 |
+
|
402 |
+
// Begin Processing Templates
|
403 |
+
if (count($templateIds) > 0) {
|
404 |
+
foreach ($templateIds as $templateId) {
|
405 |
+
if ('full' == $deleteLevel) {
|
406 |
+
$template = Mage::getModel('bronto_email/template')->load($templateId);
|
407 |
+
} else {
|
408 |
+
$template = Mage::getModel('bronto_email/message')->load($templateId);
|
409 |
+
}
|
410 |
+
|
411 |
+
if ($template->getId()) {
|
412 |
+
try {
|
413 |
+
$template->delete();
|
414 |
+
$deleted++;
|
415 |
+
} catch (Exception $e) {
|
416 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
417 |
+
}
|
418 |
+
}
|
419 |
+
}
|
420 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__(
|
421 |
+
'Total of %d email template(s) have been successfully deleted.', $deleted
|
422 |
+
));
|
423 |
+
} else {
|
424 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('bronto_email')->__('Please select template(s).'));
|
425 |
+
}
|
426 |
+
|
427 |
+
$this->_redirect('*/*');
|
428 |
+
}
|
429 |
+
|
430 |
+
public function updateSendTypeAction()
|
431 |
+
{
|
432 |
+
$templateIds = $this->getRequest()->getParam('template_id', array());
|
433 |
+
$sendType = $this->getRequest()->getParam('send_type', 'marketing');
|
434 |
+
$updated = 0;
|
435 |
+
|
436 |
+
// If single ID, set as array
|
437 |
+
if (is_numeric($templateIds)) {
|
438 |
+
$templateIds = array($templateIds);
|
439 |
+
}
|
440 |
+
|
441 |
+
// Begin Processing Templates
|
442 |
+
if (count($templateIds) > 0) {
|
443 |
+
foreach ($templateIds as $templateId) {
|
444 |
+
$template = Mage::getModel('bronto_email/message')->load($templateId);
|
445 |
+
|
446 |
+
// TODO: When approval status is available from api, implement this check
|
447 |
+
// if ('transactional' == $sendType && 0 === $template->getBrontoMessageApproved()) {
|
448 |
+
// Mage::helper('bronto_email')->writeError(
|
449 |
+
// Mage::helper('bronto_email')->__($template->getTemplateCode() . ' has not been approved for transactional sending')
|
450 |
+
// );
|
451 |
+
// }
|
452 |
+
|
453 |
+
if ($template->getId()) {
|
454 |
+
try {
|
455 |
+
$template->setTemplateSendType($sendType);
|
456 |
+
$template->save();
|
457 |
+
$updated++;
|
458 |
+
} catch (Exception $e) {
|
459 |
+
Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
|
460 |
+
}
|
461 |
+
}
|
462 |
+
}
|
463 |
+
Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__(
|
464 |
+
'Total of %d email template(s) have been successfully updated.', $updated
|
465 |
+
));
|
466 |
+
} else {
|
467 |
+
Mage::getSingleton('adminhtml/session')->addError(Mage::helper('bronto_email')->__('Please select template(s).'));
|
468 |
+
}
|
469 |
+
|
470 |
+
$this->_redirect('*/*/index');
|
471 |
+
}
|
472 |
+
|
473 |
+
/**
|
474 |
+
* Load in all of Magento's default templates
|
475 |
+
*/
|
476 |
+
public function loadDefaultsAction()
|
477 |
+
{
|
478 |
+
/** @var $templateMode Bronto_Email_Model_Template_Import */
|
479 |
+
$templateModel = Mage::getModel('bronto_email/template');
|
480 |
|
481 |
+
// Process Templates
|
482 |
+
try {
|
483 |
+
$templateModel->handleDefaultTemplates();
|
484 |
} catch (Exception $e) {
|
485 |
+
Mage::helper('bronto_email')->writeError($e->getMessage());
|
|
|
486 |
}
|
487 |
+
|
488 |
+
$this->_redirect('*/*/import');
|
489 |
}
|
490 |
|
491 |
+
/**
|
492 |
+
* Preview Action to display Template Content
|
493 |
+
*/
|
494 |
+
public function previewAction()
|
495 |
{
|
496 |
+
parent::previewAction();
|
497 |
+
}
|
498 |
+
|
499 |
+
/**
|
500 |
+
* Load email template from request
|
501 |
+
*
|
502 |
+
* @param string $idFieldName
|
503 |
+
* @return Mage_Adminhtml_Model_Email_Template $model
|
504 |
+
*/
|
505 |
+
protected function _initTemplate($idFieldName = 'template_id')
|
506 |
+
{
|
507 |
+
$this->_title($this->__('System'))->_title($this->__('Transactional Emails'));
|
508 |
+
|
509 |
+
$id = (int)$this->getRequest()->getParam($idFieldName);
|
510 |
+
$model = Mage::getModel('bronto_email/template');
|
511 |
+
|
512 |
+
if ($id) {
|
513 |
+
$model->load($id);
|
514 |
+
}
|
515 |
+
|
516 |
+
if (!Mage::registry('email_template')) {
|
517 |
+
Mage::register('email_template', $model);
|
518 |
+
}
|
519 |
+
if (!Mage::registry('current_email_template')) {
|
520 |
+
Mage::register('current_email_template', $model);
|
521 |
}
|
522 |
+
return $model;
|
523 |
+
}
|
524 |
+
|
525 |
+
protected function _isAllowed()
|
526 |
+
{
|
527 |
+
return Mage::getSingleton('admin/session')->isAllowed('bronto_email/email_template');
|
528 |
}
|
529 |
+
|
530 |
}
|
app/code/community/Bronto/Email/etc/adminhtml.xml
CHANGED
@@ -9,8 +9,8 @@
|
|
9 |
<config>
|
10 |
<children>
|
11 |
<bronto_email translate="title" module="bronto_email">
|
12 |
-
<title>Bronto
|
13 |
-
<sort_order>
|
14 |
</bronto_email>
|
15 |
</children>
|
16 |
</config>
|
@@ -20,4 +20,4 @@
|
|
20 |
</admin>
|
21 |
</resources>
|
22 |
</acl>
|
23 |
-
</config>
|
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>
|
20 |
</admin>
|
21 |
</resources>
|
22 |
</acl>
|
23 |
+
</config>
|
app/code/community/Bronto/Email/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Bronto_Email>
|
5 |
-
<version>1.1.
|
6 |
</Bronto_Email>
|
7 |
</modules>
|
8 |
<global>
|
@@ -15,14 +15,6 @@
|
|
15 |
<bronto_email>
|
16 |
<class>Bronto_Email_Block</class>
|
17 |
</bronto_email>
|
18 |
-
<adminhtml>
|
19 |
-
<rewrite>
|
20 |
-
<system_email_template>Bronto_Email_Block_Adminhtml_System_Email_Template</system_email_template>
|
21 |
-
<system_email_template_grid>Bronto_Email_Block_Adminhtml_System_Email_Template_Grid</system_email_template_grid>
|
22 |
-
<system_email_template_edit>Bronto_Email_Block_Adminhtml_System_Email_Template_Edit</system_email_template_edit>
|
23 |
-
<system_email_template_edit_form>Bronto_Email_Block_Adminhtml_System_Email_Template_Edit_Form</system_email_template_edit_form>
|
24 |
-
</rewrite>
|
25 |
-
</adminhtml>
|
26 |
</blocks>
|
27 |
<models>
|
28 |
<bronto_email>
|
@@ -32,12 +24,21 @@
|
|
32 |
<bronto_email_mysql4>
|
33 |
<class>Bronto_Email_Model_Mysql4</class>
|
34 |
<entities>
|
35 |
-
<log
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
</entities>
|
37 |
</bronto_email_mysql4>
|
38 |
<core>
|
39 |
<rewrite>
|
40 |
-
<email_template>
|
|
|
41 |
</rewrite>
|
42 |
</core>
|
43 |
<adminhtml>
|
@@ -50,10 +51,8 @@
|
|
50 |
<bronto_email_setup>
|
51 |
<setup>
|
52 |
<module>Bronto_Email</module>
|
|
|
53 |
</setup>
|
54 |
-
<connection>
|
55 |
-
<use>core_setup</use>
|
56 |
-
</connection>
|
57 |
</bronto_email_setup>
|
58 |
<bronto_email_write>
|
59 |
<connection>
|
@@ -82,6 +81,7 @@
|
|
82 |
<bronto_email>
|
83 |
<settings>
|
84 |
<enabled>0</enabled>
|
|
|
85 |
<log_enabled>1</log_enabled>
|
86 |
<log_fields_enabled>1</log_fields_enabled>
|
87 |
</settings>
|
@@ -89,6 +89,15 @@
|
|
89 |
</default>
|
90 |
<adminhtml>
|
91 |
<events>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
<controller_action_predispatch>
|
93 |
<observers>
|
94 |
<bronto_email_controller_action_predispatch>
|
@@ -97,6 +106,15 @@
|
|
97 |
</bronto_email_controller_action_predispatch>
|
98 |
</observers>
|
99 |
</controller_action_predispatch>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
100 |
</events>
|
101 |
<layout>
|
102 |
<updates>
|
@@ -105,32 +123,12 @@
|
|
105 |
</bronto_email>
|
106 |
</updates>
|
107 |
</layout>
|
108 |
-
<acl>
|
109 |
-
<resources>
|
110 |
-
<admin>
|
111 |
-
<children>
|
112 |
-
<system>
|
113 |
-
<children>
|
114 |
-
<config>
|
115 |
-
<children>
|
116 |
-
<bronto_email translate="title" module="bronto_email">
|
117 |
-
<title>Bronto Email</title>
|
118 |
-
<sort_order>200</sort_order>
|
119 |
-
</bronto_email>
|
120 |
-
</children>
|
121 |
-
</config>
|
122 |
-
</children>
|
123 |
-
</system>
|
124 |
-
</children>
|
125 |
-
</admin>
|
126 |
-
</resources>
|
127 |
-
</acl>
|
128 |
</adminhtml>
|
129 |
<phpunit>
|
130 |
<suite>
|
131 |
<modules>
|
132 |
-
|
133 |
</modules>
|
134 |
-
|
135 |
</phpunit>
|
136 |
</config>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Bronto_Email>
|
5 |
+
<version>1.1.7</version>
|
6 |
</Bronto_Email>
|
7 |
</modules>
|
8 |
<global>
|
15 |
<bronto_email>
|
16 |
<class>Bronto_Email_Block</class>
|
17 |
</bronto_email>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
</blocks>
|
19 |
<models>
|
20 |
<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>
|
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>
|
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>
|
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 |
+
</observers>
|
100 |
+
</bronto_email_enable>
|
101 |
<controller_action_predispatch>
|
102 |
<observers>
|
103 |
<bronto_email_controller_action_predispatch>
|
106 |
</bronto_email_controller_action_predispatch>
|
107 |
</observers>
|
108 |
</controller_action_predispatch>
|
109 |
+
<controller_action_predispatch_adminhtml_system_config_save>
|
110 |
+
<observers>
|
111 |
+
<bronto_email_controller_action_postdispatch_adminhtml_system_config_save>
|
112 |
+
<type>singleton</type>
|
113 |
+
<class>bronto_email/observer</class>
|
114 |
+
<method>saveDynamicField</method>
|
115 |
+
</bronto_email_controller_action_postdispatch_adminhtml_system_config_save>
|
116 |
+
</observers>
|
117 |
+
</controller_action_predispatch_adminhtml_system_config_save>
|
118 |
</events>
|
119 |
<layout>
|
120 |
<updates>
|
123 |
</bronto_email>
|
124 |
</updates>
|
125 |
</layout>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
126 |
</adminhtml>
|
127 |
<phpunit>
|
128 |
<suite>
|
129 |
<modules>
|
130 |
+
<Bronto_Email/>
|
131 |
</modules>
|
132 |
+
</suite>
|
133 |
</phpunit>
|
134 |
</config>
|
app/code/community/Bronto/Email/etc/system.xml
CHANGED
@@ -21,6 +21,7 @@
|
|
21 |
<settings translate="label">
|
22 |
<label>Settings</label>
|
23 |
<frontend_type>text</frontend_type>
|
|
|
24 |
<sort_order>1</sort_order>
|
25 |
<show_in_default>1</show_in_default>
|
26 |
<show_in_website>1</show_in_website>
|
@@ -31,34 +32,1324 @@
|
|
31 |
<label>Enable Module</label>
|
32 |
<frontend_type>select</frontend_type>
|
33 |
<frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
|
|
|
34 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
35 |
<sort_order>0</sort_order>
|
36 |
<show_in_default>1</show_in_default>
|
37 |
<show_in_website>1</show_in_website>
|
38 |
<show_in_store>1</show_in_store>
|
39 |
</enabled>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
40 |
<log_enabled translate="label">
|
41 |
<label>Log Deliveries</label>
|
42 |
-
<depends
|
|
|
|
|
43 |
<frontend_type>select</frontend_type>
|
44 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
45 |
<sort_order>10</sort_order>
|
46 |
<show_in_default>1</show_in_default>
|
47 |
-
<show_in_website>
|
48 |
-
<show_in_store>
|
49 |
</log_enabled>
|
50 |
<log_fields_enabled translate="label">
|
51 |
<label>Log Delivery Fields</label>
|
52 |
-
<depends
|
|
|
|
|
53 |
<frontend_type>select</frontend_type>
|
54 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
55 |
<sort_order>11</sort_order>
|
56 |
<show_in_default>1</show_in_default>
|
57 |
-
<show_in_website>
|
58 |
-
<show_in_store>
|
59 |
</log_fields_enabled>
|
60 |
</fields>
|
61 |
</settings>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
</groups>
|
63 |
</bronto_email>
|
64 |
</sections>
|
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>
|
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 |
</fields>
|
80 |
</settings>
|
81 |
+
<templates translate="label">
|
82 |
+
<label>Assign Templates</label>
|
83 |
+
<frontend_type>text</frontend_type>
|
84 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates</frontend_model>
|
85 |
+
<sort_order>2</sort_order>
|
86 |
+
<show_in_default>1</show_in_default>
|
87 |
+
<show_in_website>1</show_in_website>
|
88 |
+
<show_in_store>1</show_in_store>
|
89 |
+
<expanded>1</expanded>
|
90 |
+
<!--<fields>
|
91 |
+
<label_currency>
|
92 |
+
<label><![CDATA[##currency## General » Currency Setup » Scheduled Import Settings]]></label>
|
93 |
+
<frontend_type>label</frontend_type>
|
94 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
95 |
+
<sort_order>0</sort_order>
|
96 |
+
<show_in_default>1</show_in_default>
|
97 |
+
<show_in_website>1</show_in_website>
|
98 |
+
<show_in_store>1</show_in_store>
|
99 |
+
</label_currency>
|
100 |
+
<currency-import-error_email_template translate="label">
|
101 |
+
<label>Error Email Template</label>
|
102 |
+
<frontend_type>select</frontend_type>
|
103 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
104 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
105 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
106 |
+
<sort_order>1</sort_order>
|
107 |
+
<show_in_default>1</show_in_default>
|
108 |
+
<show_in_website>1</show_in_website>
|
109 |
+
<show_in_store>1</show_in_store>
|
110 |
+
</currency-import-error_email_template>
|
111 |
+
<currency-import-error_email_template_send_type translate="label">
|
112 |
+
<label>Send Type</label>
|
113 |
+
<frontend_type>radios</frontend_type>
|
114 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
115 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
116 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
117 |
+
<sort_order>2</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 |
+
</currency-import-error_email_template_send_type>
|
122 |
+
|
123 |
+
<label_contacts>
|
124 |
+
<label><![CDATA[##contacts## General » Contacts » Email Options]]></label>
|
125 |
+
<frontend_type>label</frontend_type>
|
126 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
127 |
+
<sort_order>5</sort_order>
|
128 |
+
<show_in_default>1</show_in_default>
|
129 |
+
<show_in_website>1</show_in_website>
|
130 |
+
<show_in_store>1</show_in_store>
|
131 |
+
</label_contacts>
|
132 |
+
<contacts-email-email_template translate="label">
|
133 |
+
<label>Email Template</label>
|
134 |
+
<frontend_type>select</frontend_type>
|
135 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
136 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
137 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
138 |
+
<sort_order>6</sort_order>
|
139 |
+
<show_in_default>1</show_in_default>
|
140 |
+
<show_in_website>1</show_in_website>
|
141 |
+
<show_in_store>1</show_in_store>
|
142 |
+
</contacts-email-email_template>
|
143 |
+
<contacts-email-email_template_send_type translate="label">
|
144 |
+
<label>Send Type</label>
|
145 |
+
<frontend_type>radios</frontend_type>
|
146 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
147 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
148 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
149 |
+
<sort_order>7</sort_order>
|
150 |
+
<show_in_default>1</show_in_default>
|
151 |
+
<show_in_website>1</show_in_website>
|
152 |
+
<show_in_store>1</show_in_store>
|
153 |
+
</contacts-email-email_template_send_type>
|
154 |
+
|
155 |
+
<label_sendfriend>
|
156 |
+
<label><![CDATA[##sendfriend## Catalog » Email to a Friend » Email Templates]]></label>
|
157 |
+
<frontend_type>label</frontend_type>
|
158 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
159 |
+
<sort_order>10</sort_order>
|
160 |
+
<show_in_default>1</show_in_default>
|
161 |
+
<show_in_website>1</show_in_website>
|
162 |
+
<show_in_store>1</show_in_store>
|
163 |
+
</label_sendfriend>
|
164 |
+
<sendfriend-email-template translate="label">
|
165 |
+
<label>Email Template</label>
|
166 |
+
<frontend_type>select</frontend_type>
|
167 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
168 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
169 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
170 |
+
<sort_order>11</sort_order>
|
171 |
+
<show_in_default>1</show_in_default>
|
172 |
+
<show_in_website>1</show_in_website>
|
173 |
+
<show_in_store>1</show_in_store>
|
174 |
+
</sendfriend-email-template>
|
175 |
+
<sendfriend-email-template_send_type translate="label">
|
176 |
+
<label>Send Type</label>
|
177 |
+
<frontend_type>radios</frontend_type>
|
178 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
179 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
180 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
181 |
+
<sort_order>12</sort_order>
|
182 |
+
<show_in_default>1</show_in_default>
|
183 |
+
<show_in_website>1</show_in_website>
|
184 |
+
<show_in_store>1</show_in_store>
|
185 |
+
</sendfriend-email-template_send_type>
|
186 |
+
|
187 |
+
<label_newsletter>
|
188 |
+
<label><![CDATA[##newsletter## Customers » Newsletter » Subscription Options]]></label>
|
189 |
+
<frontend_type>label</frontend_type>
|
190 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
191 |
+
<sort_order>20</sort_order>
|
192 |
+
<show_in_default>1</show_in_default>
|
193 |
+
<show_in_website>1</show_in_website>
|
194 |
+
<show_in_store>1</show_in_store>
|
195 |
+
</label_newsletter>
|
196 |
+
<newsletter-subscription-success_email_template translate="label">
|
197 |
+
<label>Success Email Template</label>
|
198 |
+
<frontend_type>select</frontend_type>
|
199 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
200 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
201 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
202 |
+
<sort_order>21</sort_order>
|
203 |
+
<show_in_default>1</show_in_default>
|
204 |
+
<show_in_website>1</show_in_website>
|
205 |
+
<show_in_store>1</show_in_store>
|
206 |
+
</newsletter-subscription-success_email_template>
|
207 |
+
<newsletter-subscription-success_email_template_send_type translate="label">
|
208 |
+
<label>Send Type</label>
|
209 |
+
<frontend_type>radios</frontend_type>
|
210 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
211 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
212 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
213 |
+
<sort_order>22</sort_order>
|
214 |
+
<show_in_default>1</show_in_default>
|
215 |
+
<show_in_website>1</show_in_website>
|
216 |
+
<show_in_store>1</show_in_store>
|
217 |
+
</newsletter-subscription-success_email_template_send_type>
|
218 |
+
<newsletter-subscription-un_email_template translate="label">
|
219 |
+
<label>Unsubscription Email Template</label>
|
220 |
+
<frontend_type>select</frontend_type>
|
221 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
222 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
223 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
224 |
+
<sort_order>23</sort_order>
|
225 |
+
<show_in_default>1</show_in_default>
|
226 |
+
<show_in_website>1</show_in_website>
|
227 |
+
<show_in_store>1</show_in_store>
|
228 |
+
</newsletter-subscription-un_email_template>
|
229 |
+
<newsletter-subscription-un_email_template_send_type translate="label">
|
230 |
+
<label>Send Type</label>
|
231 |
+
<frontend_type>radios</frontend_type>
|
232 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
233 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
234 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
235 |
+
<sort_order>24</sort_order>
|
236 |
+
<show_in_default>1</show_in_default>
|
237 |
+
<show_in_website>1</show_in_website>
|
238 |
+
<show_in_store>1</show_in_store>
|
239 |
+
</newsletter-subscription-un_email_template_send_type>
|
240 |
+
<newsletter-subscription-confirm_email_template translate="label">
|
241 |
+
<label>Confirmation Email Template</label>
|
242 |
+
<frontend_type>select</frontend_type>
|
243 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
244 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
245 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
246 |
+
<sort_order>25</sort_order>
|
247 |
+
<show_in_default>1</show_in_default>
|
248 |
+
<show_in_website>1</show_in_website>
|
249 |
+
<show_in_store>1</show_in_store>
|
250 |
+
</newsletter-subscription-confirm_email_template>
|
251 |
+
<newsletter-subscription-confirm_email_template_send_type translate="label">
|
252 |
+
<label>Send Type</label>
|
253 |
+
<frontend_type>radios</frontend_type>
|
254 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
255 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
256 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
257 |
+
<sort_order>26</sort_order>
|
258 |
+
<show_in_default>1</show_in_default>
|
259 |
+
<show_in_website>1</show_in_website>
|
260 |
+
<show_in_store>1</show_in_store>
|
261 |
+
</newsletter-subscription-confirm_email_template_send_type>
|
262 |
+
|
263 |
+
<label_customer_create>
|
264 |
+
<label><![CDATA[##customer## Customers » Customer Configuration » Create New Account Options]]></label>
|
265 |
+
<frontend_type>label</frontend_type>
|
266 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
267 |
+
<sort_order>30</sort_order>
|
268 |
+
<show_in_default>1</show_in_default>
|
269 |
+
<show_in_website>1</show_in_website>
|
270 |
+
<show_in_store>1</show_in_store>
|
271 |
+
</label_customer_create>
|
272 |
+
<customer-create_account-email_template translate="label">
|
273 |
+
<label>Default Welcome Email</label>
|
274 |
+
<frontend_type>select</frontend_type>
|
275 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
276 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
277 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
278 |
+
<sort_order>31</sort_order>
|
279 |
+
<show_in_default>1</show_in_default>
|
280 |
+
<show_in_website>1</show_in_website>
|
281 |
+
<show_in_store>1</show_in_store>
|
282 |
+
</customer-create_account-email_template>
|
283 |
+
<customer-create_account-email_template_send_type translate="label">
|
284 |
+
<label>Send Type</label>
|
285 |
+
<frontend_type>radios</frontend_type>
|
286 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
287 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
288 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
289 |
+
<sort_order>32</sort_order>
|
290 |
+
<show_in_default>1</show_in_default>
|
291 |
+
<show_in_website>1</show_in_website>
|
292 |
+
<show_in_store>1</show_in_store>
|
293 |
+
</customer-create_account-email_template_send_type>
|
294 |
+
<customer-create_account-email_confirmation_template translate="label">
|
295 |
+
<label>Confirmation Link Email</label>
|
296 |
+
<frontend_type>select</frontend_type>
|
297 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
298 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
299 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
300 |
+
<sort_order>33</sort_order>
|
301 |
+
<show_in_default>1</show_in_default>
|
302 |
+
<show_in_website>1</show_in_website>
|
303 |
+
<show_in_store>1</show_in_store>
|
304 |
+
</customer-create_account-email_confirmation_template>
|
305 |
+
<customer-create_account-email_confirmation_template_send_type translate="label">
|
306 |
+
<label>Send Type</label>
|
307 |
+
<frontend_type>radios</frontend_type>
|
308 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
309 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
310 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
311 |
+
<sort_order>34</sort_order>
|
312 |
+
<show_in_default>1</show_in_default>
|
313 |
+
<show_in_website>1</show_in_website>
|
314 |
+
<show_in_store>1</show_in_store>
|
315 |
+
</customer-create_account-email_confirmation_template_send_type>
|
316 |
+
<customer-create_account-email_confirmed_template translate="label comment">
|
317 |
+
<label>Welcome Email</label>
|
318 |
+
<comment>This email will be sent instead of default welcome email, after account confirmation.</comment>
|
319 |
+
<frontend_type>select</frontend_type>
|
320 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
321 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
322 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
323 |
+
<sort_order>35</sort_order>
|
324 |
+
<show_in_default>1</show_in_default>
|
325 |
+
<show_in_website>1</show_in_website>
|
326 |
+
<show_in_store>1</show_in_store>
|
327 |
+
</customer-create_account-email_confirmed_template>
|
328 |
+
<customer-create_account-email_confirmed_template_send_type translate="label">
|
329 |
+
<label>Send Type</label>
|
330 |
+
<frontend_type>radios</frontend_type>
|
331 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
332 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
333 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
334 |
+
<sort_order>36</sort_order>
|
335 |
+
<show_in_default>1</show_in_default>
|
336 |
+
<show_in_website>1</show_in_website>
|
337 |
+
<show_in_store>1</show_in_store>
|
338 |
+
</customer-create_account-email_confirmed_template_send_type>
|
339 |
+
|
340 |
+
<label_customer_password>
|
341 |
+
<label><![CDATA[##customer## Customers » Customer Configuration » Password Options]]></label>
|
342 |
+
<frontend_type>label</frontend_type>
|
343 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
344 |
+
<sort_order>40</sort_order>
|
345 |
+
<show_in_default>1</show_in_default>
|
346 |
+
<show_in_website>1</show_in_website>
|
347 |
+
<show_in_store>1</show_in_store>
|
348 |
+
</label_customer_password>
|
349 |
+
<customer-password-forgot_email_template translate="label">
|
350 |
+
<label>Forgot Email Template</label>
|
351 |
+
<frontend_type>select</frontend_type>
|
352 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
353 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
354 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
355 |
+
<sort_order>41</sort_order>
|
356 |
+
<show_in_default>1</show_in_default>
|
357 |
+
<show_in_website>1</show_in_website>
|
358 |
+
<show_in_store>1</show_in_store>
|
359 |
+
</customer-password-forgot_email_template>
|
360 |
+
<customer-password-forgot_email_template_send_type translate="label">
|
361 |
+
<label>Send Type</label>
|
362 |
+
<frontend_type>radios</frontend_type>
|
363 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
364 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
365 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
366 |
+
<sort_order>42</sort_order>
|
367 |
+
<show_in_default>1</show_in_default>
|
368 |
+
<show_in_website>1</show_in_website>
|
369 |
+
<show_in_store>1</show_in_store>
|
370 |
+
</customer-password-forgot_email_template_send_type>
|
371 |
+
<customer-password-remind_email_template translate="label">
|
372 |
+
<label>Reminder Email Template</label>
|
373 |
+
<frontend_type>select</frontend_type>
|
374 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
375 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
376 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
377 |
+
<sort_order>43</sort_order>
|
378 |
+
<show_in_default>1</show_in_default>
|
379 |
+
<show_in_website>1</show_in_website>
|
380 |
+
<show_in_store>1</show_in_store>
|
381 |
+
</customer-password-remind_email_template>
|
382 |
+
<customer-password-remind_email_template_send_type translate="label">
|
383 |
+
<label>Send Type</label>
|
384 |
+
<frontend_type>radios</frontend_type>
|
385 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
386 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
387 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
388 |
+
<sort_order>44</sort_order>
|
389 |
+
<show_in_default>1</show_in_default>
|
390 |
+
<show_in_website>1</show_in_website>
|
391 |
+
<show_in_store>1</show_in_store>
|
392 |
+
</customer-password-remind_email_template_send_type>
|
393 |
+
|
394 |
+
<label_customer_store_credit>
|
395 |
+
<label><![CDATA[##customer## Customers » Customer Configuration » Store Credit Options]]></label>
|
396 |
+
<frontend_type>label</frontend_type>
|
397 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
398 |
+
<sort_order>50</sort_order>
|
399 |
+
<show_in_default>1</show_in_default>
|
400 |
+
<show_in_website>1</show_in_website>
|
401 |
+
<show_in_store>1</show_in_store>
|
402 |
+
</label_customer_store_credit>
|
403 |
+
<customer-enterprise_customerbalance-email_template translate="label">
|
404 |
+
<label>Store Credit Update Email Template</label>
|
405 |
+
<frontend_type>select</frontend_type>
|
406 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
407 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
408 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
409 |
+
<sort_order>51</sort_order>
|
410 |
+
<show_in_default>1</show_in_default>
|
411 |
+
<show_in_website>1</show_in_website>
|
412 |
+
<show_in_store>1</show_in_store>
|
413 |
+
</customer-enterprise_customerbalance-email_template>
|
414 |
+
<customer-enterprise_customerbalance-email_template_send_type translate="label">
|
415 |
+
<label>Send Type</label>
|
416 |
+
<frontend_type>radios</frontend_type>
|
417 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
418 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
419 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
420 |
+
<sort_order>52</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 |
+
</customer-enterprise_customerbalance-email_template_send_type>
|
425 |
+
|
426 |
+
<label_wishlist>
|
427 |
+
<label><![CDATA[##wishlist## Customers » Wishlist » Share Options]]></label>
|
428 |
+
<frontend_type>label</frontend_type>
|
429 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
430 |
+
<sort_order>60</sort_order>
|
431 |
+
<show_in_default>1</show_in_default>
|
432 |
+
<show_in_website>1</show_in_website>
|
433 |
+
<show_in_store>1</show_in_store>
|
434 |
+
</label_wishlist>
|
435 |
+
<wishlist-email-email_template translate="label">
|
436 |
+
<label>Email Template</label>
|
437 |
+
<frontend_type>select</frontend_type>
|
438 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
439 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
440 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
441 |
+
<sort_order>61</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 |
+
</wishlist-email-email_template>
|
446 |
+
<wishlist-email-email_template_send_type translate="label">
|
447 |
+
<label>Send Type</label>
|
448 |
+
<frontend_type>radios</frontend_type>
|
449 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
450 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
451 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
452 |
+
<sort_order>62</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 |
+
</wishlist-email-email_template_send_type>
|
457 |
+
|
458 |
+
<label_invitations>
|
459 |
+
<label><![CDATA[##enterprise_invitation## Customers » Invitations » Email]]></label>
|
460 |
+
<frontend_type>label</frontend_type>
|
461 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
462 |
+
<sort_order>70</sort_order>
|
463 |
+
<show_in_default>1</show_in_default>
|
464 |
+
<show_in_website>1</show_in_website>
|
465 |
+
<show_in_store>1</show_in_store>
|
466 |
+
</label_invitations>
|
467 |
+
<enterprise_invitation-email-template translate="label">
|
468 |
+
<label>Customer Invitation Email Template</label>
|
469 |
+
<frontend_type>select</frontend_type>
|
470 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
471 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
472 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
473 |
+
<sort_order>71</sort_order>
|
474 |
+
<show_in_default>1</show_in_default>
|
475 |
+
<show_in_website>1</show_in_website>
|
476 |
+
<show_in_store>1</show_in_store>
|
477 |
+
</enterprise_invitation-email-template>
|
478 |
+
<enterprise_invitation-email-template_send_type translate="label">
|
479 |
+
<label>Send Type</label>
|
480 |
+
<frontend_type>radios</frontend_type>
|
481 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
482 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
483 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
484 |
+
<sort_order>72</sort_order>
|
485 |
+
<show_in_default>1</show_in_default>
|
486 |
+
<show_in_website>1</show_in_website>
|
487 |
+
<show_in_store>1</show_in_store>
|
488 |
+
</enterprise_invitation-email-template_send_type>
|
489 |
+
|
490 |
+
<label_rewards>
|
491 |
+
<label><![CDATA[##enterprise_reward## Customers » Reward Points » Email Notification Settings]]></label>
|
492 |
+
<frontend_type>label</frontend_type>
|
493 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
494 |
+
<sort_order>80</sort_order>
|
495 |
+
<show_in_default>1</show_in_default>
|
496 |
+
<show_in_website>1</show_in_website>
|
497 |
+
<show_in_store>1</show_in_store>
|
498 |
+
</label_rewards>
|
499 |
+
<enterprise_reward-notification-balance_update_template translate="label">
|
500 |
+
<label>Balance Update Email</label>
|
501 |
+
<frontend_type>select</frontend_type>
|
502 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
503 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
504 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
505 |
+
<sort_order>81</sort_order>
|
506 |
+
<show_in_default>1</show_in_default>
|
507 |
+
<show_in_website>1</show_in_website>
|
508 |
+
<show_in_store>1</show_in_store>
|
509 |
+
</enterprise_reward-notification-balance_update_template>
|
510 |
+
<enterprise_reward-notification-balance_update_template_send_type translate="label">
|
511 |
+
<label>Send Type</label>
|
512 |
+
<frontend_type>radios</frontend_type>
|
513 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
514 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
515 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
516 |
+
<sort_order>82</sort_order>
|
517 |
+
<show_in_default>1</show_in_default>
|
518 |
+
<show_in_website>1</show_in_website>
|
519 |
+
<show_in_store>1</show_in_store>
|
520 |
+
</enterprise_reward-notification-balance_update_template_send_type>
|
521 |
+
<enterprise_reward-notification-expiry_warning_template translate="label">
|
522 |
+
<label>Reward Points Expiry Warning Email</label>
|
523 |
+
<frontend_type>select</frontend_type>
|
524 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
525 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
526 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
527 |
+
<sort_order>83</sort_order>
|
528 |
+
<show_in_default>1</show_in_default>
|
529 |
+
<show_in_website>1</show_in_website>
|
530 |
+
<show_in_store>1</show_in_store>
|
531 |
+
</enterprise_reward-notification-expiry_warning_template>
|
532 |
+
<enterprise_reward-notification-expiry_warning_template_send_type translate="label">
|
533 |
+
<label>Send Type</label>
|
534 |
+
<frontend_type>radios</frontend_type>
|
535 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
536 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
537 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
538 |
+
<sort_order>84</sort_order>
|
539 |
+
<show_in_default>1</show_in_default>
|
540 |
+
<show_in_website>1</show_in_website>
|
541 |
+
<show_in_store>1</show_in_store>
|
542 |
+
</enterprise_reward-notification-expiry_warning_template_send_type>
|
543 |
+
|
544 |
+
<label_giftregistry_owner_notification>
|
545 |
+
<label><![CDATA[##enterprise_giftregistry## Customers » Gift Registry » Owner Notification]]></label>
|
546 |
+
<frontend_type>label</frontend_type>
|
547 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
548 |
+
<sort_order>90</sort_order>
|
549 |
+
<show_in_default>1</show_in_default>
|
550 |
+
<show_in_website>1</show_in_website>
|
551 |
+
<show_in_store>1</show_in_store>
|
552 |
+
</label_giftregistry_owner_notification>
|
553 |
+
<enterprise_giftregistry-owner_email-template translate="label">
|
554 |
+
<label>Email Template</label>
|
555 |
+
<frontend_type>select</frontend_type>
|
556 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
557 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
558 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
559 |
+
<sort_order>91</sort_order>
|
560 |
+
<show_in_default>1</show_in_default>
|
561 |
+
<show_in_website>1</show_in_website>
|
562 |
+
<show_in_store>1</show_in_store>
|
563 |
+
</enterprise_giftregistry-owner_email-template>
|
564 |
+
<enterprise_giftregistry-owner_email-template_send_type translate="label">
|
565 |
+
<label>Send Type</label>
|
566 |
+
<frontend_type>radios</frontend_type>
|
567 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
568 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
569 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
570 |
+
<sort_order>92</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 |
+
</enterprise_giftregistry-owner_email-template_send_type>
|
575 |
+
|
576 |
+
<label_giftregistry_sharing>
|
577 |
+
<label><![CDATA[##enterprise_giftregistry## Customers » Gift Registry » Gift Registry Sharing]]></label>
|
578 |
+
<frontend_type>label</frontend_type>
|
579 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
580 |
+
<sort_order>100</sort_order>
|
581 |
+
<show_in_default>1</show_in_default>
|
582 |
+
<show_in_website>1</show_in_website>
|
583 |
+
<show_in_store>1</show_in_store>
|
584 |
+
</label_giftregistry_sharing>
|
585 |
+
<enterprise_giftregistry-sharing_email-template translate="label">
|
586 |
+
<label>Email Template</label>
|
587 |
+
<frontend_type>select</frontend_type>
|
588 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
589 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
590 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
591 |
+
<sort_order>101</sort_order>
|
592 |
+
<show_in_default>1</show_in_default>
|
593 |
+
<show_in_website>1</show_in_website>
|
594 |
+
<show_in_store>1</show_in_store>
|
595 |
+
</enterprise_giftregistry-sharing_email-template>
|
596 |
+
<enterprise_giftregistry-sharing_email-template_send_type translate="label">
|
597 |
+
<label>Send Type</label>
|
598 |
+
<frontend_type>radios</frontend_type>
|
599 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
600 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
601 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
602 |
+
<sort_order>102</sort_order>
|
603 |
+
<show_in_default>1</show_in_default>
|
604 |
+
<show_in_website>1</show_in_website>
|
605 |
+
<show_in_store>1</show_in_store>
|
606 |
+
</enterprise_giftregistry-sharing_email-template_send_type>
|
607 |
+
|
608 |
+
<label_giftregistry_update>
|
609 |
+
<label><![CDATA[##enterprise_giftregistry## Customers » Gift Registry » Gift Registry Update]]></label>
|
610 |
+
<frontend_type>label</frontend_type>
|
611 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
612 |
+
<sort_order>110</sort_order>
|
613 |
+
<show_in_default>1</show_in_default>
|
614 |
+
<show_in_website>1</show_in_website>
|
615 |
+
<show_in_store>1</show_in_store>
|
616 |
+
</label_giftregistry_update>
|
617 |
+
<enterprise_giftregistry-update_email-template translate="label">
|
618 |
+
<label>Email Template</label>
|
619 |
+
<frontend_type>select</frontend_type>
|
620 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
621 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
622 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
623 |
+
<sort_order>111</sort_order>
|
624 |
+
<show_in_default>1</show_in_default>
|
625 |
+
<show_in_website>1</show_in_website>
|
626 |
+
<show_in_store>1</show_in_store>
|
627 |
+
</enterprise_giftregistry-update_email-template>
|
628 |
+
<enterprise_giftregistry-update_email-template_send_type translate="label">
|
629 |
+
<label>Send Type</label>
|
630 |
+
<frontend_type>radios</frontend_type>
|
631 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
632 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
633 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
634 |
+
<sort_order>112</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 |
+
</enterprise_giftregistry-update_email-template_send_type>
|
639 |
+
|
640 |
+
<label_sales_email_order>
|
641 |
+
<label><![CDATA[##sales_email## Sales » Sales Emails » Order]]></label>
|
642 |
+
<frontend_type>label</frontend_type>
|
643 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
644 |
+
<sort_order>120</sort_order>
|
645 |
+
<show_in_default>1</show_in_default>
|
646 |
+
<show_in_website>1</show_in_website>
|
647 |
+
<show_in_store>1</show_in_store>
|
648 |
+
</label_sales_email_order>
|
649 |
+
<sales_email-order-template translate="label">
|
650 |
+
<label>New Order Confirmation Template</label>
|
651 |
+
<frontend_type>select</frontend_type>
|
652 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
653 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
654 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
655 |
+
<sort_order>121</sort_order>
|
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 |
+
</sales_email-order-template>
|
660 |
+
<sales_email-order-template_send_type translate="label">
|
661 |
+
<label>Send Type</label>
|
662 |
+
<frontend_type>radios</frontend_type>
|
663 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
664 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
665 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
666 |
+
<sort_order>122</sort_order>
|
667 |
+
<show_in_default>1</show_in_default>
|
668 |
+
<show_in_website>1</show_in_website>
|
669 |
+
<show_in_store>1</show_in_store>
|
670 |
+
</sales_email-order-template_send_type>
|
671 |
+
<sales_email-order-guest_template translate="label">
|
672 |
+
<label>New Order Confirmation Template for Guest</label>
|
673 |
+
<frontend_type>select</frontend_type>
|
674 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
675 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
676 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
677 |
+
<sort_order>123</sort_order>
|
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 |
+
</sales_email-order-guest_template>
|
682 |
+
<sales_email-order-guest_template_send_type translate="label">
|
683 |
+
<label>Send Type</label>
|
684 |
+
<frontend_type>radios</frontend_type>
|
685 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
686 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
687 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
688 |
+
<sort_order>124</sort_order>
|
689 |
+
<show_in_default>1</show_in_default>
|
690 |
+
<show_in_website>1</show_in_website>
|
691 |
+
<show_in_store>1</show_in_store>
|
692 |
+
</sales_email-order-guest_template_send_type>
|
693 |
+
|
694 |
+
<label_sales_email_order_comments>
|
695 |
+
<label><![CDATA[##sales_email## Sales » Sales Emails » Order Comments]]></label>
|
696 |
+
<frontend_type>label</frontend_type>
|
697 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
698 |
+
<sort_order>130</sort_order>
|
699 |
+
<show_in_default>1</show_in_default>
|
700 |
+
<show_in_website>1</show_in_website>
|
701 |
+
<show_in_store>1</show_in_store>
|
702 |
+
</label_sales_email_order_comments>
|
703 |
+
<sales_email-order_comment-template translate="label">
|
704 |
+
<label>Order Comment Email Template</label>
|
705 |
+
<frontend_type>select</frontend_type>
|
706 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
707 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
708 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
709 |
+
<sort_order>131</sort_order>
|
710 |
+
<show_in_default>1</show_in_default>
|
711 |
+
<show_in_website>1</show_in_website>
|
712 |
+
<show_in_store>1</show_in_store>
|
713 |
+
</sales_email-order_comment-template>
|
714 |
+
<sales_email-order_comment-template_send_type translate="label">
|
715 |
+
<label>Send Type</label>
|
716 |
+
<frontend_type>radios</frontend_type>
|
717 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
718 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
719 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
720 |
+
<sort_order>132</sort_order>
|
721 |
+
<show_in_default>1</show_in_default>
|
722 |
+
<show_in_website>1</show_in_website>
|
723 |
+
<show_in_store>1</show_in_store>
|
724 |
+
</sales_email-order_comment-template_send_type>
|
725 |
+
<sales_email-order_comment-guest_template translate="label">
|
726 |
+
<label>Order Comment Email Template for Guest</label>
|
727 |
+
<frontend_type>select</frontend_type>
|
728 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
729 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
730 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
731 |
+
<sort_order>133</sort_order>
|
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 |
+
</sales_email-order_comment-guest_template>
|
736 |
+
<sales_email-order_comment-guest_template_send_type translate="label">
|
737 |
+
<label>Send Type</label>
|
738 |
+
<frontend_type>radios</frontend_type>
|
739 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
740 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
741 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
742 |
+
<sort_order>134</sort_order>
|
743 |
+
<show_in_default>1</show_in_default>
|
744 |
+
<show_in_website>1</show_in_website>
|
745 |
+
<show_in_store>1</show_in_store>
|
746 |
+
</sales_email-order_comment-guest_template_send_type>
|
747 |
+
|
748 |
+
<label_sales_email_invoice>
|
749 |
+
<label><![CDATA[##sales_email## Sales » Sales Emails » Invoice]]></label>
|
750 |
+
<frontend_type>label</frontend_type>
|
751 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
752 |
+
<sort_order>140</sort_order>
|
753 |
+
<show_in_default>1</show_in_default>
|
754 |
+
<show_in_website>1</show_in_website>
|
755 |
+
<show_in_store>1</show_in_store>
|
756 |
+
</label_sales_email_invoice>
|
757 |
+
<sales_email-invoice-template translate="label">
|
758 |
+
<label>Invoice Email Template</label>
|
759 |
+
<frontend_type>select</frontend_type>
|
760 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
761 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
762 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
763 |
+
<sort_order>141</sort_order>
|
764 |
+
<show_in_default>1</show_in_default>
|
765 |
+
<show_in_website>1</show_in_website>
|
766 |
+
<show_in_store>1</show_in_store>
|
767 |
+
</sales_email-invoice-template>
|
768 |
+
<sales_email-invoice-template_send_type translate="label">
|
769 |
+
<label>Send Type</label>
|
770 |
+
<frontend_type>radios</frontend_type>
|
771 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
772 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
773 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
774 |
+
<sort_order>142</sort_order>
|
775 |
+
<show_in_default>1</show_in_default>
|
776 |
+
<show_in_website>1</show_in_website>
|
777 |
+
<show_in_store>1</show_in_store>
|
778 |
+
</sales_email-invoice-template_send_type>
|
779 |
+
<sales_email-invoice-guest_template translate="label">
|
780 |
+
<label>Invoice Email Template for Guest</label>
|
781 |
+
<frontend_type>select</frontend_type>
|
782 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
783 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
784 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
785 |
+
<sort_order>143</sort_order>
|
786 |
+
<show_in_default>1</show_in_default>
|
787 |
+
<show_in_website>1</show_in_website>
|
788 |
+
<show_in_store>1</show_in_store>
|
789 |
+
</sales_email-invoice-guest_template>
|
790 |
+
<sales_email-invoice-guest_template_send_type translate="label">
|
791 |
+
<label>Send Type</label>
|
792 |
+
<frontend_type>radios</frontend_type>
|
793 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
794 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
795 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
796 |
+
<sort_order>144</sort_order>
|
797 |
+
<show_in_default>1</show_in_default>
|
798 |
+
<show_in_website>1</show_in_website>
|
799 |
+
<show_in_store>1</show_in_store>
|
800 |
+
</sales_email-invoice-guest_template_send_type>
|
801 |
+
|
802 |
+
<label_sales_email_invoice_comment>
|
803 |
+
<label><![CDATA[##sales_email## Sales » Sales Emails » Invoice Comments]]></label>
|
804 |
+
<frontend_type>label</frontend_type>
|
805 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
806 |
+
<sort_order>150</sort_order>
|
807 |
+
<show_in_default>1</show_in_default>
|
808 |
+
<show_in_website>1</show_in_website>
|
809 |
+
<show_in_store>1</show_in_store>
|
810 |
+
</label_sales_email_invoice_comment>
|
811 |
+
<sales_email-invoice_comment-template translate="label">
|
812 |
+
<label>Invoice Comment Email Template</label>
|
813 |
+
<frontend_type>select</frontend_type>
|
814 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
815 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
816 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
817 |
+
<sort_order>151</sort_order>
|
818 |
+
<show_in_default>1</show_in_default>
|
819 |
+
<show_in_website>1</show_in_website>
|
820 |
+
<show_in_store>1</show_in_store>
|
821 |
+
</sales_email-invoice_comment-template>
|
822 |
+
<sales_email-invoice_comment-template_send_type translate="label">
|
823 |
+
<label>Send Type</label>
|
824 |
+
<frontend_type>radios</frontend_type>
|
825 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
826 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
827 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
828 |
+
<sort_order>152</sort_order>
|
829 |
+
<show_in_default>1</show_in_default>
|
830 |
+
<show_in_website>1</show_in_website>
|
831 |
+
<show_in_store>1</show_in_store>
|
832 |
+
</sales_email-invoice_comment-template_send_type>
|
833 |
+
<sales_email-invoice_comment-guest_template translate="label">
|
834 |
+
<label>Invoice Comment Email Template for Guest</label>
|
835 |
+
<frontend_type>select</frontend_type>
|
836 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
837 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
838 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
839 |
+
<sort_order>153</sort_order>
|
840 |
+
<show_in_default>1</show_in_default>
|
841 |
+
<show_in_website>1</show_in_website>
|
842 |
+
<show_in_store>1</show_in_store>
|
843 |
+
</sales_email-invoice_comment-guest_template>
|
844 |
+
<sales_email-invoice_comment-guest_template_send_type translate="label">
|
845 |
+
<label>Send Type</label>
|
846 |
+
<frontend_type>radios</frontend_type>
|
847 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
848 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
849 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
850 |
+
<sort_order>154</sort_order>
|
851 |
+
<show_in_default>1</show_in_default>
|
852 |
+
<show_in_website>1</show_in_website>
|
853 |
+
<show_in_store>1</show_in_store>
|
854 |
+
</sales_email-invoice_comment-guest_template_send_type>
|
855 |
+
|
856 |
+
<label_sales_email_shipment>
|
857 |
+
<label><![CDATA[##sales_email## Sales » Sales Emails » Shipment]]></label>
|
858 |
+
<frontend_type>label</frontend_type>
|
859 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
860 |
+
<sort_order>160</sort_order>
|
861 |
+
<show_in_default>1</show_in_default>
|
862 |
+
<show_in_website>1</show_in_website>
|
863 |
+
<show_in_store>1</show_in_store>
|
864 |
+
</label_sales_email_shipment>
|
865 |
+
<sales_email-shipment-template translate="label">
|
866 |
+
<label>Shipment Email Template</label>
|
867 |
+
<frontend_type>select</frontend_type>
|
868 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
869 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
870 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
871 |
+
<sort_order>161</sort_order>
|
872 |
+
<show_in_default>1</show_in_default>
|
873 |
+
<show_in_website>1</show_in_website>
|
874 |
+
<show_in_store>1</show_in_store>
|
875 |
+
</sales_email-shipment-template>
|
876 |
+
<sales_email-shipment-template_send_type translate="label">
|
877 |
+
<label>Send Type</label>
|
878 |
+
<frontend_type>radios</frontend_type>
|
879 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
880 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
881 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
882 |
+
<sort_order>162</sort_order>
|
883 |
+
<show_in_default>1</show_in_default>
|
884 |
+
<show_in_website>1</show_in_website>
|
885 |
+
<show_in_store>1</show_in_store>
|
886 |
+
</sales_email-shipment-template_send_type>
|
887 |
+
<sales_email-shipment-guest_template translate="label">
|
888 |
+
<label>Shipment Email Template for Guest</label>
|
889 |
+
<frontend_type>select</frontend_type>
|
890 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
891 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
892 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
893 |
+
<sort_order>163</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 |
+
</sales_email-shipment-guest_template>
|
898 |
+
<sales_email-shipment-guest_template_send_type translate="label">
|
899 |
+
<label>Send Type</label>
|
900 |
+
<frontend_type>radios</frontend_type>
|
901 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
902 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
903 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
904 |
+
<sort_order>164</sort_order>
|
905 |
+
<show_in_default>1</show_in_default>
|
906 |
+
<show_in_website>1</show_in_website>
|
907 |
+
<show_in_store>1</show_in_store>
|
908 |
+
</sales_email-shipment-guest_template_send_type>
|
909 |
+
|
910 |
+
<label_sales_email_shipment_comment>
|
911 |
+
<label><![CDATA[##sales_email## Sales » Sales Emails » Shipment Comments]]></label>
|
912 |
+
<frontend_type>label</frontend_type>
|
913 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
914 |
+
<sort_order>170</sort_order>
|
915 |
+
<show_in_default>1</show_in_default>
|
916 |
+
<show_in_website>1</show_in_website>
|
917 |
+
<show_in_store>1</show_in_store>
|
918 |
+
</label_sales_email_shipment_comment>
|
919 |
+
<sales_email-shipment_comment-template translate="label">
|
920 |
+
<label>Shipment Comment Email Template</label>
|
921 |
+
<frontend_type>select</frontend_type>
|
922 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
923 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
924 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
925 |
+
<sort_order>171</sort_order>
|
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 |
+
</sales_email-shipment_comment-template>
|
930 |
+
<sales_email-shipment_comment-template_send_type translate="label">
|
931 |
+
<label>Send Type</label>
|
932 |
+
<frontend_type>radios</frontend_type>
|
933 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
934 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
935 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
936 |
+
<sort_order>172</sort_order>
|
937 |
+
<show_in_default>1</show_in_default>
|
938 |
+
<show_in_website>1</show_in_website>
|
939 |
+
<show_in_store>1</show_in_store>
|
940 |
+
</sales_email-shipment_comment-template_send_type>
|
941 |
+
<sales_email-shipment_comment-guest_template translate="label">
|
942 |
+
<label>Shipment Comment Email Template for Guest</label>
|
943 |
+
<frontend_type>select</frontend_type>
|
944 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
945 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
946 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
947 |
+
<sort_order>173</sort_order>
|
948 |
+
<show_in_default>1</show_in_default>
|
949 |
+
<show_in_website>1</show_in_website>
|
950 |
+
<show_in_store>1</show_in_store>
|
951 |
+
</sales_email-shipment_comment-guest_template>
|
952 |
+
<sales_email-shipment_comment-guest_template_send_type translate="label">
|
953 |
+
<label>Send Type</label>
|
954 |
+
<frontend_type>radios</frontend_type>
|
955 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
956 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
957 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
958 |
+
<sort_order>174</sort_order>
|
959 |
+
<show_in_default>1</show_in_default>
|
960 |
+
<show_in_website>1</show_in_website>
|
961 |
+
<show_in_store>1</show_in_store>
|
962 |
+
</sales_email-shipment_comment-guest_template_send_type>
|
963 |
+
|
964 |
+
<label_sales_email_creditmemo>
|
965 |
+
<label><![CDATA[##sales_email## Sales » Sales Emails » Credit Memo]]></label>
|
966 |
+
<frontend_type>label</frontend_type>
|
967 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
968 |
+
<sort_order>180</sort_order>
|
969 |
+
<show_in_default>1</show_in_default>
|
970 |
+
<show_in_website>1</show_in_website>
|
971 |
+
<show_in_store>1</show_in_store>
|
972 |
+
</label_sales_email_creditmemo>
|
973 |
+
<sales_email-creditmemo-template translate="label">
|
974 |
+
<label>Credit Memo Email Template</label>
|
975 |
+
<frontend_type>select</frontend_type>
|
976 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
977 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
978 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
979 |
+
<sort_order>181</sort_order>
|
980 |
+
<show_in_default>1</show_in_default>
|
981 |
+
<show_in_website>1</show_in_website>
|
982 |
+
<show_in_store>1</show_in_store>
|
983 |
+
</sales_email-creditmemo-template>
|
984 |
+
<sales_email-creditmemo-template_send_type translate="label">
|
985 |
+
<label>Send Type</label>
|
986 |
+
<frontend_type>radios</frontend_type>
|
987 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
988 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
989 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
990 |
+
<sort_order>182</sort_order>
|
991 |
+
<show_in_default>1</show_in_default>
|
992 |
+
<show_in_website>1</show_in_website>
|
993 |
+
<show_in_store>1</show_in_store>
|
994 |
+
</sales_email-creditmemo-template_send_type>
|
995 |
+
<sales_email-creditmemo-guest_template translate="label">
|
996 |
+
<label>Credit Memo Email Template for Guest</label>
|
997 |
+
<frontend_type>select</frontend_type>
|
998 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
999 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
1000 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
1001 |
+
<sort_order>183</sort_order>
|
1002 |
+
<show_in_default>1</show_in_default>
|
1003 |
+
<show_in_website>1</show_in_website>
|
1004 |
+
<show_in_store>1</show_in_store>
|
1005 |
+
</sales_email-creditmemo-guest_template>
|
1006 |
+
<sales_email-creditmemo-guest_template_send_type translate="label">
|
1007 |
+
<label>Send Type</label>
|
1008 |
+
<frontend_type>radios</frontend_type>
|
1009 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
1010 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
1011 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
1012 |
+
<sort_order>184</sort_order>
|
1013 |
+
<show_in_default>1</show_in_default>
|
1014 |
+
<show_in_website>1</show_in_website>
|
1015 |
+
<show_in_store>1</show_in_store>
|
1016 |
+
</sales_email-creditmemo-guest_template_send_type>
|
1017 |
+
|
1018 |
+
<label_sales_email_creditmemo_comment>
|
1019 |
+
<label><![CDATA[##sales_email## Sales » Sales Emails » Credit Memo Comments]]></label>
|
1020 |
+
<frontend_type>label</frontend_type>
|
1021 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
1022 |
+
<sort_order>190</sort_order>
|
1023 |
+
<show_in_default>1</show_in_default>
|
1024 |
+
<show_in_website>1</show_in_website>
|
1025 |
+
<show_in_store>1</show_in_store>
|
1026 |
+
</label_sales_email_creditmemo_comment>
|
1027 |
+
<sales_email-creditmemo_comment-template translate="label">
|
1028 |
+
<label>Credit Memo Comment Email Template</label>
|
1029 |
+
<frontend_type>select</frontend_type>
|
1030 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
1031 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
1032 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
1033 |
+
<sort_order>191</sort_order>
|
1034 |
+
<show_in_default>1</show_in_default>
|
1035 |
+
<show_in_website>1</show_in_website>
|
1036 |
+
<show_in_store>1</show_in_store>
|
1037 |
+
</sales_email-creditmemo_comment-template>
|
1038 |
+
<sales_email-creditmemo_comment-template_send_type translate="label">
|
1039 |
+
<label>Send Type</label>
|
1040 |
+
<frontend_type>radios</frontend_type>
|
1041 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
1042 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
1043 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
1044 |
+
<sort_order>192</sort_order>
|
1045 |
+
<show_in_default>1</show_in_default>
|
1046 |
+
<show_in_website>1</show_in_website>
|
1047 |
+
<show_in_store>1</show_in_store>
|
1048 |
+
</sales_email-creditmemo_comment-template_send_type>
|
1049 |
+
<sales_email-creditmemo_comment-guest_template translate="label">
|
1050 |
+
<label>Credit Memo Comment Email Template for Guest</label>
|
1051 |
+
<frontend_type>select</frontend_type>
|
1052 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
1053 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
1054 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
1055 |
+
<sort_order>193</sort_order>
|
1056 |
+
<show_in_default>1</show_in_default>
|
1057 |
+
<show_in_website>1</show_in_website>
|
1058 |
+
<show_in_store>1</show_in_store>
|
1059 |
+
</sales_email-creditmemo_comment-guest_template>
|
1060 |
+
<sales_email-creditmemo_comment-guest_template_send_type translate="label">
|
1061 |
+
<label>Send Type</label>
|
1062 |
+
<frontend_type>radios</frontend_type>
|
1063 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
1064 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
1065 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
1066 |
+
<sort_order>194</sort_order>
|
1067 |
+
<show_in_default>1</show_in_default>
|
1068 |
+
<show_in_website>1</show_in_website>
|
1069 |
+
<show_in_store>1</show_in_store>
|
1070 |
+
</sales_email-creditmemo_comment-guest_template_send_type>
|
1071 |
+
|
1072 |
+
<label_sales_email_enterprise_rma>
|
1073 |
+
<label><![CDATA[##sales_email## Sales » Sales Emails » RMA]]></label>
|
1074 |
+
<frontend_type>label</frontend_type>
|
1075 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
1076 |
+
<sort_order>200</sort_order>
|
1077 |
+
<show_in_default>1</show_in_default>
|
1078 |
+
<show_in_website>1</show_in_website>
|
1079 |
+
<show_in_store>1</show_in_store>
|
1080 |
+
</label_sales_email_enterprise_rma>
|
1081 |
+
<sales_email-enterprise_rma-template translate="label">
|
1082 |
+
<label>RMA Email Template</label>
|
1083 |
+
<frontend_type>select</frontend_type>
|
1084 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
1085 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
1086 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
1087 |
+
<sort_order>201</sort_order>
|
1088 |
+
<show_in_default>1</show_in_default>
|
1089 |
+
<show_in_website>1</show_in_website>
|
1090 |
+
<show_in_store>1</show_in_store>
|
1091 |
+
</sales_email-enterprise_rma-template>
|
1092 |
+
<sales_email-enterprise_rma-template_send_type translate="label">
|
1093 |
+
<label>Send Type</label>
|
1094 |
+
<frontend_type>radios</frontend_type>
|
1095 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
1096 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
1097 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
1098 |
+
<sort_order>202</sort_order>
|
1099 |
+
<show_in_default>1</show_in_default>
|
1100 |
+
<show_in_website>1</show_in_website>
|
1101 |
+
<show_in_store>1</show_in_store>
|
1102 |
+
</sales_email-enterprise_rma-template_send_type>
|
1103 |
+
<sales_email-enterprise_rma-guest_template translate="label">
|
1104 |
+
<label>RMA Email Template for Guest</label>
|
1105 |
+
<frontend_type>select</frontend_type>
|
1106 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
1107 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
1108 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
1109 |
+
<sort_order>203</sort_order>
|
1110 |
+
<show_in_default>1</show_in_default>
|
1111 |
+
<show_in_website>1</show_in_website>
|
1112 |
+
<show_in_store>1</show_in_store>
|
1113 |
+
</sales_email-enterprise_rma-guest_template>
|
1114 |
+
<sales_email-enterprise_rma-guest_template_send_type translate="label">
|
1115 |
+
<label>Send Type</label>
|
1116 |
+
<frontend_type>radios</frontend_type>
|
1117 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
1118 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
1119 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
1120 |
+
<sort_order>204</sort_order>
|
1121 |
+
<show_in_default>1</show_in_default>
|
1122 |
+
<show_in_website>1</show_in_website>
|
1123 |
+
<show_in_store>1</show_in_store>
|
1124 |
+
</sales_email-enterprise_rma-guest_template_send_type>
|
1125 |
+
|
1126 |
+
<label_sales_email_enterprise_rma_auth>
|
1127 |
+
<label><![CDATA[##sales_email## Sales » Sales Emails » RMA Authorization]]></label>
|
1128 |
+
<frontend_type>label</frontend_type>
|
1129 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
1130 |
+
<sort_order>210</sort_order>
|
1131 |
+
<show_in_default>1</show_in_default>
|
1132 |
+
<show_in_website>1</show_in_website>
|
1133 |
+
<show_in_store>1</show_in_store>
|
1134 |
+
</label_sales_email_enterprise_rma_auth>
|
1135 |
+
<sales_email-enterprise_rma_auth-template translate="label">
|
1136 |
+
<label>RMA Authorization Email Template</label>
|
1137 |
+
<frontend_type>select</frontend_type>
|
1138 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
1139 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
1140 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
1141 |
+
<sort_order>211</sort_order>
|
1142 |
+
<show_in_default>1</show_in_default>
|
1143 |
+
<show_in_website>1</show_in_website>
|
1144 |
+
<show_in_store>1</show_in_store>
|
1145 |
+
</sales_email-enterprise_rma_auth-template>
|
1146 |
+
<sales_email-enterprise_rma_auth-template_send_type translate="label">
|
1147 |
+
<label>Send Type</label>
|
1148 |
+
<frontend_type>radios</frontend_type>
|
1149 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
1150 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
1151 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
1152 |
+
<sort_order>212</sort_order>
|
1153 |
+
<show_in_default>1</show_in_default>
|
1154 |
+
<show_in_website>1</show_in_website>
|
1155 |
+
<show_in_store>1</show_in_store>
|
1156 |
+
</sales_email-enterprise_rma_auth-template_send_type>
|
1157 |
+
<sales_email-enterprise_rma_auth-guest_template translate="label">
|
1158 |
+
<label>RMA Authorization Email Template for Guest</label>
|
1159 |
+
<frontend_type>select</frontend_type>
|
1160 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
1161 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
1162 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
1163 |
+
<sort_order>213</sort_order>
|
1164 |
+
<show_in_default>1</show_in_default>
|
1165 |
+
<show_in_website>1</show_in_website>
|
1166 |
+
<show_in_store>1</show_in_store>
|
1167 |
+
</sales_email-enterprise_rma_auth-guest_template>
|
1168 |
+
<sales_email-enterprise_rma_auth-guest_template_send_type translate="label">
|
1169 |
+
<label>Send Type</label>
|
1170 |
+
<frontend_type>radios</frontend_type>
|
1171 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
1172 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
1173 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
1174 |
+
<sort_order>214</sort_order>
|
1175 |
+
<show_in_default>1</show_in_default>
|
1176 |
+
<show_in_website>1</show_in_website>
|
1177 |
+
<show_in_store>1</show_in_store>
|
1178 |
+
</sales_email-enterprise_rma_auth-guest_template_send_type>
|
1179 |
+
|
1180 |
+
<label_sales_email_enterprise_rma_comment>
|
1181 |
+
<label><![CDATA[##sales_email## Sales » Sales Emails » RMA Admin Comments]]></label>
|
1182 |
+
<frontend_type>label</frontend_type>
|
1183 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
1184 |
+
<sort_order>220</sort_order>
|
1185 |
+
<show_in_default>1</show_in_default>
|
1186 |
+
<show_in_website>1</show_in_website>
|
1187 |
+
<show_in_store>1</show_in_store>
|
1188 |
+
</label_sales_email_enterprise_rma_comment>
|
1189 |
+
<sales_email-enterprise_rma_comment-template translate="label">
|
1190 |
+
<label>RMA Comment Email Template</label>
|
1191 |
+
<frontend_type>select</frontend_type>
|
1192 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
1193 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
1194 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
1195 |
+
<sort_order>221</sort_order>
|
1196 |
+
<show_in_default>1</show_in_default>
|
1197 |
+
<show_in_website>1</show_in_website>
|
1198 |
+
<show_in_store>1</show_in_store>
|
1199 |
+
</sales_email-enterprise_rma_comment-template>
|
1200 |
+
<sales_email-enterprise_rma_comment-template_send_type translate="label">
|
1201 |
+
<label>Send Type</label>
|
1202 |
+
<frontend_type>radios</frontend_type>
|
1203 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
1204 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
1205 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
1206 |
+
<sort_order>222</sort_order>
|
1207 |
+
<show_in_default>1</show_in_default>
|
1208 |
+
<show_in_website>1</show_in_website>
|
1209 |
+
<show_in_store>1</show_in_store>
|
1210 |
+
</sales_email-enterprise_rma_comment-template_send_type>
|
1211 |
+
<sales_email-enterprise_rma_comment-guest_template translate="label">
|
1212 |
+
<label>RMA Comment Email Template for Guest</label>
|
1213 |
+
<frontend_type>select</frontend_type>
|
1214 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
1215 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
1216 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
1217 |
+
<sort_order>223</sort_order>
|
1218 |
+
<show_in_default>1</show_in_default>
|
1219 |
+
<show_in_website>1</show_in_website>
|
1220 |
+
<show_in_store>1</show_in_store>
|
1221 |
+
</sales_email-enterprise_rma_comment-guest_template>
|
1222 |
+
<sales_email-enterprise_rma_comment-guest_template_send_type translate="label">
|
1223 |
+
<label>Send Type</label>
|
1224 |
+
<frontend_type>radios</frontend_type>
|
1225 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
1226 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
1227 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
1228 |
+
<sort_order>224</sort_order>
|
1229 |
+
<show_in_default>1</show_in_default>
|
1230 |
+
<show_in_website>1</show_in_website>
|
1231 |
+
<show_in_store>1</show_in_store>
|
1232 |
+
</sales_email-enterprise_rma_comment-guest_template_send_type>
|
1233 |
+
|
1234 |
+
<label_sales_email_enterprise_rma_customer_comment>
|
1235 |
+
<label><![CDATA[##sales_email## Sales » Sales Emails » RMA Customer Comments]]></label>
|
1236 |
+
<frontend_type>label</frontend_type>
|
1237 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
1238 |
+
<sort_order>230</sort_order>
|
1239 |
+
<show_in_default>1</show_in_default>
|
1240 |
+
<show_in_website>1</show_in_website>
|
1241 |
+
<show_in_store>1</show_in_store>
|
1242 |
+
</label_sales_email_enterprise_rma_customer_comment>
|
1243 |
+
<sales_email-enterprise_rma_customer_comment-template translate="label">
|
1244 |
+
<label>RMA Comment Email Template</label>
|
1245 |
+
<frontend_type>select</frontend_type>
|
1246 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
1247 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
1248 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
1249 |
+
<sort_order>231</sort_order>
|
1250 |
+
<show_in_default>1</show_in_default>
|
1251 |
+
<show_in_website>1</show_in_website>
|
1252 |
+
<show_in_store>1</show_in_store>
|
1253 |
+
</sales_email-enterprise_rma_customer_comment-template>
|
1254 |
+
<sales_email-enterprise_rma_customer_comment-template_send_type translate="label">
|
1255 |
+
<label>Send Type</label>
|
1256 |
+
<frontend_type>radios</frontend_type>
|
1257 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
1258 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
1259 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
1260 |
+
<sort_order>232</sort_order>
|
1261 |
+
<show_in_default>1</show_in_default>
|
1262 |
+
<show_in_website>1</show_in_website>
|
1263 |
+
<show_in_store>1</show_in_store>
|
1264 |
+
</sales_email-enterprise_rma_customer_comment-template_send_type>
|
1265 |
+
<sales_email-enterprise_rma_customer_comment-guest_template translate="label">
|
1266 |
+
<label>RMA Comment Email Template for Guest</label>
|
1267 |
+
<frontend_type>select</frontend_type>
|
1268 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
1269 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
1270 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
1271 |
+
<sort_order>233</sort_order>
|
1272 |
+
<show_in_default>1</show_in_default>
|
1273 |
+
<show_in_website>1</show_in_website>
|
1274 |
+
<show_in_store>1</show_in_store>
|
1275 |
+
</sales_email-enterprise_rma_customer_comment-guest_template>
|
1276 |
+
<sales_email-enterprise_rma_customer_comment-guest_template_send_type translate="label">
|
1277 |
+
<label>Send Type</label>
|
1278 |
+
<frontend_type>radios</frontend_type>
|
1279 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
1280 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
1281 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
1282 |
+
<sort_order>234</sort_order>
|
1283 |
+
<show_in_default>1</show_in_default>
|
1284 |
+
<show_in_website>1</show_in_website>
|
1285 |
+
<show_in_store>1</show_in_store>
|
1286 |
+
</sales_email-enterprise_rma_customer_comment-guest_template_send_type>
|
1287 |
+
|
1288 |
+
<label_sales_checkout_payment_failed>
|
1289 |
+
<label><![CDATA[##checkout## Sales » Checkout » Payment Failed Emails]]></label>
|
1290 |
+
<frontend_type>label</frontend_type>
|
1291 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
1292 |
+
<sort_order>240</sort_order>
|
1293 |
+
<show_in_default>1</show_in_default>
|
1294 |
+
<show_in_website>1</show_in_website>
|
1295 |
+
<show_in_store>1</show_in_store>
|
1296 |
+
</label_sales_checkout_payment_failed>
|
1297 |
+
<checkout-payment_failed-template translate="label">
|
1298 |
+
<label>Payment Failed Template</label>
|
1299 |
+
<frontend_type>select</frontend_type>
|
1300 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
1301 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
1302 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
1303 |
+
<sort_order>241</sort_order>
|
1304 |
+
<show_in_default>1</show_in_default>
|
1305 |
+
<show_in_website>1</show_in_website>
|
1306 |
+
<show_in_store>1</show_in_store>
|
1307 |
+
</checkout-payment_failed-template>
|
1308 |
+
<checkout-payment_failed-template_send_type translate="label">
|
1309 |
+
<label>Send Type</label>
|
1310 |
+
<frontend_type>radios</frontend_type>
|
1311 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
1312 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
1313 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
1314 |
+
<sort_order>242</sort_order>
|
1315 |
+
<show_in_default>1</show_in_default>
|
1316 |
+
<show_in_website>1</show_in_website>
|
1317 |
+
<show_in_store>1</show_in_store>
|
1318 |
+
</checkout-payment_failed-template_send_type>
|
1319 |
+
|
1320 |
+
<label_admin_forgot_password>
|
1321 |
+
<label><![CDATA[##admin## Advanced » Admin » Admin User Emails]]></label>
|
1322 |
+
<frontend_type>label</frontend_type>
|
1323 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_label</frontend_model>
|
1324 |
+
<sort_order>250</sort_order>
|
1325 |
+
<show_in_default>1</show_in_default>
|
1326 |
+
<show_in_website>1</show_in_website>
|
1327 |
+
<show_in_store>1</show_in_store>
|
1328 |
+
</label_admin_forgot_password>
|
1329 |
+
<admin-emails-forgot_email_template translate="label">
|
1330 |
+
<label>Forgot Password Email Template</label>
|
1331 |
+
<frontend_type>select</frontend_type>
|
1332 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_field</frontend_model>
|
1333 |
+
<backend_model>bronto_email/system_config_backend_templates_field</backend_model>
|
1334 |
+
<source_model>bronto_email/system_config_source_email_template</source_model>
|
1335 |
+
<sort_order>251</sort_order>
|
1336 |
+
<show_in_default>1</show_in_default>
|
1337 |
+
<show_in_website>1</show_in_website>
|
1338 |
+
<show_in_store>1</show_in_store>
|
1339 |
+
</admin-emails-forgot_email_template>
|
1340 |
+
<admin-emails-forgot_email_template_send_type translate="label">
|
1341 |
+
<label>Send Type</label>
|
1342 |
+
<frontend_type>radios</frontend_type>
|
1343 |
+
<frontend_model>bronto_email/adminhtml_system_config_templates_sendtype</frontend_model>
|
1344 |
+
<backend_model>bronto_email/system_config_backend_templates_sendtype</backend_model>
|
1345 |
+
<source_model>bronto_email/system_config_source_sendtype</source_model>
|
1346 |
+
<sort_order>252</sort_order>
|
1347 |
+
<show_in_default>1</show_in_default>
|
1348 |
+
<show_in_website>1</show_in_website>
|
1349 |
+
<show_in_store>1</show_in_store>
|
1350 |
+
</admin-emails-forgot_email_template_send_type>
|
1351 |
+
</fields>-->
|
1352 |
+
</templates>
|
1353 |
</groups>
|
1354 |
</bronto_email>
|
1355 |
</sections>
|
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.1.2.php
CHANGED
@@ -68,7 +68,7 @@ try {
|
|
68 |
");
|
69 |
|
70 |
} catch (Exception $e) {
|
71 |
-
|
72 |
}
|
73 |
|
74 |
$installer->endSetup();
|
68 |
");
|
69 |
|
70 |
} catch (Exception $e) {
|
71 |
+
Mage::log($e->getMessage());
|
72 |
}
|
73 |
|
74 |
$installer->endSetup();
|
app/code/community/Bronto/Email/sql/bronto_email_setup/mysql4-install-1.1.7.php
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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-upgrade-1.1.1-1.1.2.php
CHANGED
@@ -14,7 +14,7 @@ try {
|
|
14 |
");
|
15 |
|
16 |
} catch (Exception $e) {
|
17 |
-
|
18 |
}
|
19 |
|
20 |
$installer->endSetup();
|
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
ADDED
@@ -0,0 +1,63 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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/News/Block/Adminhtml/ItemRender.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
return $this->assign($vars)->toHtml();
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Bronto/News/Block/Adminhtml/Redirect.php
ADDED
@@ -0,0 +1,26 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
return $this;
|
20 |
+
}
|
21 |
+
|
22 |
+
public function getRedirectUrl()
|
23 |
+
{
|
24 |
+
return $this->_url;
|
25 |
+
}
|
26 |
+
}
|
app/code/community/Bronto/News/Block/Adminhtml/System/Config/About.php
ADDED
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,141 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 type
|
13 |
+
*/
|
14 |
+
protected $_renderer;
|
15 |
+
|
16 |
+
/**
|
17 |
+
* @var Varien_Object
|
18 |
+
*/
|
19 |
+
protected $_itemDefinition;
|
20 |
+
|
21 |
+
/**
|
22 |
+
* @return Bronto_News_Model_Resource_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 |
+
return $this->_helper;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* @param Mage_Core_Helper_Abstract $helper
|
39 |
+
* @return Bronto_News_Block_Adminhtml_System_Config_News
|
40 |
+
*/
|
41 |
+
public function setHelper(Mage_Core_Helper_Abstract $helper)
|
42 |
+
{
|
43 |
+
$this->_helper = $helper;
|
44 |
+
return $this;
|
45 |
+
}
|
46 |
+
|
47 |
+
/**
|
48 |
+
* @return type
|
49 |
+
*/
|
50 |
+
protected function _getRenderer()
|
51 |
+
{
|
52 |
+
if (is_null($this->_renderer)) {
|
53 |
+
$this->_renderer = Mage::getBlockSingleton('bronto_news/adminhtml_itemRender');
|
54 |
+
}
|
55 |
+
return $this->_renderer;
|
56 |
+
}
|
57 |
+
|
58 |
+
/**
|
59 |
+
* @return Varien_Object
|
60 |
+
*/
|
61 |
+
protected function _getItemDefinition()
|
62 |
+
{
|
63 |
+
if (is_null($this->_item)) {
|
64 |
+
$this->_itemDefinition = new Varien_Object(array(
|
65 |
+
'frontend_type' => 'link',
|
66 |
+
'show_in_default' => 1,
|
67 |
+
'show_in_website' => 1,
|
68 |
+
'show_in_store' => 1,
|
69 |
+
));
|
70 |
+
}
|
71 |
+
|
72 |
+
return $this->_itemDefinition;
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* @param Varien_Data_Form_Element_Fieldset $fieldset
|
77 |
+
* @param Bronto_News_Model_Item $item
|
78 |
+
* @return Varien_Data_Form_Element_Abstract
|
79 |
+
*/
|
80 |
+
protected function addItemToFieldset($fieldset, $item)
|
81 |
+
{
|
82 |
+
$field = $fieldset->addField($item->getId(), 'link', array(
|
83 |
+
'value' => $item->getTitle(),
|
84 |
+
'title' => $item->getTitle(),
|
85 |
+
'href' => $item->getLink(),
|
86 |
+
'news_item' => $item,
|
87 |
+
'target' => '_blank',
|
88 |
+
'field_config' => $this->_getItemDefinition(),
|
89 |
+
));
|
90 |
+
|
91 |
+
return $field;
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
96 |
+
* @return string
|
97 |
+
*/
|
98 |
+
public function render(Varien_Data_Form_Element_Abstract $element)
|
99 |
+
{
|
100 |
+
$helper = $this->_getHelper();
|
101 |
+
|
102 |
+
if (!$helper->validApiToken()) {
|
103 |
+
// Route to API token
|
104 |
+
$url = $helper->getScopeUrl('*/system_config/edit', array(
|
105 |
+
'section' => 'bronto'
|
106 |
+
));
|
107 |
+
|
108 |
+
$element->setComment("In order to receive <strong>{$element->getLegend()}</strong>, you must enter a valid <a href=\"{$url}\">API Token</a>.");
|
109 |
+
} else {
|
110 |
+
foreach ($this->_pullRssItems() as $rssItem) {
|
111 |
+
$this
|
112 |
+
->addItemToFieldset($element, $rssItem)
|
113 |
+
->setRenderer($this->_getRenderer());
|
114 |
+
}
|
115 |
+
}
|
116 |
+
|
117 |
+
return parent::render($element);
|
118 |
+
}
|
119 |
+
|
120 |
+
/**
|
121 |
+
* @see parent
|
122 |
+
* @return string
|
123 |
+
*/
|
124 |
+
protected function _getHeaderHtml($element)
|
125 |
+
{
|
126 |
+
$html = parent::_getHeaderHtml($element);
|
127 |
+
$tableIndex = strpos($html, '<table');
|
128 |
+
return substr($html, 0, $tableIndex);
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* @see parent
|
133 |
+
* @return string
|
134 |
+
*/
|
135 |
+
protected function _getFooterHtml($element)
|
136 |
+
{
|
137 |
+
$html = parent::_getFooterHtml($element);
|
138 |
+
$fieldsetIndex = strpos($html, '</fieldset');
|
139 |
+
return substr($html, $fieldsetIndex);
|
140 |
+
}
|
141 |
+
}
|
app/code/community/Bronto/News/Block/Adminhtml/System/Config/Releases.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,208 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
class Bronto_News_Helper_Data extends Bronto_Common_Helper_Data
|
4 |
+
{
|
5 |
+
|
6 |
+
const XML_PATH_FEEDS = 'bronto_news/feeds';
|
7 |
+
|
8 |
+
/**
|
9 |
+
* @var Varien_Http_Adapter_Curl
|
10 |
+
*/
|
11 |
+
protected $_xmlProvider;
|
12 |
+
|
13 |
+
/**
|
14 |
+
* @var Zend_Http_Client
|
15 |
+
*/
|
16 |
+
protected $_client;
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Gets the RSS item threshold
|
20 |
+
*
|
21 |
+
* @return int
|
22 |
+
*/
|
23 |
+
public function getThreshold()
|
24 |
+
{
|
25 |
+
return (int)$this->getAdminScopedConfig(self::XML_PATH_FEEDS . '/threshold');
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Gets the release announcements RSS url
|
30 |
+
*
|
31 |
+
* @return string
|
32 |
+
*/
|
33 |
+
public function getReleaseUrl()
|
34 |
+
{
|
35 |
+
$path = self::XML_PATH_FEEDS . '/' . Bronto_News_Model_Item::TYPE_RELEASE;
|
36 |
+
return $this->getAdminScopedConfig($path);
|
37 |
+
}
|
38 |
+
|
39 |
+
/**
|
40 |
+
* Gets the general feed RSS url
|
41 |
+
*
|
42 |
+
* @return string
|
43 |
+
*/
|
44 |
+
public function getGeneralUrl()
|
45 |
+
{
|
46 |
+
$path = self::XML_PATH_FEEDS . '/' . Bronto_News_Model_Item::TYPE_GENERAL;
|
47 |
+
return $this->getAdminScopedConfig($path);
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* Sets the XML provider to be used in conjuction with SimpleXMLElement
|
52 |
+
*
|
53 |
+
* @param Varien_Http_Adapter_Curl $provider
|
54 |
+
* @return Bronto_Common_Helper_Data
|
55 |
+
*/
|
56 |
+
public function setXmlProvider(Varien_Http_Adapter_Curl $provider)
|
57 |
+
{
|
58 |
+
if (is_null($this->_client)) {
|
59 |
+
$this->_client = new Zend_Http_Client();
|
60 |
+
}
|
61 |
+
|
62 |
+
$this->_xmlProvider = $provider;
|
63 |
+
$this->_client->setAdapter($provider);
|
64 |
+
return $this;
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* Given a url, use the provider to pull from the url
|
69 |
+
*
|
70 |
+
* @return string
|
71 |
+
*/
|
72 |
+
protected function _getXml($url)
|
73 |
+
{
|
74 |
+
if (is_null($this->_xmlProvider)) {
|
75 |
+
$this->setXmlProvider(new Varien_Http_Adapter_Curl());
|
76 |
+
}
|
77 |
+
|
78 |
+
$this->_client->setUri($url ? $url : 'http');
|
79 |
+
$response = $this->_client->request(Zend_Http_Client::GET);
|
80 |
+
return $response->getBody();
|
81 |
+
}
|
82 |
+
|
83 |
+
/**
|
84 |
+
* Is this is the first time? (ie: no RSS items in DB)
|
85 |
+
*
|
86 |
+
* @return boolean
|
87 |
+
*/
|
88 |
+
public function isFirstTime()
|
89 |
+
{
|
90 |
+
return Mage::getModel('bronto_news/item')->getCollection()->count() === 0;
|
91 |
+
}
|
92 |
+
|
93 |
+
/**
|
94 |
+
* Processes the RSS feed based on type and url
|
95 |
+
*
|
96 |
+
* @param string $type
|
97 |
+
* @param string $url
|
98 |
+
* @param boolean $silence
|
99 |
+
* @throws RuntimeException
|
100 |
+
*/
|
101 |
+
protected function _processItems($type, $url, $silence)
|
102 |
+
{
|
103 |
+
// We want to report on XML parsing errors
|
104 |
+
$previousValue = libxml_use_internal_errors(true);
|
105 |
+
|
106 |
+
try {
|
107 |
+
$date = Mage::getModel('core/date');
|
108 |
+
$xml = new SimpleXMLElement($this->_getXml($url));
|
109 |
+
|
110 |
+
foreach ($xml->channel->item as $item) {
|
111 |
+
$guid = (string)$item->guid;
|
112 |
+
$description = (string)$item->description;
|
113 |
+
$formattedDate = strtotime((string)$item->pubDate);
|
114 |
+
|
115 |
+
// Attempts to load the RSS feed
|
116 |
+
$rssItem = Mage::getModel('bronto_news/item')->load($guid, 'link');
|
117 |
+
|
118 |
+
// Silence the alert if this rss item already exists
|
119 |
+
$rssItem
|
120 |
+
->setSilence($silence ? $silence : $rssItem->hasLink())
|
121 |
+
->setTitle((string)$item->title)
|
122 |
+
->setDescription(current(explode('--', $description)))
|
123 |
+
->setPubDate($date->date('Y-m-d H:m:s', $formattedDate))
|
124 |
+
->setLink($guid)
|
125 |
+
->setType($type)
|
126 |
+
->save();
|
127 |
+
|
128 |
+
$this->writeDebug("Processed [$type] item: {$item->title}");
|
129 |
+
}
|
130 |
+
} catch (Exception $e) {
|
131 |
+
$exception = new RuntimeException("Failed to pull RSS for $type announcements.");
|
132 |
+
$this->writeError($e->getMessage());
|
133 |
+
$this->writeError("Failed processing $url:\n{$e->getTraceAsString()}");
|
134 |
+
}
|
135 |
+
|
136 |
+
// Would be great in a finally block
|
137 |
+
libxml_use_internal_errors($previousValue);
|
138 |
+
|
139 |
+
if (isset($exception)) {
|
140 |
+
throw $exception;
|
141 |
+
}
|
142 |
+
}
|
143 |
+
|
144 |
+
/**
|
145 |
+
* Pulls the RSS information, creating announcements as necessary
|
146 |
+
*/
|
147 |
+
public function pullNewItems()
|
148 |
+
{
|
149 |
+
$urls = array(
|
150 |
+
Bronto_News_Model_Item::TYPE_RELEASE => $this->getReleaseUrl(),
|
151 |
+
Bronto_News_Model_Item::TYPE_GENERAL => $this->getGeneralUrl(),
|
152 |
+
);
|
153 |
+
|
154 |
+
if ($firstTime = $this->isFirstTime()) {
|
155 |
+
try {
|
156 |
+
Mage::getModel('bronto_news/item')
|
157 |
+
->setTitle('Thank you for installing the Bronto Extension for Magento. Please visit our resource center for full documentation and release notes.')
|
158 |
+
->setDescription('Please click on the Read Details link to be redirected to the resource center.')
|
159 |
+
->setLink('http://a.bron.to/magento')
|
160 |
+
->setType(Bronto_News_Model_Item::TYPE_OTHER)
|
161 |
+
->setPubDate(Mage::getModel('core/date')->date('Y-m-s H:m:s'))
|
162 |
+
->save();
|
163 |
+
} catch (Exception $e) {
|
164 |
+
$this->writeError('Could not create initial announcement');
|
165 |
+
}
|
166 |
+
}
|
167 |
+
|
168 |
+
foreach ($urls as $type => $url) {
|
169 |
+
$this->writeDebug("Processing $type RSS feed at $url");
|
170 |
+
$this->_processItems($type, $url, $firstTime);
|
171 |
+
}
|
172 |
+
}
|
173 |
+
|
174 |
+
/**
|
175 |
+
* Wraps the internal notification URL with a controller route to
|
176 |
+
* mark the notification as read
|
177 |
+
*
|
178 |
+
* @param Bronto_News_Model_Item $item
|
179 |
+
* @return string
|
180 |
+
*/
|
181 |
+
protected function wrapNotificationUrl(Bronto_News_Model_Item $item)
|
182 |
+
{
|
183 |
+
return Mage::app()->getStore()
|
184 |
+
->getUrl('announcement/route/index', array('item' => $item->getId()));
|
185 |
+
}
|
186 |
+
|
187 |
+
/**
|
188 |
+
* Creates an in-app Magento announcement
|
189 |
+
*
|
190 |
+
* @param Bronto_News_Model_Item $item
|
191 |
+
*/
|
192 |
+
public function createAnnouncement(Bronto_News_Model_Item $item)
|
193 |
+
{
|
194 |
+
if ($item->isAlert()) {
|
195 |
+
$notice = Mage::getModel('adminnotification/inbox')
|
196 |
+
->setSeverity(Mage_Adminnotification_Model_Inbox::SEVERITY_NOTICE)
|
197 |
+
->setTitle($item->getAlertTitle())
|
198 |
+
->setDescription($item->getDescription())
|
199 |
+
->setUrl($this->wrapNotificationUrl($item))
|
200 |
+
->save();
|
201 |
+
|
202 |
+
$item
|
203 |
+
->setSilence(true)
|
204 |
+
->setNotificationId($notice->getId())
|
205 |
+
->save();
|
206 |
+
}
|
207 |
+
}
|
208 |
+
}
|
app/code/community/Bronto/News/Model/Item.php
ADDED
@@ -0,0 +1,139 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @return Bronto_News_Model_Item
|
20 |
+
*/
|
21 |
+
public function setHelper(Mage_Core_Helper_Abstract $helper)
|
22 |
+
{
|
23 |
+
$this->_helper = $helper;
|
24 |
+
return $this;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Gets the helper used for this model
|
29 |
+
*
|
30 |
+
* @return Mage_Core_Helper_Abstract
|
31 |
+
*/
|
32 |
+
protected function _getHelper()
|
33 |
+
{
|
34 |
+
if (is_null($this->_helper)) {
|
35 |
+
$this->setHelper(Mage::helper('bronto_news'));
|
36 |
+
}
|
37 |
+
|
38 |
+
return $this->_helper;
|
39 |
+
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* @see parent
|
43 |
+
*/
|
44 |
+
public function _construct()
|
45 |
+
{
|
46 |
+
parent::_construct();
|
47 |
+
$this->_init('bronto_news/item');
|
48 |
+
}
|
49 |
+
|
50 |
+
/**
|
51 |
+
* @see parent
|
52 |
+
*/
|
53 |
+
public function afterCommitCallback()
|
54 |
+
{
|
55 |
+
parent::afterCommitCallback();
|
56 |
+
if (!$this->getSilence()) {
|
57 |
+
$this->_getHelper()->createAnnouncement($this);
|
58 |
+
}
|
59 |
+
return $this;
|
60 |
+
}
|
61 |
+
|
62 |
+
/**
|
63 |
+
* Is this RSS item an alert item
|
64 |
+
*
|
65 |
+
* @return boolean
|
66 |
+
*/
|
67 |
+
public function isAlert()
|
68 |
+
{
|
69 |
+
return (
|
70 |
+
$this->getType() != self::TYPE_GENERAL ||
|
71 |
+
preg_match('/^\[?ALERT\]?/i', $this->getTitle())
|
72 |
+
);
|
73 |
+
}
|
74 |
+
|
75 |
+
/**
|
76 |
+
* Returns the "Magento Alert title" for the given notification
|
77 |
+
*
|
78 |
+
* @return string
|
79 |
+
*/
|
80 |
+
public function getAlertTitle()
|
81 |
+
{
|
82 |
+
return "[Bronto Alert] {$this->getTitle()}";
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Marks all alerts as read
|
87 |
+
*
|
88 |
+
* @return Bronto_News_Model_Item
|
89 |
+
*/
|
90 |
+
public function markAlertAsRead()
|
91 |
+
{
|
92 |
+
$notification = Mage::getModel('adminnotification/inbox')
|
93 |
+
->load($this->getNotificationId(), 'notification_id');
|
94 |
+
|
95 |
+
if ($notification->hasNotificationId()) {
|
96 |
+
$notification->setIsRead(1)->save();
|
97 |
+
}
|
98 |
+
|
99 |
+
return $this;
|
100 |
+
}
|
101 |
+
|
102 |
+
/**
|
103 |
+
* Returns a collection of RSS items based on type
|
104 |
+
*
|
105 |
+
* @param string $type
|
106 |
+
* @return Mage_Core_Model_Resource_Db_Collection_Abstract
|
107 |
+
*/
|
108 |
+
public function getItemsOfType($type)
|
109 |
+
{
|
110 |
+
return $this
|
111 |
+
->getCollection()
|
112 |
+
->addFieldToFilter('type', $type)
|
113 |
+
->orderByMostRecent();
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Returns the most recent, limited release notes
|
118 |
+
*
|
119 |
+
* @return Mage_Core_Model_Resource_Db_Collection_Abstract
|
120 |
+
*/
|
121 |
+
public function getLimitedReleaseNotes()
|
122 |
+
{
|
123 |
+
return $this
|
124 |
+
->getItemsOfType(self::TYPE_RELEASE)
|
125 |
+
->setPageSize($this->_getHelper()->getThreshold());
|
126 |
+
}
|
127 |
+
|
128 |
+
/**
|
129 |
+
* Returns the most recent, limited general notes
|
130 |
+
*
|
131 |
+
* @return Mage_Core_Model_Resource_Db_Collection_Abstract
|
132 |
+
*/
|
133 |
+
public function getLimitedGeneralNotes()
|
134 |
+
{
|
135 |
+
return $this
|
136 |
+
->getItemsOfType(self::TYPE_GENERAL)
|
137 |
+
->setPageSize($this->_getHelper()->getThreshold());
|
138 |
+
}
|
139 |
+
}
|
app/code/community/Bronto/News/Model/Mysql4/Item.php
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
* @return Bronto_News_Model_Observer
|
16 |
+
*/
|
17 |
+
public function setHelper(Mage_Core_Helper_Abstract $helper)
|
18 |
+
{
|
19 |
+
$this->_helper = $helper;
|
20 |
+
return $this;
|
21 |
+
}
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Gets the helper cached on this request
|
25 |
+
*
|
26 |
+
* @return Mage_Core_Helper_Abstract
|
27 |
+
*/
|
28 |
+
protected function _getHelper()
|
29 |
+
{
|
30 |
+
if (is_null($this->_helper)) {
|
31 |
+
$this->setHelper(Mage::helper('bronto_news'));
|
32 |
+
}
|
33 |
+
|
34 |
+
return $this->_helper;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Forwards call to helper class
|
39 |
+
*/
|
40 |
+
public function pullNewItems()
|
41 |
+
{
|
42 |
+
$helper = $this->_getHelper();
|
43 |
+
|
44 |
+
if ($helper->validApiToken()) {
|
45 |
+
try {
|
46 |
+
$helper->pullNewItems();
|
47 |
+
} catch (Exception $e) {
|
48 |
+
$helper->writeError('Failed pulling items.');
|
49 |
+
}
|
50 |
+
}
|
51 |
+
}
|
52 |
+
}
|
app/code/community/Bronto/News/Model/Resource/Setup.php
ADDED
@@ -0,0 +1,36 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
return false;
|
23 |
+
}
|
24 |
+
|
25 |
+
return true;
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Load the inital config data for the module
|
30 |
+
*/
|
31 |
+
public function loadInitialSettings()
|
32 |
+
{
|
33 |
+
Mage::getConfig()->reinit();
|
34 |
+
Mage::app()->reinitStores();
|
35 |
+
}
|
36 |
+
}
|
app/code/community/Bronto/News/controllers/Adminhtml/AnnouncementController.php
ADDED
@@ -0,0 +1,52 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
return $this->_helper;
|
20 |
+
}
|
21 |
+
|
22 |
+
/**
|
23 |
+
* @param Mage_Core_Helper_Abstract $helper
|
24 |
+
* @return Bronto_News_Adminhtml_RefreshController
|
25 |
+
*/
|
26 |
+
public function setHelper(Mage_Core_Helper_Abstract $helper)
|
27 |
+
{
|
28 |
+
$this->_helper = $helper;
|
29 |
+
return $this;
|
30 |
+
}
|
31 |
+
|
32 |
+
/**
|
33 |
+
* Refresh Feeds and send back to resquestUri
|
34 |
+
* Example: admin/announcement/refresh
|
35 |
+
*/
|
36 |
+
public function refreshAction()
|
37 |
+
{
|
38 |
+
$helper = $this->_getHelper();
|
39 |
+
$session = Mage::getSingleton('adminhtml/session');
|
40 |
+
|
41 |
+
try {
|
42 |
+
$helper->pullNewItems();
|
43 |
+
$session->addSuccess('Successfully refreshed Announcements & News.');
|
44 |
+
} catch (Exception $e) {
|
45 |
+
$helper->writeError($e->getMessage());
|
46 |
+
$helper->writeError($e->getTraceAsString());
|
47 |
+
$session->addError('Failed to refresh Announcements & News.');
|
48 |
+
}
|
49 |
+
|
50 |
+
$this->_redirectReferer();
|
51 |
+
}
|
52 |
+
}
|
app/code/community/Bronto/News/controllers/RouteController.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
return $this->_redirectUrl($link);
|
19 |
+
}
|
20 |
+
}
|
21 |
+
|
22 |
+
return $this->_redirectUrl('/');
|
23 |
+
}
|
24 |
+
}
|
app/code/community/Bronto/News/etc/adminhtml.xml
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<acl>
|
4 |
+
<resources>
|
5 |
+
<admin>
|
6 |
+
<children>
|
7 |
+
<system>
|
8 |
+
<children>
|
9 |
+
<config>
|
10 |
+
<children>
|
11 |
+
<bronto_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
ADDED
@@ -0,0 +1,116 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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&id=5jodwr23wmaolrs5mpw6gq91zofp0&fn=Link&ssid=30245</releases>
|
103 |
+
<general>http://app.bronto.com/public/?q=feed&id=bimy41imold5nrca83kyqcuvbtru9&fn=Link&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
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<sections>
|
4 |
+
<bronto_news module="bronto_news">
|
5 |
+
<label><![CDATA[Announcements & News]]></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
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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
CHANGED
@@ -10,15 +10,15 @@ class Bronto_Newsletter_Block_Adminhtml_System_Config_About extends Bronto_Commo
|
|
10 |
|
11 |
/**
|
12 |
* Description for protected
|
13 |
-
* @var string
|
14 |
* @access protected
|
15 |
*/
|
16 |
protected $_module = 'bronto_newsletter';
|
17 |
|
18 |
/**
|
19 |
* Description for protected
|
20 |
-
* @var string
|
21 |
* @access protected
|
22 |
*/
|
23 |
-
protected $_name
|
24 |
}
|
10 |
|
11 |
/**
|
12 |
* Description for protected
|
13 |
+
* @var string
|
14 |
* @access protected
|
15 |
*/
|
16 |
protected $_module = 'bronto_newsletter';
|
17 |
|
18 |
/**
|
19 |
* Description for protected
|
20 |
+
* @var string
|
21 |
* @access protected
|
22 |
*/
|
23 |
+
protected $_name = 'Bronto Contact Newsletter Sign-Up for Magento';
|
24 |
}
|
app/code/community/Bronto/Newsletter/Block/Adminhtml/System/Config/Cron.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
*/
|
8 |
class Bronto_Newsletter_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Block_Adminhtml_System_Config_Cron
|
9 |
{
|
10 |
-
protected $_jobCode
|
11 |
protected $_hasProgressBar = true;
|
12 |
|
13 |
/**
|
@@ -15,6 +15,7 @@ class Bronto_Newsletter_Block_Adminhtml_System_Config_Cron extends Bronto_Common
|
|
15 |
*/
|
16 |
protected function _prepareLayout()
|
17 |
{
|
|
|
18 |
$this->addButton($this->getLayout()->createBlock('bronto_newsletter/adminhtml_widget_button_reset'));
|
19 |
$this->addButton($this->getLayout()->createBlock('bronto_newsletter/adminhtml_widget_button_run'));
|
20 |
|
@@ -27,8 +28,7 @@ class Bronto_Newsletter_Block_Adminhtml_System_Config_Cron extends Bronto_Common
|
|
27 |
protected function getProgressBarTotal()
|
28 |
{
|
29 |
return $this->getNewsletterResourceCollection()
|
30 |
-
->getSize()
|
31 |
-
;
|
32 |
}
|
33 |
|
34 |
/**
|
@@ -38,8 +38,48 @@ class Bronto_Newsletter_Block_Adminhtml_System_Config_Cron extends Bronto_Common
|
|
38 |
{
|
39 |
return $this->getNewsletterResourceCollection()
|
40 |
->addBrontoNotImportedFilter()
|
41 |
-
->
|
42 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
43 |
}
|
44 |
|
45 |
/**
|
@@ -48,12 +88,12 @@ class Bronto_Newsletter_Block_Adminhtml_System_Config_Cron extends Bronto_Common
|
|
48 |
protected function getNewsletterResourceCollection()
|
49 |
{
|
50 |
$collection = Mage::getModel('bronto_newsletter/queue')->getCollection();
|
51 |
-
$storeIds
|
52 |
-
|
53 |
if ($storeIds) {
|
54 |
$collection->addStoreFilter($storeIds);
|
55 |
}
|
56 |
-
|
57 |
return $collection;
|
58 |
}
|
59 |
}
|
7 |
*/
|
8 |
class Bronto_Newsletter_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Block_Adminhtml_System_Config_Cron
|
9 |
{
|
10 |
+
protected $_jobCode = 'bronto_newsletter_import';
|
11 |
protected $_hasProgressBar = true;
|
12 |
|
13 |
/**
|
15 |
*/
|
16 |
protected function _prepareLayout()
|
17 |
{
|
18 |
+
$this->addButton($this->getLayout()->createBlock('bronto_newsletter/adminhtml_widget_button_sync'));
|
19 |
$this->addButton($this->getLayout()->createBlock('bronto_newsletter/adminhtml_widget_button_reset'));
|
20 |
$this->addButton($this->getLayout()->createBlock('bronto_newsletter/adminhtml_widget_button_run'));
|
21 |
|
28 |
protected function getProgressBarTotal()
|
29 |
{
|
30 |
return $this->getNewsletterResourceCollection()
|
31 |
+
->getSize();
|
|
|
32 |
}
|
33 |
|
34 |
/**
|
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 |
+
* @return int
|
59 |
+
*/
|
60 |
+
protected function getProgressBarDisabled()
|
61 |
+
{
|
62 |
+
$collection = Mage::getModel('bronto_newsletter/queue')->getCollection();
|
63 |
+
$storeIds = Mage::helper('bronto_newsletter')->getStoreIds();
|
64 |
+
|
65 |
+
if ($storeIds) {
|
66 |
+
if (!is_array($storeIds)) {
|
67 |
+
$storeIds = array($storeIds);
|
68 |
+
}
|
69 |
+
foreach ($storeIds as $key => $storeId) {
|
70 |
+
if (Mage::getStoreConfig(Bronto_Newsletter_Helper_Data::XML_PATH_ENABLED, $storeId)) {
|
71 |
+
unset($storeIds[$key]);
|
72 |
+
}
|
73 |
+
}
|
74 |
+
|
75 |
+
if (count($storeIds) > 0) {
|
76 |
+
$collection->addStoreFilter($storeIds);
|
77 |
+
|
78 |
+
return $collection->addBrontoNotImportedFilter()
|
79 |
+
->getSize();
|
80 |
+
}
|
81 |
+
}
|
82 |
+
return 0;
|
83 |
}
|
84 |
|
85 |
/**
|
88 |
protected function getNewsletterResourceCollection()
|
89 |
{
|
90 |
$collection = Mage::getModel('bronto_newsletter/queue')->getCollection();
|
91 |
+
$storeIds = Mage::helper('bronto_newsletter')->getStoreIds();
|
92 |
+
|
93 |
if ($storeIds) {
|
94 |
$collection->addStoreFilter($storeIds);
|
95 |
}
|
96 |
+
|
97 |
return $collection;
|
98 |
}
|
99 |
}
|
app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Reset.php
CHANGED
@@ -13,11 +13,14 @@ class Bronto_Newsletter_Block_Adminhtml_Widget_Button_Reset extends Mage_Adminht
|
|
13 |
protected function _construct()
|
14 |
{
|
15 |
$this->setLabel('Reset All Subscribers');
|
16 |
-
$this->setOnClick("deleteConfirm('This will mark all subscribers as not-imported and will cause the importer to re-process each subscriber again.\\n\\nAre you sure you want to do this?', '" . Mage::helper('
|
17 |
$this->setClass('delete');
|
18 |
|
19 |
-
if (!
|
20 |
$this->setDisabled(true)->setClass('disabled');
|
|
|
|
|
|
|
21 |
}
|
22 |
}
|
23 |
}
|
13 |
protected function _construct()
|
14 |
{
|
15 |
$this->setLabel('Reset All Subscribers');
|
16 |
+
$this->setOnClick("deleteConfirm('This will mark all subscribers as not-imported and will cause the importer to re-process each subscriber again.\\n\\nAre you sure you want to do this?', '" . Mage::helper('bronto_newsletter')->getScopeUrl('*/newsletter/reset') . "'); return false;");
|
17 |
$this->setClass('delete');
|
18 |
|
19 |
+
if (!Mage::helper('bronto_newsletter')->isModuleActive() || (!Mage::helper('bronto_newsletter')->isDebugEnabled() && !Mage::helper('bronto_newsletter')->isTestModeEnabled())) {
|
20 |
$this->setDisabled(true)->setClass('disabled');
|
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/Newsletter/Block/Adminhtml/Widget/Button/Run.php
CHANGED
@@ -12,15 +12,11 @@ class Bronto_Newsletter_Block_Adminhtml_Widget_Button_Run extends Mage_Adminhtml
|
|
12 |
*/
|
13 |
protected function _construct()
|
14 |
{
|
15 |
-
$params = array(
|
16 |
-
'section' => Mage::app()->getRequest()->getParam('section'),
|
17 |
-
'website' => Mage::app()->getRequest()->getParam('website'),
|
18 |
-
'store' => Mage::app()->getRequest()->getParam('store'),
|
19 |
-
);
|
20 |
$this->setLabel('Run Now');
|
21 |
-
$this->setOnClick("setLocation('" . Mage::helper('
|
22 |
|
23 |
-
|
|
|
24 |
$this->setDisabled(true)->setClass('disabled');
|
25 |
}
|
26 |
}
|
12 |
*/
|
13 |
protected function _construct()
|
14 |
{
|
|
|
|
|
|
|
|
|
|
|
15 |
$this->setLabel('Run Now');
|
16 |
+
$this->setOnClick("setLocation('" . Mage::helper('bronto_newsletter')->getScopeUrl('*/newsletter/run') . "'); return false;");
|
17 |
|
18 |
+
// Check to see if this module meets requirements
|
19 |
+
if (!Mage::helper('bronto_newsletter')->isModuleActive()) {
|
20 |
$this->setDisabled(true)->setClass('disabled');
|
21 |
}
|
22 |
}
|
app/code/community/Bronto/Newsletter/Block/Adminhtml/Widget/Button/Sync.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* @package Bronto\Newsletter
|
5 |
+
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
+
* @version 1.1.5
|
7 |
+
*/
|
8 |
+
class Bronto_Newsletter_Block_Adminhtml_Widget_Button_Sync extends Mage_Adminhtml_Block_Widget_Button
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Internal constructor not depended on params. Can be used for object initialization
|
12 |
+
*/
|
13 |
+
protected function _construct()
|
14 |
+
{
|
15 |
+
$this->setLabel($this->__('Sync Subscribers to Queue'));
|
16 |
+
$this->setOnClick("deleteConfirm('This will ensure all Magento subscribers are in the queue to import into Bronto\\n\\nThis is meant to be used when the subscriber count does not match the total number of subscriber in the Magento admin\\n\\nWould you like to continue?', '" . Mage::helper('bronto_newsletter')->getScopeUrl('*/newsletter/sync') . "'); return false;");
|
17 |
+
$this->setClass('save');
|
18 |
+
|
19 |
+
if (!Mage::helper('bronto_newsletter')->isModuleActive()) {
|
20 |
+
$this->setDisabled(true)->setClass('disabled');
|
21 |
+
}
|
22 |
+
}
|
23 |
+
}
|
app/code/community/Bronto/Newsletter/Block/Checkout/Onepage/Newsletter.php
CHANGED
@@ -46,7 +46,7 @@ class Bronto_Newsletter_Block_Checkout_Onepage_Newsletter extends Mage_Checkout_
|
|
46 |
{
|
47 |
return Mage::helper('bronto_newsletter')->isEnabledForRegisterCheckout();
|
48 |
}
|
49 |
-
|
50 |
/**
|
51 |
* @return bool
|
52 |
*/
|
@@ -69,11 +69,11 @@ class Bronto_Newsletter_Block_Checkout_Onepage_Newsletter extends Mage_Checkout_
|
|
69 |
*/
|
70 |
public function getCheckboxLabelText()
|
71 |
{
|
72 |
-
return Mage::helper('bronto_newsletter')->getCheckboxLabelText();
|
73 |
}
|
74 |
-
|
75 |
/**
|
76 |
-
*
|
77 |
* @param string $method
|
78 |
* @return string
|
79 |
*/
|
@@ -81,37 +81,37 @@ class Bronto_Newsletter_Block_Checkout_Onepage_Newsletter extends Mage_Checkout_
|
|
81 |
{
|
82 |
$js = "";
|
83 |
$methodName = 'isEnabledFor' . ucfirst($method) . 'Checkout';
|
84 |
-
|
85 |
// Default Values
|
86 |
-
$action
|
87 |
$checked = 'false';
|
88 |
-
$value
|
89 |
-
|
90 |
// If function exists, use it, otherwise we hide and disable values
|
91 |
if (method_exists($this, $methodName)) {
|
92 |
if ($this->$methodName()) {
|
93 |
-
$action
|
94 |
if ($this->isSubscribed() || $this->isEnabledCheckedByDefault()) {
|
95 |
$checked = 'true';
|
96 |
-
$value
|
97 |
}
|
98 |
}
|
99 |
}
|
100 |
-
|
101 |
// If user is subscribed and enabled if already subscribed is not allowed,
|
102 |
// Hide it, but set the values to true
|
103 |
if ($this->isSubscribed() && !$this->isEnabledIfAlreadySubscribed()) {
|
104 |
-
$action
|
105 |
$checked = 'true';
|
106 |
-
$value
|
107 |
}
|
108 |
-
|
109 |
// Create JS
|
110 |
-
$js.= "Element.{$action}('register-customer-newsletter');\r\n";
|
111 |
-
$js.= "$('billing:is_subscribed_box').checked = {$checked};\r\n";
|
112 |
-
$js.= "$('billing:is_subscribed').value = {$value};\r\n";
|
113 |
-
$js.= "$('billing:is_subscribed').value = {$value};\r\n";
|
114 |
-
|
115 |
return $js;
|
116 |
}
|
117 |
}
|
46 |
{
|
47 |
return Mage::helper('bronto_newsletter')->isEnabledForRegisterCheckout();
|
48 |
}
|
49 |
+
|
50 |
/**
|
51 |
* @return bool
|
52 |
*/
|
69 |
*/
|
70 |
public function getCheckboxLabelText()
|
71 |
{
|
72 |
+
return addslashes(Mage::helper('bronto_newsletter')->getCheckboxLabelText());
|
73 |
}
|
74 |
+
|
75 |
/**
|
76 |
+
*
|
77 |
* @param string $method
|
78 |
* @return string
|
79 |
*/
|
81 |
{
|
82 |
$js = "";
|
83 |
$methodName = 'isEnabledFor' . ucfirst($method) . 'Checkout';
|
84 |
+
|
85 |
// Default Values
|
86 |
+
$action = 'hide';
|
87 |
$checked = 'false';
|
88 |
+
$value = 'null';
|
89 |
+
|
90 |
// If function exists, use it, otherwise we hide and disable values
|
91 |
if (method_exists($this, $methodName)) {
|
92 |
if ($this->$methodName()) {
|
93 |
+
$action = 'show';
|
94 |
if ($this->isSubscribed() || $this->isEnabledCheckedByDefault()) {
|
95 |
$checked = 'true';
|
96 |
+
$value = '1';
|
97 |
}
|
98 |
}
|
99 |
}
|
100 |
+
|
101 |
// If user is subscribed and enabled if already subscribed is not allowed,
|
102 |
// Hide it, but set the values to true
|
103 |
if ($this->isSubscribed() && !$this->isEnabledIfAlreadySubscribed()) {
|
104 |
+
$action = 'hide';
|
105 |
$checked = 'true';
|
106 |
+
$value = '1';
|
107 |
}
|
108 |
+
|
109 |
// Create JS
|
110 |
+
$js .= "Element.{$action}('register-customer-newsletter');\r\n";
|
111 |
+
$js .= "$('billing:is_subscribed_box').checked = {$checked};\r\n";
|
112 |
+
$js .= "$('billing:is_subscribed').value = {$value};\r\n";
|
113 |
+
$js .= "$('billing:is_subscribed').value = {$value};\r\n";
|
114 |
+
|
115 |
return $js;
|
116 |
}
|
117 |
}
|
app/code/community/Bronto/Newsletter/Helper/Contact.php
CHANGED
@@ -16,14 +16,14 @@ class Bronto_Newsletter_Helper_Contact extends Bronto_Common_Helper_Contact
|
|
16 |
/**
|
17 |
* Description for const
|
18 |
*/
|
19 |
-
const XML_PATH_LISTS
|
20 |
|
21 |
/**
|
22 |
* @return bool
|
23 |
*/
|
24 |
public function getUpdateStatus()
|
25 |
{
|
26 |
-
return (bool)
|
27 |
}
|
28 |
|
29 |
/**
|
@@ -42,7 +42,7 @@ class Bronto_Newsletter_Helper_Contact extends Bronto_Common_Helper_Contact
|
|
42 |
|
43 |
return $listIds;
|
44 |
}
|
45 |
-
|
46 |
/**
|
47 |
* Get the list object from list id
|
48 |
* @param int $listId
|
@@ -53,13 +53,13 @@ class Bronto_Newsletter_Helper_Contact extends Bronto_Common_Helper_Contact
|
|
53 |
if ($api = $this->getApi()) {
|
54 |
/* @var $listObject Bronto_Api_List */
|
55 |
$listObject = $api->getListObject();
|
56 |
-
foreach ($listObject->readAll()->iterate() as $list
|
57 |
if ($list->id == $listId) {
|
58 |
return $list;
|
59 |
}
|
60 |
}
|
61 |
}
|
62 |
-
|
63 |
return false;
|
64 |
}
|
65 |
|
@@ -72,7 +72,7 @@ class Bronto_Newsletter_Helper_Contact extends Bronto_Common_Helper_Contact
|
|
72 |
{
|
73 |
return 'Bronto_Newsletter';
|
74 |
}
|
75 |
-
|
76 |
/**
|
77 |
* Convert Magento Newsletter Subscriber Status to Bronto API Contact Status
|
78 |
* @param Mage_Newsletter_Model_Subscriber $subscriber
|
@@ -83,13 +83,17 @@ class Bronto_Newsletter_Helper_Contact extends Bronto_Common_Helper_Contact
|
|
83 |
// Set correct status based on subscriber status
|
84 |
switch ($subscriber->getStatus()) {
|
85 |
case Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED:
|
86 |
-
$status = Bronto_Api_Contact::
|
87 |
break;
|
88 |
|
89 |
case Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED:
|
90 |
$status = Bronto_Api_Contact::STATUS_UNSUBSCRIBED;
|
91 |
break;
|
92 |
-
|
|
|
|
|
|
|
|
|
93 |
case Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE:
|
94 |
default:
|
95 |
$status = Bronto_Api_Contact::STATUS_TRANSACTIONAL;
|
16 |
/**
|
17 |
* Description for const
|
18 |
*/
|
19 |
+
const XML_PATH_LISTS = 'bronto_newsletter/contacts/lists';
|
20 |
|
21 |
/**
|
22 |
* @return bool
|
23 |
*/
|
24 |
public function getUpdateStatus()
|
25 |
{
|
26 |
+
return (bool)Mage::getStoreConfig(self::XML_PATH_UPDATE_STATUS);
|
27 |
}
|
28 |
|
29 |
/**
|
42 |
|
43 |
return $listIds;
|
44 |
}
|
45 |
+
|
46 |
/**
|
47 |
* Get the list object from list id
|
48 |
* @param int $listId
|
53 |
if ($api = $this->getApi()) {
|
54 |
/* @var $listObject Bronto_Api_List */
|
55 |
$listObject = $api->getListObject();
|
56 |
+
foreach ($listObject->readAll()->iterate() as $list/* @var $list Bronto_Api_List_Row */) {
|
57 |
if ($list->id == $listId) {
|
58 |
return $list;
|
59 |
}
|
60 |
}
|
61 |
}
|
62 |
+
|
63 |
return false;
|
64 |
}
|
65 |
|
72 |
{
|
73 |
return 'Bronto_Newsletter';
|
74 |
}
|
75 |
+
|
76 |
/**
|
77 |
* Convert Magento Newsletter Subscriber Status to Bronto API Contact Status
|
78 |
* @param Mage_Newsletter_Model_Subscriber $subscriber
|
83 |
// Set correct status based on subscriber status
|
84 |
switch ($subscriber->getStatus()) {
|
85 |
case Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED:
|
86 |
+
$status = Bronto_Api_Contact::STATUS_ACTIVE;
|
87 |
break;
|
88 |
|
89 |
case Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED:
|
90 |
$status = Bronto_Api_Contact::STATUS_UNSUBSCRIBED;
|
91 |
break;
|
92 |
+
|
93 |
+
case Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED:
|
94 |
+
$status = Bronto_Api_Contact::STATUS_UNCONFIRMED;
|
95 |
+
break;
|
96 |
+
|
97 |
case Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE:
|
98 |
default:
|
99 |
$status = Bronto_Api_Contact::STATUS_TRANSACTIONAL;
|
app/code/community/Bronto/Newsletter/Helper/Data.php
CHANGED
@@ -7,50 +7,73 @@
|
|
7 |
*/
|
8 |
class Bronto_Newsletter_Helper_Data extends Bronto_Common_Helper_Data
|
9 |
{
|
10 |
-
const XML_PATH_ENABLED
|
11 |
-
const XML_PATH_LIMIT
|
12 |
-
const
|
13 |
-
const
|
14 |
-
const
|
15 |
-
const
|
16 |
-
const
|
|
|
17 |
const XML_PATH_USE_CUSTOM_TEMPLATE = 'bronto_newsletter/checkout/use_custom_template';
|
18 |
-
const XML_PATH_BILLING_TEMPLATE
|
19 |
-
const XML_PATH_INSTALL_DATE
|
20 |
-
const XML_PATH_UPGRADE_DATE
|
21 |
|
22 |
/**
|
23 |
-
* @param string $store
|
24 |
* @return bool
|
25 |
*/
|
26 |
-
public function isEnabled(
|
27 |
{
|
28 |
-
|
29 |
-
|
30 |
-
}
|
31 |
|
32 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
}
|
34 |
|
35 |
/**
|
36 |
* @param string $path
|
37 |
* @return bool
|
38 |
*/
|
39 |
-
public function disableModule()
|
40 |
{
|
41 |
-
return $this->_disableModule(self::XML_PATH_ENABLED);
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
* @return int
|
46 |
*/
|
47 |
-
public function
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
{
|
49 |
if (!$this->isEnabled()) {
|
50 |
return false;
|
51 |
}
|
52 |
|
53 |
-
return (int)
|
54 |
}
|
55 |
|
56 |
/**
|
@@ -58,7 +81,7 @@ class Bronto_Newsletter_Helper_Data extends Bronto_Common_Helper_Data
|
|
58 |
*/
|
59 |
public function isEnabledCheckedByDefault()
|
60 |
{
|
61 |
-
return (bool)
|
62 |
}
|
63 |
|
64 |
/**
|
@@ -66,7 +89,7 @@ class Bronto_Newsletter_Helper_Data extends Bronto_Common_Helper_Data
|
|
66 |
*/
|
67 |
public function isEnabledForGuestCheckout()
|
68 |
{
|
69 |
-
return (bool)
|
70 |
}
|
71 |
|
72 |
/**
|
@@ -74,7 +97,7 @@ class Bronto_Newsletter_Helper_Data extends Bronto_Common_Helper_Data
|
|
74 |
*/
|
75 |
public function isEnabledForRegisterCheckout()
|
76 |
{
|
77 |
-
return (bool)
|
78 |
}
|
79 |
|
80 |
/**
|
@@ -82,7 +105,7 @@ class Bronto_Newsletter_Helper_Data extends Bronto_Common_Helper_Data
|
|
82 |
*/
|
83 |
public function isEnabledIfAlreadySubscribed()
|
84 |
{
|
85 |
-
return (bool)
|
86 |
}
|
87 |
|
88 |
/**
|
@@ -90,7 +113,7 @@ class Bronto_Newsletter_Helper_Data extends Bronto_Common_Helper_Data
|
|
90 |
*/
|
91 |
public function getCheckboxLabelText()
|
92 |
{
|
93 |
-
return
|
94 |
}
|
95 |
|
96 |
/**
|
@@ -105,56 +128,36 @@ class Bronto_Newsletter_Helper_Data extends Bronto_Common_Helper_Data
|
|
105 |
|
106 |
/* @var $subscriber Mage_Newsletter_Model_Subscriber */
|
107 |
$subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer($customer);
|
108 |
-
return (bool)
|
109 |
-
}
|
110 |
-
|
111 |
-
/**
|
112 |
-
* @return bool
|
113 |
-
*/
|
114 |
-
public function useCustomBillingTemplate()
|
115 |
-
{
|
116 |
-
return (bool) Mage::getStoreConfig(self::XML_PATH_USE_CUSTOM_TEMPLATE);
|
117 |
}
|
118 |
|
119 |
/**
|
|
|
|
|
120 |
* @return string
|
121 |
*/
|
122 |
-
|
123 |
{
|
124 |
-
|
125 |
-
|
126 |
-
if (!$this->useCustomBillingTemplate() || empty($template)) {
|
127 |
-
return false;
|
128 |
-
}
|
129 |
-
|
130 |
-
return $template;
|
131 |
}
|
132 |
|
133 |
/**
|
134 |
-
*
|
|
|
135 |
*/
|
136 |
-
public function
|
137 |
{
|
138 |
-
|
139 |
-
|
140 |
-
if (empty($customTemplate)) {
|
141 |
-
if ($this->isEnabled()) {
|
142 |
-
return 'bronto/newsletter/billing.phtml';
|
143 |
-
} else {
|
144 |
-
return 'checkout/onepage/billing.phtml';
|
145 |
-
}
|
146 |
-
}
|
147 |
-
|
148 |
-
return $customTemplate;
|
149 |
}
|
150 |
|
151 |
/**
|
152 |
-
*
|
153 |
-
*
|
154 |
-
* @return string
|
155 |
*/
|
156 |
-
|
157 |
{
|
158 |
-
return '
|
|
|
159 |
}
|
160 |
}
|
7 |
*/
|
8 |
class Bronto_Newsletter_Helper_Data extends Bronto_Common_Helper_Data
|
9 |
{
|
10 |
+
const XML_PATH_ENABLED = 'bronto_newsletter/settings/enabled';
|
11 |
+
const XML_PATH_LIMIT = 'bronto_newsletter/settings/limit';
|
12 |
+
const XML_PATH_SYNC_LIMIT = 'bronto_newsletter/settings/sync_limit';
|
13 |
+
const XML_PATH_DEFAULT = 'bronto_newsletter/checkout/default_checked';
|
14 |
+
const XML_PATH_SHOW_GUEST = 'bronto_newsletter/checkout/show_to_guests';
|
15 |
+
const XML_PATH_SHOW_REGISTRAR = 'bronto_newsletter/checkout/show_to_registrars';
|
16 |
+
const XML_PATH_SHOW_SUBSCRIBED = 'bronto_newsletter/checkout/show_if_subscribed';
|
17 |
+
const XML_PATH_LABEL_TEXT = 'bronto_newsletter/checkout/label_text';
|
18 |
const XML_PATH_USE_CUSTOM_TEMPLATE = 'bronto_newsletter/checkout/use_custom_template';
|
19 |
+
const XML_PATH_BILLING_TEMPLATE = 'bronto_newsletter/checkout/billing_template';
|
20 |
+
const XML_PATH_INSTALL_DATE = 'bronto_newsletter/settings/install_date';
|
21 |
+
const XML_PATH_UPGRADE_DATE = 'bronto_newsletter/settings/upgrade_date';
|
22 |
|
23 |
/**
|
|
|
24 |
* @return bool
|
25 |
*/
|
26 |
+
public function isEnabled()
|
27 |
{
|
28 |
+
return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED);
|
29 |
+
}
|
|
|
30 |
|
31 |
+
/*
|
32 |
+
* Get Text to display in notice when enabling module
|
33 |
+
*
|
34 |
+
* @return string
|
35 |
+
*/
|
36 |
+
public function getModuleEnabledText()
|
37 |
+
{
|
38 |
+
$message = parent::getModuleEnabledText();
|
39 |
+
$scopeData = $this->getScopeParams();
|
40 |
+
if ($scopeData['scope'] != 'default') {
|
41 |
+
$message = $this->__(
|
42 |
+
'If the API token being used for this configuration scope is different from that of the Default Config scope, ' .
|
43 |
+
'you should un-check the `Use Website` or `Use Default` for the <em>Add to List(s)</em> field in the <em>Contacts</em> ' .
|
44 |
+
'group on this page and select the desired list(s).'
|
45 |
+
);
|
46 |
+
}
|
47 |
+
return $message;
|
48 |
}
|
49 |
|
50 |
/**
|
51 |
* @param string $path
|
52 |
* @return bool
|
53 |
*/
|
54 |
+
public function disableModule($scope = 'default', $scopeId = 0)
|
55 |
{
|
56 |
+
return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId);
|
57 |
}
|
58 |
|
59 |
/**
|
60 |
* @return int
|
61 |
*/
|
62 |
+
public function getSyncLimit()
|
63 |
+
{
|
64 |
+
return (int)$this->getAdminScopedConfig(self::XML_PATH_SYNC_LIMIT);
|
65 |
+
}
|
66 |
+
|
67 |
+
/**
|
68 |
+
* @return int
|
69 |
+
*/
|
70 |
+
public function getLimit($storeId = null)
|
71 |
{
|
72 |
if (!$this->isEnabled()) {
|
73 |
return false;
|
74 |
}
|
75 |
|
76 |
+
return (int)$this->getAdminScopedConfig(self::XML_PATH_LIMIT, $storeId);
|
77 |
}
|
78 |
|
79 |
/**
|
81 |
*/
|
82 |
public function isEnabledCheckedByDefault()
|
83 |
{
|
84 |
+
return (bool)$this->getAdminScopedConfig(self::XML_PATH_DEFAULT);
|
85 |
}
|
86 |
|
87 |
/**
|
89 |
*/
|
90 |
public function isEnabledForGuestCheckout()
|
91 |
{
|
92 |
+
return (bool)$this->getAdminScopedConfig(self::XML_PATH_SHOW_GUEST);
|
93 |
}
|
94 |
|
95 |
/**
|
97 |
*/
|
98 |
public function isEnabledForRegisterCheckout()
|
99 |
{
|
100 |
+
return (bool)$this->getAdminScopedConfig(self::XML_PATH_SHOW_REGISTRAR);
|
101 |
}
|
102 |
|
103 |
/**
|
105 |
*/
|
106 |
public function isEnabledIfAlreadySubscribed()
|
107 |
{
|
108 |
+
return (bool)$this->getAdminScopedConfig(self::XML_PATH_SHOW_SUBSCRIBED);
|
109 |
}
|
110 |
|
111 |
/**
|
113 |
*/
|
114 |
public function getCheckboxLabelText()
|
115 |
{
|
116 |
+
return $this->getAdminScopedConfig(self::XML_PATH_LABEL_TEXT);
|
117 |
}
|
118 |
|
119 |
/**
|
128 |
|
129 |
/* @var $subscriber Mage_Newsletter_Model_Subscriber */
|
130 |
$subscriber = Mage::getModel('newsletter/subscriber')->loadByCustomer($customer);
|
131 |
+
return (bool)$subscriber->isSubscribed();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
132 |
}
|
133 |
|
134 |
/**
|
135 |
+
* Retrieve helper module name
|
136 |
+
*
|
137 |
* @return string
|
138 |
*/
|
139 |
+
protected function _getModuleName()
|
140 |
{
|
141 |
+
return 'Bronto_Newsletter';
|
|
|
|
|
|
|
|
|
|
|
|
|
142 |
}
|
143 |
|
144 |
/**
|
145 |
+
* Get Count of Subscribers not in queue
|
146 |
+
* @return int
|
147 |
*/
|
148 |
+
public function getMissingSubscribersCount()
|
149 |
{
|
150 |
+
return Mage::getModel('bronto_newsletter/queue')
|
151 |
+
->getMissingSubscribersCount();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
152 |
}
|
153 |
|
154 |
/**
|
155 |
+
* Get Subscribers which aren't in queue
|
156 |
+
* @return array
|
|
|
157 |
*/
|
158 |
+
public function getMissingSubscribers()
|
159 |
{
|
160 |
+
return Mage::getModel('bronto_newsletter/queue')
|
161 |
+
->getMissingSubscribers();
|
162 |
}
|
163 |
}
|
app/code/community/Bronto/Newsletter/Model/Mysql4/Queue.php
CHANGED
@@ -2,18 +2,18 @@
|
|
2 |
|
3 |
/**
|
4 |
* Short description for file
|
5 |
-
*
|
6 |
* Long description (if any) ...
|
7 |
-
*
|
8 |
* PHP version 5
|
9 |
-
*
|
10 |
* The license text...
|
11 |
-
*
|
12 |
* @category Bronto
|
13 |
* @package Newsletter
|
14 |
* @author Jeff Lambert <jeff.lambert@atlanticbt.com>
|
15 |
* @copyright 2012 Atlantic BT
|
16 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
17 |
* @version CVS: $Id:$
|
18 |
* @link <>
|
19 |
* @see References to other sections (if any)...
|
@@ -29,17 +29,26 @@ class Bronto_Newsletter_Model_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstra
|
|
29 |
* @var bool
|
30 |
*/
|
31 |
protected $_isPkAutoIncrement = false;
|
32 |
-
|
33 |
/**
|
34 |
* Short description for function
|
35 |
-
*
|
36 |
* Long description (if any) ...
|
37 |
-
*
|
38 |
-
* @return void
|
39 |
* @access public
|
40 |
*/
|
41 |
public function _construct()
|
42 |
{
|
43 |
$this->_init('bronto_newsletter/queue', 'queue_id');
|
44 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
45 |
}
|
2 |
|
3 |
/**
|
4 |
* Short description for file
|
5 |
+
*
|
6 |
* Long description (if any) ...
|
7 |
+
*
|
8 |
* PHP version 5
|
9 |
+
*
|
10 |
* The license text...
|
11 |
+
*
|
12 |
* @category Bronto
|
13 |
* @package Newsletter
|
14 |
* @author Jeff Lambert <jeff.lambert@atlanticbt.com>
|
15 |
* @copyright 2012 Atlantic BT
|
16 |
+
* @license http://www.atlanticbt.com/ Atlantic BT
|
17 |
* @version CVS: $Id:$
|
18 |
* @link <>
|
19 |
* @see References to other sections (if any)...
|
29 |
* @var bool
|
30 |
*/
|
31 |
protected $_isPkAutoIncrement = false;
|
32 |
+
|
33 |
/**
|
34 |
* Short description for function
|
35 |
+
*
|
36 |
* Long description (if any) ...
|
37 |
+
*
|
38 |
+
* @return void
|
39 |
* @access public
|
40 |
*/
|
41 |
public function _construct()
|
42 |
{
|
43 |
$this->_init('bronto_newsletter/queue', 'queue_id');
|
44 |
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Get Write adapter instance
|
48 |
+
* @return type
|
49 |
+
*/
|
50 |
+
public function getWriteAdapter()
|
51 |
+
{
|
52 |
+
return $this->_getWriteAdapter();
|
53 |
+
}
|
54 |
}
|
app/code/community/Bronto/Newsletter/Model/Mysql4/Queue/Collection.php
CHANGED
@@ -1,44 +1,28 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
8 |
-
* PHP version 5
|
9 |
-
*
|
10 |
-
* The license text...
|
11 |
-
*
|
12 |
-
* @category Bronto
|
13 |
-
* @package Newsletter
|
14 |
-
* @author Jeff Lambert <jeff.lambert@atlanticbt.com>
|
15 |
-
* @copyright 2012 Atlantic BT
|
16 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
17 |
-
* @version CVS: $Id:$
|
18 |
-
* @link <>
|
19 |
-
* @see References to other sections (if any)...
|
20 |
*/
|
21 |
-
|
22 |
-
|
23 |
-
|
24 |
-
class Bronto_Newsletter_Model_Mysql4_Queue_Collection
|
25 |
-
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
26 |
-
{
|
27 |
/**
|
28 |
* Short description for function
|
29 |
-
*
|
30 |
* Long description (if any) ...
|
31 |
-
*
|
32 |
-
* @return void
|
33 |
* @access public
|
34 |
*/
|
35 |
-
public function _construct()
|
|
|
36 |
parent::_construct();
|
37 |
$this->_init('bronto_newsletter/queue');
|
38 |
}
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
/**
|
43 |
* @return Bronto_Newsletter_Model_Mysql4_Queue_Collection
|
44 |
*/
|
@@ -48,12 +32,30 @@ class Bronto_Newsletter_Model_Mysql4_Queue_Collection
|
|
48 |
return $this;
|
49 |
}
|
50 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
51 |
/**
|
52 |
* @return Bronto_Newsletter_Model_Mysql4_Queue_Collection
|
53 |
*/
|
54 |
public function addBrontoNotImportedFilter()
|
55 |
{
|
56 |
-
$this->addFieldToFilter('imported', array('
|
57 |
return $this;
|
58 |
}
|
59 |
|
@@ -71,13 +73,11 @@ class Bronto_Newsletter_Model_Mysql4_Queue_Collection
|
|
71 |
|
72 |
$storeIds = array_unique($storeIds);
|
73 |
|
74 |
-
if ($index = array_search(null, $storeIds)) {
|
75 |
unset($storeIds[$index]);
|
76 |
$nullCheck = true;
|
77 |
}
|
78 |
|
79 |
-
$storeIds[0] = ($storeIds[0] == '') ? 0 : $storeIds[0];
|
80 |
-
|
81 |
if ($nullCheck) {
|
82 |
$this->getSelect()->where('store IN(?) OR store IS NULL', $storeIds);
|
83 |
} else {
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* @package Bronto\Newsletter
|
5 |
+
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
+
* @version 1.3.5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
*/
|
8 |
+
class Bronto_Newsletter_Model_Mysql4_Queue_Collection
|
9 |
+
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
10 |
+
{
|
|
|
|
|
|
|
11 |
/**
|
12 |
* Short description for function
|
13 |
+
*
|
14 |
* Long description (if any) ...
|
15 |
+
*
|
16 |
+
* @return void
|
17 |
* @access public
|
18 |
*/
|
19 |
+
public function _construct()
|
20 |
+
{
|
21 |
parent::_construct();
|
22 |
$this->_init('bronto_newsletter/queue');
|
23 |
}
|
24 |
+
|
25 |
+
|
|
|
26 |
/**
|
27 |
* @return Bronto_Newsletter_Model_Mysql4_Queue_Collection
|
28 |
*/
|
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 |
+
return $this;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* @return Bronto_Order_Model_Mysql4_Queue_Collection
|
46 |
+
*/
|
47 |
+
public function addBrontoNotSuppressedFilter()
|
48 |
+
{
|
49 |
+
$this->addFieldToFilter('bronto_suppressed', array('null' => true));
|
50 |
+
return $this;
|
51 |
+
}
|
52 |
+
|
53 |
/**
|
54 |
* @return Bronto_Newsletter_Model_Mysql4_Queue_Collection
|
55 |
*/
|
56 |
public function addBrontoNotImportedFilter()
|
57 |
{
|
58 |
+
$this->addFieldToFilter('imported', array('neq' => '1'));
|
59 |
return $this;
|
60 |
}
|
61 |
|
73 |
|
74 |
$storeIds = array_unique($storeIds);
|
75 |
|
76 |
+
if ($index = array_search(null, $storeIds, true)) {
|
77 |
unset($storeIds[$index]);
|
78 |
$nullCheck = true;
|
79 |
}
|
80 |
|
|
|
|
|
81 |
if ($nullCheck) {
|
82 |
$this->getSelect()->where('store IN(?) OR store IS NULL', $storeIds);
|
83 |
} else {
|
app/code/community/Bronto/Newsletter/Model/Observer.php
CHANGED
@@ -1,19 +1,30 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
* @package Newsletter
|
5 |
-
* @copyright 2011-
|
6 |
* @version 1.3.5
|
7 |
*/
|
8 |
-
class Bronto_Newsletter_Model_Observer
|
|
|
9 |
{
|
|
|
10 |
const NOTICE_IDENTIFER = 'bronto_newsletter';
|
11 |
const BOX_UNCHECKED = 0;
|
12 |
const BOX_CHECKED = 1;
|
13 |
const BOX_NOT_CHANGED = 2;
|
14 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
15 |
/**
|
16 |
* @param Varien_Event_Observer $observer
|
|
|
17 |
* @return mixed
|
18 |
*/
|
19 |
public function checkBrontoRequirements(Varien_Event_Observer $observer)
|
@@ -23,11 +34,20 @@ class Bronto_Newsletter_Model_Observer extends Mage_Core_Model_Abstract
|
|
23 |
}
|
24 |
|
25 |
// Verify Requirements
|
26 |
-
if (
|
27 |
return;
|
28 |
}
|
29 |
}
|
30 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
31 |
/**
|
32 |
* This event fires when customer continues past the Billing Info step
|
33 |
* on the onepage checkout. We set a flag here in the session to avoid
|
@@ -37,87 +57,102 @@ class Bronto_Newsletter_Model_Observer extends Mage_Core_Model_Abstract
|
|
37 |
*/
|
38 |
public function setSubscriptionAtBillingStep(Varien_Event_Observer $observer)
|
39 |
{
|
40 |
-
if (
|
41 |
return;
|
42 |
}
|
43 |
-
|
44 |
$controllerAction = $observer->getControllerAction();
|
45 |
if ($controllerAction instanceof Mage_Checkout_OnepageController) {
|
46 |
Mage::getSingleton('checkout/session')->unsIsSubscribed();
|
47 |
$params = Mage::app()->getRequest()->getParams();
|
48 |
|
49 |
if (
|
50 |
-
isset($params['billing']['is_subscribed']) &&
|
51 |
($params['billing']['is_subscribed'] === '1' ||
|
52 |
-
|
53 |
) {
|
54 |
$isSubscribed = (int) $params['billing']['is_subscribed'];
|
55 |
Mage::getSingleton('checkout/session')->setIsSubscribed($isSubscribed);
|
56 |
-
}
|
|
|
57 |
Mage::getSingleton('checkout/session')->setIsSubscribed(self::BOX_NOT_CHANGED);
|
58 |
}
|
59 |
}
|
60 |
-
|
61 |
return $observer;
|
62 |
}
|
63 |
-
|
64 |
/**
|
65 |
* Get Bronto Contact Row via Email address
|
|
|
66 |
* @param string $email
|
|
|
67 |
* @return boolean|Bronto_Api_Contact_Row
|
68 |
*/
|
69 |
protected function _getBrontoContact($email)
|
70 |
{
|
71 |
try {
|
72 |
/* @var $contact Bronto_Api_Contact_Row */
|
73 |
-
$contact = Mage::helper('bronto_newsletter/contact')->getContactByEmail(
|
|
|
|
|
|
|
|
|
|
|
74 |
return $contact;
|
75 |
-
}
|
76 |
-
|
77 |
-
|
|
|
|
|
78 |
}
|
79 |
}
|
80 |
|
81 |
/**
|
82 |
* Observe checkout event and handle assigning status
|
|
|
83 |
* @param Varien_Event_Observer $observer
|
|
|
84 |
* @return boolean|Varien_Event_Observer
|
85 |
*/
|
86 |
public function handleSubscriptionAtCheckout(Varien_Event_Observer $observer)
|
87 |
{
|
88 |
-
if (
|
89 |
return;
|
90 |
}
|
91 |
-
|
92 |
// Get Subscription status from session
|
93 |
$isSubscribed = Mage::getSingleton('checkout/session')->getIsSubscribed();
|
94 |
-
|
95 |
// If Subscription status isn't set, we do nothing
|
96 |
if (!is_int($isSubscribed)) {
|
97 |
return $observer;
|
98 |
}
|
99 |
-
|
100 |
try {
|
101 |
// Get e-mail address we are working with
|
102 |
$email = $observer->getEvent()->getOrder()->getData('customer_email');
|
103 |
-
|
104 |
if (empty($email)) {
|
105 |
-
|
106 |
-
|
|
|
107 |
}
|
108 |
|
109 |
/* @var $subscriber Mage_Newsletter_Model_Subscriber */
|
110 |
if (!$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email)) {
|
111 |
-
|
112 |
-
|
|
|
113 |
}
|
114 |
-
|
115 |
/* @var $contact Bronto_Api_Contact_Row */
|
116 |
if (!$contact = $this->_getBrontoContact($email)) {
|
117 |
-
|
118 |
-
|
|
|
119 |
}
|
120 |
-
|
121 |
// Determine action
|
122 |
switch ($isSubscribed) {
|
123 |
case self::BOX_CHECKED:
|
@@ -130,7 +165,8 @@ class Bronto_Newsletter_Model_Observer extends Mage_Core_Model_Abstract
|
|
130 |
// Unsubscribe the Customer if subscribed, Make Transactional if not in bronto
|
131 |
if ($subscriber->isSubscribed()) {
|
132 |
return $subscriber->unsubscribe();
|
133 |
-
}
|
|
|
134 |
$this->_makeTransactional($subscriber, $email);
|
135 |
}
|
136 |
break;
|
@@ -144,50 +180,55 @@ class Bronto_Newsletter_Model_Observer extends Mage_Core_Model_Abstract
|
|
144 |
// Intentionally blank
|
145 |
break;
|
146 |
}
|
147 |
-
} catch (Exception $e) {
|
148 |
-
Mage::helper('bronto_newsletter')->writeError($e);
|
149 |
}
|
150 |
-
|
|
|
|
|
|
|
151 |
return $observer;
|
152 |
}
|
153 |
-
|
154 |
/**
|
155 |
-
* Handle setting subscriber as transactional in bronto queue and
|
156 |
* removing from magento subscription
|
|
|
157 |
* @param Mage_Newsletter_Model_Subscriber $subscriber
|
158 |
-
* @param string
|
|
|
159 |
* @return boolean|Mage_Newsletter_Model_Subscriber
|
160 |
*/
|
161 |
private function _makeTransactional(Mage_Newsletter_Model_Subscriber $subscriber, $email)
|
162 |
{
|
163 |
/* @var $contact Bronto_Api_Contact_Row */
|
164 |
if (!$contact = $this->_getBrontoContact($email)) {
|
165 |
-
|
166 |
-
|
|
|
167 |
}
|
168 |
-
|
169 |
// Get Customer using the email provided
|
170 |
$ownerId = Mage::getModel('customer/customer')
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
if (!$ownerId) {
|
176 |
$ownerId = Mage::getSingleton('customer/session')->getId();
|
177 |
}
|
178 |
-
|
179 |
// Set Magento Subscriber and Status
|
180 |
-
$subscriber->setCustomerId($ownerId);
|
181 |
$subscriber->setSubscriberEmail($email);
|
182 |
$subscriber->setStoreId(Mage::app()->getStore()->getId());
|
183 |
if ($contact->status == Bronto_Api_Contact::STATUS_UNSUBSCRIBED) {
|
184 |
$subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED);
|
185 |
-
}
|
|
|
186 |
$subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE);
|
187 |
}
|
188 |
-
|
189 |
$subscriber->save();
|
190 |
-
|
191 |
return $subscriber;
|
192 |
}
|
193 |
|
@@ -196,7 +237,7 @@ class Bronto_Newsletter_Model_Observer extends Mage_Core_Model_Abstract
|
|
196 |
*/
|
197 |
public function updateBrontoFromNewsletterStatus(Varien_Event_Observer $observer)
|
198 |
{
|
199 |
-
if (
|
200 |
return;
|
201 |
}
|
202 |
|
@@ -205,125 +246,190 @@ class Bronto_Newsletter_Model_Observer extends Mage_Core_Model_Abstract
|
|
205 |
try {
|
206 |
/* @var $subscriber Mage_Newsletter_Model_Subscriber */
|
207 |
if (!$subscriber = $observer->getEvent()->getSubscriber()) {
|
208 |
-
|
209 |
-
|
|
|
210 |
}
|
211 |
-
|
212 |
// Send to queue
|
213 |
$this->_saveToQueue($subscriber, Mage::app()->getStore()->getId());
|
214 |
-
}
|
215 |
-
|
|
|
216 |
}
|
217 |
}
|
218 |
|
219 |
/**
|
220 |
* Add Subscriber to Bronto Newsletter Opt-in queue
|
|
|
221 |
* @param Mage_Newsletter_Model_Subscriber $subscriber
|
222 |
-
* @param int
|
|
|
223 |
* @return void
|
224 |
*/
|
225 |
-
private function _saveToQueue($subscriber, $storeId)
|
226 |
{
|
227 |
// Get e-mail address we are working with
|
228 |
$email = $subscriber->getEmail();
|
229 |
if (empty($email)) {
|
230 |
-
|
231 |
-
|
|
|
232 |
}
|
233 |
-
|
234 |
// Get Calculated Status
|
235 |
$status = Mage::helper('bronto_newsletter/contact')->getQueueStatus($subscriber);
|
236 |
-
|
237 |
/* @var $contactQueue Bronto_Newsletter_Model_Queue */
|
238 |
$contactQueue = Mage::getModel('bronto_newsletter/queue')
|
239 |
-
|
240 |
-
|
241 |
// If ContactQueue status doesn't match subscriber status, replace it
|
242 |
if ($status != $contactQueue->getStatus()) {
|
243 |
$contactQueue->setSubscriberEmail($subscriber->getEmail())
|
244 |
-
|
245 |
-
|
246 |
-
|
247 |
-
|
248 |
-
|
249 |
}
|
250 |
}
|
251 |
-
|
252 |
/**
|
253 |
* @param int $storeId
|
|
|
254 |
* @return array
|
255 |
*/
|
256 |
-
public function processSubscribersForStore($storeId
|
257 |
{
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
258 |
if (is_object($storeId)) {
|
259 |
$store = $storeId;
|
260 |
$storeId = $store->getId();
|
261 |
-
}
|
|
|
262 |
$store = Mage::app()->getStore($storeId);
|
263 |
$storeId = $store->getId();
|
264 |
}
|
265 |
-
|
266 |
-
$
|
267 |
-
Mage::helper('bronto_newsletter')->writeDebug("Starting Subscriber Opt-In process for store: {$store->getName()} ({$storeId})");
|
268 |
|
269 |
if (!$store->getConfig(Bronto_Newsletter_Helper_Data::XML_PATH_ENABLED)) {
|
270 |
-
|
271 |
-
return false;
|
272 |
-
}
|
273 |
|
274 |
-
|
275 |
-
if (!$limit) {
|
276 |
-
Mage::helper('bronto_newsletter')->writeDebug(' Limit empty. Skipping...');
|
277 |
-
return false;
|
278 |
}
|
279 |
-
|
280 |
$helper = Mage::helper('bronto_newsletter/contact');
|
281 |
-
|
282 |
$lists = $helper->getListIds($storeId);
|
283 |
-
|
284 |
// Get Subscriber Queue for store
|
285 |
/* var $subscribers Bronto_Newsletter_Model_Mysql4_Queue_Collection */
|
286 |
$subscribers = Mage::getModel('bronto_newsletter/queue')
|
287 |
-
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
|
|
|
|
292 |
foreach ($subscribers as $subscriber) {
|
293 |
try {
|
294 |
/* @var $contact Bronto_Api_Contact_Row */
|
295 |
-
$contact = $helper->getContactByEmail($subscriber->getSubscriberEmail(),
|
296 |
-
|
297 |
// Get List Details
|
298 |
foreach ($lists as $listId) {
|
299 |
if ($list = $helper->getListData($listId)) {
|
300 |
$listName = $list->label;
|
301 |
-
}
|
302 |
-
|
|
|
|
|
|
|
303 |
}
|
304 |
$helper->writeInfo(" Adding Contact to list: {$listName}");
|
305 |
$contact->addToList($listId);
|
306 |
}
|
307 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
308 |
if ($helper->getUpdateStatus()) {
|
309 |
-
|
310 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
311 |
}
|
|
|
312 |
$contact->save();
|
|
|
313 |
$subscriber->setImported(1)->save();
|
|
|
314 |
$result['success']++;
|
315 |
-
}
|
316 |
-
|
317 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
318 |
$subscriber->setImported(0)->save();
|
319 |
$result['error']++;
|
320 |
}
|
|
|
321 |
$result['total']++;
|
322 |
}
|
323 |
-
|
324 |
return $result;
|
325 |
}
|
326 |
-
|
327 |
/**
|
328 |
* @return array
|
329 |
*/
|
@@ -335,21 +441,20 @@ class Bronto_Newsletter_Model_Observer extends Mage_Core_Model_Abstract
|
|
335 |
'error' => 0,
|
336 |
);
|
337 |
|
338 |
-
$
|
|
|
|
|
339 |
foreach ($stores as $_store) {
|
340 |
-
$
|
|
|
|
|
|
|
341 |
$result['total'] += $storeResult['total'];
|
342 |
$result['success'] += $storeResult['success'];
|
343 |
$result['error'] += $storeResult['error'];
|
|
|
344 |
}
|
345 |
|
346 |
return $result;
|
347 |
}
|
348 |
-
|
349 |
-
/**
|
350 |
-
* @depricated
|
351 |
-
*/
|
352 |
-
static public function cronImport() {
|
353 |
-
return;
|
354 |
-
}
|
355 |
}
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* @package Bronto\Newsletter
|
5 |
+
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
* @version 1.3.5
|
7 |
*/
|
8 |
+
class Bronto_Newsletter_Model_Observer
|
9 |
+
extends Mage_Core_Model_Abstract
|
10 |
{
|
11 |
+
|
12 |
const NOTICE_IDENTIFER = 'bronto_newsletter';
|
13 |
const BOX_UNCHECKED = 0;
|
14 |
const BOX_CHECKED = 1;
|
15 |
const BOX_NOT_CHANGED = 2;
|
16 |
|
17 |
+
private $_helper;
|
18 |
+
|
19 |
+
public function __construct()
|
20 |
+
{
|
21 |
+
/* @var $_helper Bronto_Newsletter_Helper_Data */
|
22 |
+
$this->_helper = Mage::helper(self::NOTICE_IDENTIFER);
|
23 |
+
}
|
24 |
+
|
25 |
/**
|
26 |
* @param Varien_Event_Observer $observer
|
27 |
+
*
|
28 |
* @return mixed
|
29 |
*/
|
30 |
public function checkBrontoRequirements(Varien_Event_Observer $observer)
|
34 |
}
|
35 |
|
36 |
// Verify Requirements
|
37 |
+
if (!$this->_helper->varifyRequirements(self::NOTICE_IDENTIFER, array('soap', 'openssl'))) {
|
38 |
return;
|
39 |
}
|
40 |
}
|
41 |
+
|
42 |
+
/**
|
43 |
+
* Observes module becoming enabled and displays message warning user to configure settings
|
44 |
+
* @param Varien_Event_Observer $observer
|
45 |
+
*/
|
46 |
+
public function watchEnableAction(Varien_Event_Observer $observer)
|
47 |
+
{
|
48 |
+
Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('bronto_newsletter')->__(Mage::helper('bronto_newsletter')->getModuleEnabledText()));
|
49 |
+
}
|
50 |
+
|
51 |
/**
|
52 |
* This event fires when customer continues past the Billing Info step
|
53 |
* on the onepage checkout. We set a flag here in the session to avoid
|
57 |
*/
|
58 |
public function setSubscriptionAtBillingStep(Varien_Event_Observer $observer)
|
59 |
{
|
60 |
+
if (!$this->_helper->isEnabled()) {
|
61 |
return;
|
62 |
}
|
63 |
+
|
64 |
$controllerAction = $observer->getControllerAction();
|
65 |
if ($controllerAction instanceof Mage_Checkout_OnepageController) {
|
66 |
Mage::getSingleton('checkout/session')->unsIsSubscribed();
|
67 |
$params = Mage::app()->getRequest()->getParams();
|
68 |
|
69 |
if (
|
70 |
+
isset($params['billing']['is_subscribed']) &&
|
71 |
($params['billing']['is_subscribed'] === '1' ||
|
72 |
+
$params['billing']['is_subscribed'] === '0')
|
73 |
) {
|
74 |
$isSubscribed = (int) $params['billing']['is_subscribed'];
|
75 |
Mage::getSingleton('checkout/session')->setIsSubscribed($isSubscribed);
|
76 |
+
}
|
77 |
+
else {
|
78 |
Mage::getSingleton('checkout/session')->setIsSubscribed(self::BOX_NOT_CHANGED);
|
79 |
}
|
80 |
}
|
81 |
+
|
82 |
return $observer;
|
83 |
}
|
84 |
+
|
85 |
/**
|
86 |
* Get Bronto Contact Row via Email address
|
87 |
+
*
|
88 |
* @param string $email
|
89 |
+
*
|
90 |
* @return boolean|Bronto_Api_Contact_Row
|
91 |
*/
|
92 |
protected function _getBrontoContact($email)
|
93 |
{
|
94 |
try {
|
95 |
/* @var $contact Bronto_Api_Contact_Row */
|
96 |
+
$contact = Mage::helper('bronto_newsletter/contact')->getContactByEmail(
|
97 |
+
$email,
|
98 |
+
NULL,
|
99 |
+
Mage::app()->getStore()->getId()
|
100 |
+
);
|
101 |
+
|
102 |
return $contact;
|
103 |
+
}
|
104 |
+
catch (Exception $e) {
|
105 |
+
$this->_helper->writeError($e);
|
106 |
+
|
107 |
+
return FALSE;
|
108 |
}
|
109 |
}
|
110 |
|
111 |
/**
|
112 |
* Observe checkout event and handle assigning status
|
113 |
+
*
|
114 |
* @param Varien_Event_Observer $observer
|
115 |
+
*
|
116 |
* @return boolean|Varien_Event_Observer
|
117 |
*/
|
118 |
public function handleSubscriptionAtCheckout(Varien_Event_Observer $observer)
|
119 |
{
|
120 |
+
if (!$this->_helper->isEnabled()) {
|
121 |
return;
|
122 |
}
|
123 |
+
|
124 |
// Get Subscription status from session
|
125 |
$isSubscribed = Mage::getSingleton('checkout/session')->getIsSubscribed();
|
126 |
+
|
127 |
// If Subscription status isn't set, we do nothing
|
128 |
if (!is_int($isSubscribed)) {
|
129 |
return $observer;
|
130 |
}
|
131 |
+
|
132 |
try {
|
133 |
// Get e-mail address we are working with
|
134 |
$email = $observer->getEvent()->getOrder()->getData('customer_email');
|
135 |
+
|
136 |
if (empty($email)) {
|
137 |
+
$this->_helper->writeError('No customer_email was provided.');
|
138 |
+
|
139 |
+
return FALSE;
|
140 |
}
|
141 |
|
142 |
/* @var $subscriber Mage_Newsletter_Model_Subscriber */
|
143 |
if (!$subscriber = Mage::getModel('newsletter/subscriber')->loadByEmail($email)) {
|
144 |
+
$this->_helper->writeError('Unable to create subscriber object');
|
145 |
+
|
146 |
+
return FALSE;
|
147 |
}
|
148 |
+
|
149 |
/* @var $contact Bronto_Api_Contact_Row */
|
150 |
if (!$contact = $this->_getBrontoContact($email)) {
|
151 |
+
$this->_helper->writeError('Unable to create contact object');
|
152 |
+
|
153 |
+
return FALSE;
|
154 |
}
|
155 |
+
|
156 |
// Determine action
|
157 |
switch ($isSubscribed) {
|
158 |
case self::BOX_CHECKED:
|
165 |
// Unsubscribe the Customer if subscribed, Make Transactional if not in bronto
|
166 |
if ($subscriber->isSubscribed()) {
|
167 |
return $subscriber->unsubscribe();
|
168 |
+
}
|
169 |
+
elseif (!$contact->id && !$subscriber->isSubscribed()) {
|
170 |
$this->_makeTransactional($subscriber, $email);
|
171 |
}
|
172 |
break;
|
180 |
// Intentionally blank
|
181 |
break;
|
182 |
}
|
|
|
|
|
183 |
}
|
184 |
+
catch (Exception $e) {
|
185 |
+
$this->_helper->writeError($e);
|
186 |
+
}
|
187 |
+
|
188 |
return $observer;
|
189 |
}
|
190 |
+
|
191 |
/**
|
192 |
+
* Handle setting subscriber as transactional in bronto queue and
|
193 |
* removing from magento subscription
|
194 |
+
*
|
195 |
* @param Mage_Newsletter_Model_Subscriber $subscriber
|
196 |
+
* @param string $email
|
197 |
+
*
|
198 |
* @return boolean|Mage_Newsletter_Model_Subscriber
|
199 |
*/
|
200 |
private function _makeTransactional(Mage_Newsletter_Model_Subscriber $subscriber, $email)
|
201 |
{
|
202 |
/* @var $contact Bronto_Api_Contact_Row */
|
203 |
if (!$contact = $this->_getBrontoContact($email)) {
|
204 |
+
$this->_helper->writeError('Unable to create contact object');
|
205 |
+
|
206 |
+
return FALSE;
|
207 |
}
|
208 |
+
|
209 |
// Get Customer using the email provided
|
210 |
$ownerId = Mage::getModel('customer/customer')
|
211 |
+
->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
|
212 |
+
->loadByEmail($email)
|
213 |
+
->getId();
|
214 |
+
|
215 |
if (!$ownerId) {
|
216 |
$ownerId = Mage::getSingleton('customer/session')->getId();
|
217 |
}
|
218 |
+
|
219 |
// Set Magento Subscriber and Status
|
220 |
+
$subscriber->setCustomerId($ownerId);
|
221 |
$subscriber->setSubscriberEmail($email);
|
222 |
$subscriber->setStoreId(Mage::app()->getStore()->getId());
|
223 |
if ($contact->status == Bronto_Api_Contact::STATUS_UNSUBSCRIBED) {
|
224 |
$subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED);
|
225 |
+
}
|
226 |
+
else {
|
227 |
$subscriber->setStatus(Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE);
|
228 |
}
|
229 |
+
|
230 |
$subscriber->save();
|
231 |
+
|
232 |
return $subscriber;
|
233 |
}
|
234 |
|
237 |
*/
|
238 |
public function updateBrontoFromNewsletterStatus(Varien_Event_Observer $observer)
|
239 |
{
|
240 |
+
if (!$this->_helper->isEnabled()) {
|
241 |
return;
|
242 |
}
|
243 |
|
246 |
try {
|
247 |
/* @var $subscriber Mage_Newsletter_Model_Subscriber */
|
248 |
if (!$subscriber = $observer->getEvent()->getSubscriber()) {
|
249 |
+
$this->_helper->writeError('Unable to create subscriber object');
|
250 |
+
|
251 |
+
return FALSE;
|
252 |
}
|
253 |
+
|
254 |
// Send to queue
|
255 |
$this->_saveToQueue($subscriber, Mage::app()->getStore()->getId());
|
256 |
+
}
|
257 |
+
catch (Exception $e) {
|
258 |
+
$this->_helper->writeError($e);
|
259 |
}
|
260 |
}
|
261 |
|
262 |
/**
|
263 |
* Add Subscriber to Bronto Newsletter Opt-in queue
|
264 |
+
*
|
265 |
* @param Mage_Newsletter_Model_Subscriber $subscriber
|
266 |
+
* @param int $storeId
|
267 |
+
*
|
268 |
* @return void
|
269 |
*/
|
270 |
+
private function _saveToQueue($subscriber, $storeId)
|
271 |
{
|
272 |
// Get e-mail address we are working with
|
273 |
$email = $subscriber->getEmail();
|
274 |
if (empty($email)) {
|
275 |
+
$this->_helper->writeError('Subscriber does not have an email address.');
|
276 |
+
|
277 |
+
return FALSE;
|
278 |
}
|
279 |
+
|
280 |
// Get Calculated Status
|
281 |
$status = Mage::helper('bronto_newsletter/contact')->getQueueStatus($subscriber);
|
282 |
+
|
283 |
/* @var $contactQueue Bronto_Newsletter_Model_Queue */
|
284 |
$contactQueue = Mage::getModel('bronto_newsletter/queue')
|
285 |
+
->getContactRow($subscriber->getId(), $storeId);
|
286 |
+
|
287 |
// If ContactQueue status doesn't match subscriber status, replace it
|
288 |
if ($status != $contactQueue->getStatus()) {
|
289 |
$contactQueue->setSubscriberEmail($subscriber->getEmail())
|
290 |
+
->setStatus($status)
|
291 |
+
->setMessagePreference('html')
|
292 |
+
->setSource('api')
|
293 |
+
->setImported(0)
|
294 |
+
->save();
|
295 |
}
|
296 |
}
|
297 |
+
|
298 |
/**
|
299 |
* @param int $storeId
|
300 |
+
*
|
301 |
* @return array
|
302 |
*/
|
303 |
+
public function processSubscribersForStore($storeId, $limit)
|
304 |
{
|
305 |
+
// Define default results
|
306 |
+
$result = array('total' => 0, 'success' => 0, 'error' => 0);
|
307 |
+
|
308 |
+
// If limit is false or 0, return
|
309 |
+
if (!$limit) {
|
310 |
+
$this->_helper->writeDebug(' Limit empty. Skipping...');
|
311 |
+
|
312 |
+
return $result;
|
313 |
+
}
|
314 |
+
|
315 |
if (is_object($storeId)) {
|
316 |
$store = $storeId;
|
317 |
$storeId = $store->getId();
|
318 |
+
}
|
319 |
+
else {
|
320 |
$store = Mage::app()->getStore($storeId);
|
321 |
$storeId = $store->getId();
|
322 |
}
|
323 |
+
|
324 |
+
$this->_helper->writeDebug("Starting Subscriber Opt-In process for store: {$store->getName()} ({$storeId})");
|
|
|
325 |
|
326 |
if (!$store->getConfig(Bronto_Newsletter_Helper_Data::XML_PATH_ENABLED)) {
|
327 |
+
$this->_helper->writeDebug(' Module disabled for this store. Skipping...');
|
|
|
|
|
328 |
|
329 |
+
return FALSE;
|
|
|
|
|
|
|
330 |
}
|
331 |
+
|
332 |
$helper = Mage::helper('bronto_newsletter/contact');
|
333 |
+
|
334 |
$lists = $helper->getListIds($storeId);
|
335 |
+
|
336 |
// Get Subscriber Queue for store
|
337 |
/* var $subscribers Bronto_Newsletter_Model_Mysql4_Queue_Collection */
|
338 |
$subscribers = Mage::getModel('bronto_newsletter/queue')
|
339 |
+
->getCollection()
|
340 |
+
->addBrontoNotImportedFilter()
|
341 |
+
->addBrontoNotSuppressedFilter()
|
342 |
+
->addStoreFilter($storeId)
|
343 |
+
->setPageSize($limit)
|
344 |
+
->getItems();
|
345 |
+
|
346 |
foreach ($subscribers as $subscriber) {
|
347 |
try {
|
348 |
/* @var $contact Bronto_Api_Contact_Row */
|
349 |
+
$contact = $helper->getContactByEmail($subscriber->getSubscriberEmail(), NULL, $storeId);
|
350 |
+
|
351 |
// Get List Details
|
352 |
foreach ($lists as $listId) {
|
353 |
if ($list = $helper->getListData($listId)) {
|
354 |
$listName = $list->label;
|
355 |
+
}
|
356 |
+
else {
|
357 |
+
Mage::throwException(
|
358 |
+
"The list ({$listId}) was not found. This may indicate that it does not exist. Try re-saving the config"
|
359 |
+
);
|
360 |
}
|
361 |
$helper->writeInfo(" Adding Contact to list: {$listName}");
|
362 |
$contact->addToList($listId);
|
363 |
}
|
364 |
+
|
365 |
+
// Save List Update at least
|
366 |
+
$contact->save();
|
367 |
+
|
368 |
+
// If Bronto Status is 'Bounced', mark suppressed, show error and continue foreach
|
369 |
+
if ($contact->status == Bronto_Api_Contact::STATUS_BOUNCE) {
|
370 |
+
$bounceMessage = "Subscriber {$contact->email} Has Been Bounced in Bronto";
|
371 |
+
$subscriber->setBrontoSuppressed($bounceMessage)->save();
|
372 |
+
Mage::throwException($bounceMessage);
|
373 |
+
}
|
374 |
+
|
375 |
if ($helper->getUpdateStatus()) {
|
376 |
+
switch ($subscriber->getStatus()) {
|
377 |
+
case Bronto_Api_Contact::STATUS_UNCONFIRMED:
|
378 |
+
case Bronto_Api_Contact::STATUS_TRANSACTIONAL:
|
379 |
+
if ($contact->id && $contact->status != Bronto_Api_Contact::STATUS_UNSUBSCRIBED) {
|
380 |
+
$helper->writeInfo(
|
381 |
+
" Keeping Contact ({$contact->email}) status as: {$contact->status}"
|
382 |
+
);
|
383 |
+
break;
|
384 |
+
}
|
385 |
+
$contact->status = $subscriber->getStatus();
|
386 |
+
$helper->writeInfo(" Setting Contact ({$contact->email}) status to: {$contact->status}");
|
387 |
+
break;
|
388 |
+
|
389 |
+
case Bronto_Api_Contact::STATUS_ACTIVE:
|
390 |
+
if ($contact->status == Bronto_Api_Contact::STATUS_UNSUBSCRIBED &&
|
391 |
+
$subscriber->getImported() == 2
|
392 |
+
) {
|
393 |
+
$helper->writeInfo(
|
394 |
+
" Keeping Contact ({$contact->email}) status as: {$contact->status}"
|
395 |
+
);
|
396 |
+
break;
|
397 |
+
}
|
398 |
+
$contact->status = $subscriber->getStatus();
|
399 |
+
$helper->writeInfo(" Setting Contact ({$contact->email}) status to: {$contact->status}");
|
400 |
+
break;
|
401 |
+
|
402 |
+
default:
|
403 |
+
$contact->status = $subscriber->getStatus();
|
404 |
+
$helper->writeInfo(" Setting Contact ({$contact->email}) status to: {$contact->status}");
|
405 |
+
break;
|
406 |
+
}
|
407 |
}
|
408 |
+
|
409 |
$contact->save();
|
410 |
+
|
411 |
$subscriber->setImported(1)->save();
|
412 |
+
|
413 |
$result['success']++;
|
414 |
+
}
|
415 |
+
catch (Exception $e) {
|
416 |
+
// 315 means contact on suppression list, so suppress
|
417 |
+
if (315 == $e->getCode()) {
|
418 |
+
$subscriber->setBrontoSuppressed($e->getMessage());
|
419 |
+
}
|
420 |
+
|
421 |
+
$this->_helper->writeError($e);
|
422 |
+
|
423 |
$subscriber->setImported(0)->save();
|
424 |
$result['error']++;
|
425 |
}
|
426 |
+
|
427 |
$result['total']++;
|
428 |
}
|
429 |
+
|
430 |
return $result;
|
431 |
}
|
432 |
+
|
433 |
/**
|
434 |
* @return array
|
435 |
*/
|
441 |
'error' => 0,
|
442 |
);
|
443 |
|
444 |
+
$limit = $this->_helper->getLimit();
|
445 |
+
|
446 |
+
$stores = Mage::app()->getStores(TRUE);
|
447 |
foreach ($stores as $_store) {
|
448 |
+
if ($limit <= 0) {
|
449 |
+
continue;
|
450 |
+
}
|
451 |
+
$storeResult = $this->processSubscribersForStore($_store, $limit);
|
452 |
$result['total'] += $storeResult['total'];
|
453 |
$result['success'] += $storeResult['success'];
|
454 |
$result['error'] += $storeResult['error'];
|
455 |
+
$limit = $limit - $storeResult['total'];
|
456 |
}
|
457 |
|
458 |
return $result;
|
459 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
460 |
}
|
app/code/community/Bronto/Newsletter/Model/Queue.php
CHANGED
@@ -1,35 +1,19 @@
|
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
-
*
|
5 |
-
*
|
6 |
-
*
|
7 |
-
*
|
8 |
-
* PHP version 5
|
9 |
-
*
|
10 |
-
* The license text...
|
11 |
-
*
|
12 |
-
* @category Bronto
|
13 |
-
* @package Newsletter
|
14 |
-
* @author Jeff Lambert <jeff.lambert@atlanticbt.com>
|
15 |
-
* @copyright 2012 Atlantic BT
|
16 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
17 |
-
* @version CVS: $Id:$
|
18 |
-
* @link <>
|
19 |
-
* @see References to other sections (if any)...
|
20 |
-
*/
|
21 |
-
/**
|
22 |
-
* @author Jeff Lambert <jeff.lambert@atlanticbt.com>
|
23 |
*/
|
24 |
class Bronto_Newsletter_Model_Queue extends Mage_Core_Model_Abstract
|
25 |
{
|
26 |
|
27 |
/**
|
28 |
* Short description for function
|
29 |
-
*
|
30 |
* Long description (if any) ...
|
31 |
-
*
|
32 |
-
* @return void
|
33 |
* @access public
|
34 |
*/
|
35 |
public function _construct()
|
@@ -37,20 +21,94 @@ class Bronto_Newsletter_Model_Queue extends Mage_Core_Model_Abstract
|
|
37 |
parent::_construct();
|
38 |
$this->_init('bronto_newsletter/queue');
|
39 |
}
|
40 |
-
|
41 |
public function getContactRow($subscriber_id, $store_id)
|
42 |
{
|
43 |
$collection = $this->getCollection()
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
if ($collection->count() == 1) {
|
48 |
return $collection->getFirstItem();
|
49 |
} else {
|
50 |
$this->setSubscriberId($subscriber_id)
|
51 |
-
|
52 |
}
|
53 |
-
|
54 |
return $this;
|
55 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
56 |
}
|
1 |
<?php
|
2 |
|
3 |
/**
|
4 |
+
* @package Bronto\Newsletter
|
5 |
+
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
+
* @version 1.3.5
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
7 |
*/
|
8 |
class Bronto_Newsletter_Model_Queue extends Mage_Core_Model_Abstract
|
9 |
{
|
10 |
|
11 |
/**
|
12 |
* Short description for function
|
13 |
+
*
|
14 |
* Long description (if any) ...
|
15 |
+
*
|
16 |
+
* @return void
|
17 |
* @access public
|
18 |
*/
|
19 |
public function _construct()
|
21 |
parent::_construct();
|
22 |
$this->_init('bronto_newsletter/queue');
|
23 |
}
|
24 |
+
|
25 |
public function getContactRow($subscriber_id, $store_id)
|
26 |
{
|
27 |
$collection = $this->getCollection()
|
28 |
+
->addFieldToFilter('subscriber_id', $subscriber_id)
|
29 |
+
->addFieldToFilter('store', $store_id);
|
30 |
+
|
31 |
if ($collection->count() == 1) {
|
32 |
return $collection->getFirstItem();
|
33 |
} else {
|
34 |
$this->setSubscriberId($subscriber_id)
|
35 |
+
->setStore($store_id);
|
36 |
}
|
37 |
+
|
38 |
return $this;
|
39 |
}
|
40 |
+
|
41 |
+
/**
|
42 |
+
* Get Count of missing subscribers
|
43 |
+
* @return int
|
44 |
+
*/
|
45 |
+
public function getMissingSubscribersCount()
|
46 |
+
{
|
47 |
+
// Get Resources
|
48 |
+
$resource = $this->getResource();
|
49 |
+
$adapter = $resource->getWriteAdapter();
|
50 |
+
|
51 |
+
// Build Select Statement
|
52 |
+
$select = $adapter->select();
|
53 |
+
$select->from(
|
54 |
+
array('subscriber' => $resource->getTable('newsletter/subscriber')), array(new Zend_Db_Expr('COUNT(subscriber_id) as count'))
|
55 |
+
)
|
56 |
+
->where('NOT EXISTS (?)', $this->_getSubselect($resource, $adapter));
|
57 |
+
|
58 |
+
// Get Results
|
59 |
+
$result = $adapter->query($select)->fetch();
|
60 |
+
|
61 |
+
if (array_key_exists('count', $result)) {
|
62 |
+
return (int) $result['count'];
|
63 |
+
} else {
|
64 |
+
return 0;
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
/**
|
69 |
+
* Get Sub-Select Statement that limits results
|
70 |
+
* @param Bronto_Newsletter_Model_Mysql4_Queue $resource
|
71 |
+
* @param type $adapter
|
72 |
+
* @return Varien_Db_Select
|
73 |
+
*/
|
74 |
+
private function _getSubselect($resource, $adapter)
|
75 |
+
{
|
76 |
+
// Build Sub-Select Statement
|
77 |
+
$subselect = $adapter->select()
|
78 |
+
->from(
|
79 |
+
array('queue' => $resource->getTable('bronto_newsletter/queue')), array(new Zend_Db_Expr(1))
|
80 |
+
)
|
81 |
+
->where('queue.subscriber_id = subscriber.subscriber_id');
|
82 |
+
|
83 |
+
return $subselect;
|
84 |
+
}
|
85 |
+
|
86 |
+
/**
|
87 |
+
* Get collection of subscribers which aren't already in the queue, but should be
|
88 |
+
* @return array
|
89 |
+
*/
|
90 |
+
public function getMissingSubscribers()
|
91 |
+
{
|
92 |
+
// Get Resources
|
93 |
+
$resource = $this->getResource();
|
94 |
+
$adapter = $resource->getWriteAdapter();
|
95 |
+
|
96 |
+
// Get Sync Limit Value
|
97 |
+
$count = Mage::helper('bronto_newsletter')->getSyncLimit();
|
98 |
+
|
99 |
+
// Build Select Statement
|
100 |
+
$select = $adapter->select();
|
101 |
+
$select->from(
|
102 |
+
array('subscriber' => $resource->getTable('newsletter/subscriber')),
|
103 |
+
array('subscriber_id', 'store_id', 'subscriber_email', 'subscriber_status')
|
104 |
+
)
|
105 |
+
->where('NOT EXISTS (?)', $this->_getSubselect($resource, $adapter))
|
106 |
+
->limit($count);
|
107 |
+
|
108 |
+
// Get Results
|
109 |
+
$result = $adapter->query($select)->fetchAll();
|
110 |
+
|
111 |
+
return $result;
|
112 |
+
}
|
113 |
+
|
114 |
}
|
app/code/community/Bronto/Newsletter/Model/System/Config/Backend/Cron.php
CHANGED
@@ -7,5 +7,5 @@
|
|
7 |
class Bronto_Newsletter_Model_System_Config_Backend_Cron extends Bronto_Common_Model_System_Config_Backend_Cron
|
8 |
{
|
9 |
protected $_cron_string_path = 'crontab/jobs/bronto_newsletter_import/schedule/cron_expr';
|
10 |
-
protected $_cron_model_path
|
11 |
}
|
7 |
class Bronto_Newsletter_Model_System_Config_Backend_Cron extends Bronto_Common_Model_System_Config_Backend_Cron
|
8 |
{
|
9 |
protected $_cron_string_path = 'crontab/jobs/bronto_newsletter_import/schedule/cron_expr';
|
10 |
+
protected $_cron_model_path = 'crontab/jobs/bronto_newsletter_import/run/model';
|
11 |
}
|
app/code/community/Bronto/Newsletter/Test/Config/Config.php
DELETED
@@ -1,228 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Bronto_Newsletter_Test_Config_Config
|
3 |
-
extends EcomDev_PHPUnit_Test_Case_Config
|
4 |
-
{
|
5 |
-
// {{{ blocksProvider()
|
6 |
-
|
7 |
-
public function blocksProvider()
|
8 |
-
{
|
9 |
-
return array(
|
10 |
-
array('bronto_newsletter/adminhtml_system_config_about', 'Bronto_Newsletter_Block_Adminhtml_System_Config_About'),
|
11 |
-
array('bronto_newsletter/checkout_onepage_newsletter', 'Bronto_Newsletter_Block_Checkout_Onepage_Newsletter'),
|
12 |
-
array('bronto_newsletter/adminhtml_widget_button_run', 'Bronto_Newsletter_Block_Adminhtml_Widget_Button_Run'),
|
13 |
-
array('bronto_newsletter/adminhtml_widget_button_reset', 'Bronto_Newsletter_Block_Adminhtml_Widget_Button_Run'),
|
14 |
-
);
|
15 |
-
}
|
16 |
-
|
17 |
-
// }}}
|
18 |
-
// {{{ resourceModelProvider()
|
19 |
-
|
20 |
-
public function resourceModelProvider()
|
21 |
-
{
|
22 |
-
return array(
|
23 |
-
array('bronto_newsletter_mysql4/queue', 'Bronto_Newsletter_Model_Mysql4_Queue'),
|
24 |
-
array('bronto_newsletter_mysql4/queue_collection', 'Bronto_Newsletter_Model_Mysql4_Queue_Collection'),
|
25 |
-
);
|
26 |
-
}
|
27 |
-
|
28 |
-
// }}}
|
29 |
-
// {{{ modelsProvider()
|
30 |
-
|
31 |
-
public function modelsProvider()
|
32 |
-
{
|
33 |
-
return array(
|
34 |
-
array('bronto_newsletter/queue', 'Bronto_Newsletter_Model_Queue'),
|
35 |
-
);
|
36 |
-
}
|
37 |
-
|
38 |
-
// }}}
|
39 |
-
// {{{ helpersProvider()
|
40 |
-
|
41 |
-
public function helpersProvider()
|
42 |
-
{
|
43 |
-
return array(
|
44 |
-
array('bronto_newsletter/data', 'Bronto_Newsletter_Helper_Data'),
|
45 |
-
array('bronto_newsletter/contact', 'Bronto_Newsletter_Helper_Contact'),
|
46 |
-
);
|
47 |
-
}
|
48 |
-
|
49 |
-
// }}}
|
50 |
-
// {{{ observersProvider()
|
51 |
-
|
52 |
-
public function observersProvider()
|
53 |
-
{
|
54 |
-
return array(
|
55 |
-
array('adminhtml', 'controller_action_predispatch', 'bronto_newsletter/observer', 'checkBrontoRequirements'),
|
56 |
-
);
|
57 |
-
}
|
58 |
-
|
59 |
-
// }}}
|
60 |
-
// {{{ definedLayoutFilesProvider()
|
61 |
-
|
62 |
-
public function definedLayoutFilesProvider()
|
63 |
-
{
|
64 |
-
return array(
|
65 |
-
array('frontend', 'bronto/newsletter.xml'),
|
66 |
-
);
|
67 |
-
}
|
68 |
-
|
69 |
-
// }}}
|
70 |
-
// {{{ themeLayoutFilesExistProvider()
|
71 |
-
|
72 |
-
public function themeLayoutFilesExistProvider()
|
73 |
-
{
|
74 |
-
return array(
|
75 |
-
array('frontend', 'bronto/newsletter.xml', 'default', 'default'),
|
76 |
-
);
|
77 |
-
}
|
78 |
-
|
79 |
-
// }}}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* @test
|
83 |
-
* @group amd
|
84 |
-
* @group config
|
85 |
-
*/
|
86 |
-
public function assertNewsletterModuleVersionGreaterThanOrEquals()
|
87 |
-
{
|
88 |
-
$this->assertModuleVersionGreaterThanOrEquals('1.4.0');
|
89 |
-
}
|
90 |
-
|
91 |
-
// {{{ assertNewsletterModuleInLocalCodePool()
|
92 |
-
|
93 |
-
/**
|
94 |
-
* @test
|
95 |
-
* @group amd
|
96 |
-
* @group config
|
97 |
-
*/
|
98 |
-
public function assertNewsletterModuleInCommunityCodePool()
|
99 |
-
{
|
100 |
-
$this->assertModuleCodePool('community');
|
101 |
-
}
|
102 |
-
|
103 |
-
// }}}
|
104 |
-
// {{{ assertNewsletterModelAliases()
|
105 |
-
|
106 |
-
/**
|
107 |
-
* @test
|
108 |
-
* @group amd
|
109 |
-
* @group config
|
110 |
-
* @dataProvider modelsProvider
|
111 |
-
*/
|
112 |
-
public function assertNewsletterModelAliases(
|
113 |
-
$classAlias,
|
114 |
-
$expectedClassName
|
115 |
-
) {
|
116 |
-
$this->assertModelAlias($classAlias, $expectedClassName);
|
117 |
-
}
|
118 |
-
|
119 |
-
// }}}
|
120 |
-
// {{{ assertNewsletterResourceModelAliases()
|
121 |
-
|
122 |
-
/**
|
123 |
-
* @test
|
124 |
-
* @group amd
|
125 |
-
* @group config
|
126 |
-
* @dataProvider resourceModelProvider
|
127 |
-
*/
|
128 |
-
public function assertNewsletterResourceModelAliases(
|
129 |
-
$classAlias,
|
130 |
-
$expectedClassName
|
131 |
-
) {
|
132 |
-
$this->assertResourceModelAlias($classAlias, $expectedClassName);
|
133 |
-
}
|
134 |
-
|
135 |
-
// }}}
|
136 |
-
// {{{ assertNewsletterBlockAliases()
|
137 |
-
|
138 |
-
/**
|
139 |
-
* @test
|
140 |
-
* @group amd
|
141 |
-
* @group config
|
142 |
-
* @dataProvider blocksProvider
|
143 |
-
*/
|
144 |
-
public function assertNewsletterBlockAliases(
|
145 |
-
$classAlias,
|
146 |
-
$expectedClassName
|
147 |
-
) {
|
148 |
-
$this->assertBlockAlias($classAlias, $expectedClassName);
|
149 |
-
}
|
150 |
-
|
151 |
-
// }}}
|
152 |
-
// {{{ assertNewsletterHelperAliases()
|
153 |
-
|
154 |
-
/**
|
155 |
-
* @test
|
156 |
-
* @group amd
|
157 |
-
* @group config
|
158 |
-
* @dataProvider helpersProvider
|
159 |
-
*/
|
160 |
-
public function assertNewsletterHelperAliases(
|
161 |
-
$classAlias,
|
162 |
-
$expectedClassName
|
163 |
-
) {
|
164 |
-
$this->assertHelperAlias($classAlias, $expectedClassName);
|
165 |
-
}
|
166 |
-
|
167 |
-
// }}}
|
168 |
-
// {{{ assertNewsletterEventObserversDefined()
|
169 |
-
|
170 |
-
/**
|
171 |
-
* test
|
172 |
-
* @group config
|
173 |
-
* @group amd
|
174 |
-
* @dataProvider observersProvider
|
175 |
-
*/
|
176 |
-
public function assertNewsletterEventObserversDefined(
|
177 |
-
$area,
|
178 |
-
$eventName,
|
179 |
-
$observerClassAlias,
|
180 |
-
$observerMethod
|
181 |
-
) {
|
182 |
-
$this->assertEventObserverDefined(
|
183 |
-
$area,
|
184 |
-
$eventName,
|
185 |
-
$observerClassAlias,
|
186 |
-
$observerMethod
|
187 |
-
);
|
188 |
-
}
|
189 |
-
|
190 |
-
// }}}
|
191 |
-
// {{{ assertNewsletterLayoutFileDefined()
|
192 |
-
|
193 |
-
/**
|
194 |
-
* test
|
195 |
-
* @group config
|
196 |
-
* @group amd
|
197 |
-
* @dataProvider definedLayoutFilesProvider
|
198 |
-
*/
|
199 |
-
public function assertNewsletterLayoutFileDefined($area, $expectedFileName)
|
200 |
-
{
|
201 |
-
$this->assertLayoutFileDefined($area, $expectedFileName);
|
202 |
-
}
|
203 |
-
|
204 |
-
// }}}
|
205 |
-
// {{{ assertNewsletterLayoutFileExistsForDefaultTheme()
|
206 |
-
|
207 |
-
/**
|
208 |
-
* test
|
209 |
-
* @group config
|
210 |
-
* @group amd
|
211 |
-
* @dataProvider themeLayoutFilesExistProvider
|
212 |
-
*/
|
213 |
-
public function assertNewsletterLayoutFileExistsForDefaultTheme(
|
214 |
-
$area,
|
215 |
-
$filename,
|
216 |
-
$theme,
|
217 |
-
$designPackage
|
218 |
-
) {
|
219 |
-
$this->assertLayoutFileExistsInTheme(
|
220 |
-
$area,
|
221 |
-
$filename,
|
222 |
-
$theme,
|
223 |
-
$designPackage
|
224 |
-
);
|
225 |
-
}
|
226 |
-
|
227 |
-
// }}}
|
228 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/Newsletter/controllers/Adminhtml/NewsletterController.php
CHANGED
@@ -2,26 +2,35 @@
|
|
2 |
|
3 |
/**
|
4 |
* @category Bronto
|
5 |
-
* @package
|
6 |
*/
|
7 |
class Bronto_Newsletter_Adminhtml_NewsletterController extends Mage_Adminhtml_Controller_Action
|
8 |
{
|
|
|
9 |
/**
|
10 |
* Run immediately
|
11 |
*/
|
12 |
public function runAction()
|
13 |
{
|
14 |
-
|
15 |
-
|
16 |
-
|
17 |
-
|
18 |
|
|
|
19 |
if ($storeIds = $helper->getStoreIds()) {
|
|
|
|
|
|
|
20 |
foreach ($storeIds as $storeId) {
|
21 |
-
$
|
22 |
-
|
|
|
|
|
|
|
23 |
$result['success'] += $storeResult['success'];
|
24 |
-
$result['error']
|
|
|
25 |
}
|
26 |
} else {
|
27 |
$result = $model->processSubscribers();
|
@@ -32,35 +41,101 @@ class Bronto_Newsletter_Adminhtml_NewsletterController extends Mage_Adminhtml_Co
|
|
32 |
} else {
|
33 |
$this->_getSession()->addError('Scheduled Sync failed: ' . $result);
|
34 |
}
|
35 |
-
|
36 |
} catch (Exception $e) {
|
37 |
$this->_getSession()->addError($e->getMessage());
|
38 |
-
|
39 |
}
|
40 |
|
41 |
-
$
|
|
|
|
|
42 |
}
|
43 |
|
44 |
/**
|
45 |
-
* Reset all
|
46 |
*/
|
47 |
public function resetAction()
|
48 |
{
|
49 |
-
$
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
$
|
56 |
-
|
57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
}
|
59 |
|
60 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
61 |
}
|
62 |
|
63 |
-
$this->
|
|
|
|
|
|
|
|
|
64 |
}
|
65 |
|
66 |
/**
|
@@ -101,4 +176,5 @@ class Bronto_Newsletter_Adminhtml_NewsletterController extends Mage_Adminhtml_Co
|
|
101 |
return false;
|
102 |
}
|
103 |
}
|
|
|
104 |
}
|
2 |
|
3 |
/**
|
4 |
* @category Bronto
|
5 |
+
* @package Bronto_Newsletter
|
6 |
*/
|
7 |
class Bronto_Newsletter_Adminhtml_NewsletterController extends Mage_Adminhtml_Controller_Action
|
8 |
{
|
9 |
+
|
10 |
/**
|
11 |
* Run immediately
|
12 |
*/
|
13 |
public function runAction()
|
14 |
{
|
15 |
+
$result = array('total' => 0, 'success' => 0, 'error' => 0);
|
16 |
+
$model = Mage::getModel('bronto_newsletter/observer');
|
17 |
+
$helper = Mage::helper('bronto_newsletter');
|
18 |
+
$limit = $helper->getLimit();
|
19 |
|
20 |
+
try {
|
21 |
if ($storeIds = $helper->getStoreIds()) {
|
22 |
+
if (!is_array($storeIds)) {
|
23 |
+
$storeIds = array($storeIds);
|
24 |
+
}
|
25 |
foreach ($storeIds as $storeId) {
|
26 |
+
if ($limit <= 0) {
|
27 |
+
continue;
|
28 |
+
}
|
29 |
+
$storeResult = $model->processSubscribersForStore($storeId, $limit);
|
30 |
+
$result['total'] += $storeResult['total'];
|
31 |
$result['success'] += $storeResult['success'];
|
32 |
+
$result['error'] += $storeResult['error'];
|
33 |
+
$limit = $limit - $storeResult['total'];
|
34 |
}
|
35 |
} else {
|
36 |
$result = $model->processSubscribers();
|
41 |
} else {
|
42 |
$this->_getSession()->addError('Scheduled Sync failed: ' . $result);
|
43 |
}
|
|
|
44 |
} catch (Exception $e) {
|
45 |
$this->_getSession()->addError($e->getMessage());
|
46 |
+
$helper->writeError($e);
|
47 |
}
|
48 |
|
49 |
+
$returnParams = array('section' => 'bronto_newsletter');
|
50 |
+
$returnParams = array_merge($returnParams, $helper->getScopeParams());
|
51 |
+
$this->_redirect('*/system_config/edit', $returnParams);
|
52 |
}
|
53 |
|
54 |
/**
|
55 |
+
* Reset all Subscribers
|
56 |
*/
|
57 |
public function resetAction()
|
58 |
{
|
59 |
+
$helper = Mage::helper('bronto_newsletter');
|
60 |
+
$resource = Mage::getResourceModel('bronto_newsletter/queue');
|
61 |
+
$adapter = $resource->getWriteAdapter();
|
62 |
+
|
63 |
+
try {
|
64 |
+
$adapter->update(
|
65 |
+
$resource->getTable('bronto_newsletter/queue'),
|
66 |
+
array(
|
67 |
+
'imported' => 2,
|
68 |
+
'bronto_suppressed' => null,
|
69 |
+
),
|
70 |
+
array('imported' => 1)
|
71 |
+
);
|
72 |
+
} catch (Exception $e) {
|
73 |
+
$helper->writeError($e);
|
74 |
+
$this->_getSession()->addError('Reset failed: ' . $e->getMessage());
|
75 |
}
|
76 |
|
77 |
+
$returnParams = array('section' => 'bronto_newsletter');
|
78 |
+
$returnParams = array_merge($returnParams, $helper->getScopeParams());
|
79 |
+
$this->_redirect('*/system_config/edit', $returnParams);
|
80 |
+
}
|
81 |
+
|
82 |
+
/**
|
83 |
+
* Pull Subscribers from Subscribers Table if not in queue
|
84 |
+
*/
|
85 |
+
public function syncAction()
|
86 |
+
{
|
87 |
+
$helper = Mage::helper('bronto_newsletter');
|
88 |
+
$imported = 0;
|
89 |
+
|
90 |
+
try {
|
91 |
+
$subscribers = $helper->getMissingSubscribers();
|
92 |
+
$waiting = count($subscribers);
|
93 |
+
|
94 |
+
if ($waiting > 0) {
|
95 |
+
foreach ($subscribers as $subscriber) {
|
96 |
+
// Convert Magento subscriber status to bronto subscriber status
|
97 |
+
switch ($subscriber['subscriber_status']) {
|
98 |
+
case Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED:
|
99 |
+
$status = Bronto_Api_Contact::STATUS_ACTIVE;
|
100 |
+
break;
|
101 |
+
|
102 |
+
case Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED:
|
103 |
+
$status = Bronto_Api_Contact::STATUS_UNSUBSCRIBED;
|
104 |
+
break;
|
105 |
+
|
106 |
+
case Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED:
|
107 |
+
$status = Bronto_Api_Contact::STATUS_UNCONFIRMED;
|
108 |
+
break;
|
109 |
+
|
110 |
+
case Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE:
|
111 |
+
default:
|
112 |
+
$status = Bronto_Api_Contact::STATUS_TRANSACTIONAL;
|
113 |
+
break;
|
114 |
+
}
|
115 |
+
|
116 |
+
// Create Subscriber
|
117 |
+
Mage::getModel('bronto_newsletter/queue')->getContactRow($subscriber['subscriber_id'], $subscriber['store_id'])
|
118 |
+
->setStatus($status)
|
119 |
+
->setSubscriberEmail($subscriber['subscriber_email'])
|
120 |
+
->setMessagePreference('html')
|
121 |
+
->setSource('api')
|
122 |
+
->setImported(0)
|
123 |
+
->setBrontoSuppressed(NULL)
|
124 |
+
->save();
|
125 |
+
|
126 |
+
$imported++;
|
127 |
+
}
|
128 |
+
}
|
129 |
+
} catch (Exception $e) {
|
130 |
+
$helper->writeError($e);
|
131 |
+
$this->_getSession()->addError('Sync failed: ' . $e->getMessage());
|
132 |
}
|
133 |
|
134 |
+
$this->_getSession()->addSuccess(sprintf("%d of %d Subscribers were added to the Queue", $imported, $waiting));
|
135 |
+
|
136 |
+
$returnParams = array('section' => 'bronto_newsletter');
|
137 |
+
$returnParams = array_merge($returnParams, $helper->getScopeParams());
|
138 |
+
$this->_redirect('*/system_config/edit', $returnParams);
|
139 |
}
|
140 |
|
141 |
/**
|
176 |
return false;
|
177 |
}
|
178 |
}
|
179 |
+
|
180 |
}
|
app/code/community/Bronto/Newsletter/etc/adminhtml.xml
CHANGED
@@ -9,7 +9,8 @@
|
|
9 |
<config>
|
10 |
<children>
|
11 |
<bronto_newsletter module="bronto_newsletter">
|
12 |
-
<title>Bronto Newsletter Section</title>
|
|
|
13 |
</bronto_newsletter>
|
14 |
</children>
|
15 |
</config>
|
@@ -19,4 +20,4 @@
|
|
19 |
</admin>
|
20 |
</resources>
|
21 |
</acl>
|
22 |
-
</config>
|
9 |
<config>
|
10 |
<children>
|
11 |
<bronto_newsletter module="bronto_newsletter">
|
12 |
+
<title>Bronto Newsletter Opt-In Section</title>
|
13 |
+
<sort_order>9997</sort_order>
|
14 |
</bronto_newsletter>
|
15 |
</children>
|
16 |
</config>
|
20 |
</admin>
|
21 |
</resources>
|
22 |
</acl>
|
23 |
+
</config>
|
app/code/community/Bronto/Newsletter/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Bronto_Newsletter>
|
5 |
-
<version>1.4.
|
6 |
</Bronto_Newsletter>
|
7 |
</modules>
|
8 |
<global>
|
@@ -24,7 +24,9 @@
|
|
24 |
<bronto_newsletter_mysql4>
|
25 |
<class>Bronto_Newsletter_Model_Mysql4</class>
|
26 |
<entities>
|
27 |
-
<queue
|
|
|
|
|
28 |
</entities>
|
29 |
</bronto_newsletter_mysql4>
|
30 |
</models>
|
@@ -94,6 +96,7 @@
|
|
94 |
<interval>15</interval>
|
95 |
<minutes>0</minutes>
|
96 |
<limit>250</limit>
|
|
|
97 |
</settings>
|
98 |
<checkout>
|
99 |
<show_to_guests>1</show_to_guests>
|
@@ -108,9 +111,18 @@
|
|
108 |
<update_status>1</update_status>
|
109 |
</contacts>
|
110 |
</bronto_newsletter>
|
111 |
-
</default>
|
112 |
<adminhtml>
|
113 |
<events>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
114 |
<controller_action_predispatch>
|
115 |
<observers>
|
116 |
<bronto_newsletter_controller_action_predispatch>
|
@@ -120,25 +132,6 @@
|
|
120 |
</observers>
|
121 |
</controller_action_predispatch>
|
122 |
</events>
|
123 |
-
<acl>
|
124 |
-
<resources>
|
125 |
-
<admin>
|
126 |
-
<children>
|
127 |
-
<system>
|
128 |
-
<children>
|
129 |
-
<config>
|
130 |
-
<children>
|
131 |
-
<bronto_newsletter module="bronto_newsletter">
|
132 |
-
<title>Bronto Newsletter Section</title>
|
133 |
-
</bronto_newsletter>
|
134 |
-
</children>
|
135 |
-
</config>
|
136 |
-
</children>
|
137 |
-
</system>
|
138 |
-
</children>
|
139 |
-
</admin>
|
140 |
-
</resources>
|
141 |
-
</acl>
|
142 |
</adminhtml>
|
143 |
<admin>
|
144 |
<routers>
|
@@ -152,13 +145,15 @@
|
|
152 |
</routers>
|
153 |
<fieldsets>
|
154 |
<customer_account>
|
155 |
-
<bronto_contact_id
|
|
|
|
|
156 |
</customer_account>
|
157 |
</fieldsets>
|
158 |
</admin>
|
159 |
<crontab>
|
160 |
<jobs>
|
161 |
-
<bronto_newsletter_import>
|
162 |
<run>
|
163 |
<model>bronto_newsletter/observer::processSubscribers</model>
|
164 |
</run>
|
@@ -167,10 +162,10 @@
|
|
167 |
</crontab>
|
168 |
|
169 |
<phpunit>
|
170 |
-
|
171 |
-
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
</phpunit>
|
176 |
</config>
|
2 |
<config>
|
3 |
<modules>
|
4 |
<Bronto_Newsletter>
|
5 |
+
<version>1.4.5</version>
|
6 |
</Bronto_Newsletter>
|
7 |
</modules>
|
8 |
<global>
|
24 |
<bronto_newsletter_mysql4>
|
25 |
<class>Bronto_Newsletter_Model_Mysql4</class>
|
26 |
<entities>
|
27 |
+
<queue>
|
28 |
+
<table>bronto_newsletter_queue</table>
|
29 |
+
</queue>
|
30 |
</entities>
|
31 |
</bronto_newsletter_mysql4>
|
32 |
</models>
|
96 |
<interval>15</interval>
|
97 |
<minutes>0</minutes>
|
98 |
<limit>250</limit>
|
99 |
+
<sync_limit>1000</sync_limit>
|
100 |
</settings>
|
101 |
<checkout>
|
102 |
<show_to_guests>1</show_to_guests>
|
111 |
<update_status>1</update_status>
|
112 |
</contacts>
|
113 |
</bronto_newsletter>
|
114 |
+
</default>
|
115 |
<adminhtml>
|
116 |
<events>
|
117 |
+
<bronto_newsletter_enable>
|
118 |
+
<observers>
|
119 |
+
<bronto_newsletter_enable>
|
120 |
+
<type>singleton</type>
|
121 |
+
<class>bronto_newsletter/observer</class>
|
122 |
+
<method>watchEnableAction</method>
|
123 |
+
</bronto_newsletter_enable>
|
124 |
+
</observers>
|
125 |
+
</bronto_newsletter_enable>
|
126 |
<controller_action_predispatch>
|
127 |
<observers>
|
128 |
<bronto_newsletter_controller_action_predispatch>
|
132 |
</observers>
|
133 |
</controller_action_predispatch>
|
134 |
</events>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
135 |
</adminhtml>
|
136 |
<admin>
|
137 |
<routers>
|
145 |
</routers>
|
146 |
<fieldsets>
|
147 |
<customer_account>
|
148 |
+
<bronto_contact_id>
|
149 |
+
<create>1</create>
|
150 |
+
</bronto_contact_id>
|
151 |
</customer_account>
|
152 |
</fieldsets>
|
153 |
</admin>
|
154 |
<crontab>
|
155 |
<jobs>
|
156 |
+
<bronto_newsletter_import>
|
157 |
<run>
|
158 |
<model>bronto_newsletter/observer::processSubscribers</model>
|
159 |
</run>
|
162 |
</crontab>
|
163 |
|
164 |
<phpunit>
|
165 |
+
<suite>
|
166 |
+
<modules>
|
167 |
+
<Bronto_Newsletter/>
|
168 |
+
</modules>
|
169 |
+
</suite>
|
170 |
</phpunit>
|
171 |
</config>
|
app/code/community/Bronto/Newsletter/etc/system.xml
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
<label>Newsletter Opt-In</label>
|
6 |
<tab>bronto</tab>
|
7 |
<frontend_type>text</frontend_type>
|
8 |
-
<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>
|
@@ -31,6 +31,7 @@
|
|
31 |
<label>Enable Module</label>
|
32 |
<frontend_type>select</frontend_type>
|
33 |
<frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
|
|
|
34 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
35 |
<sort_order>0</sort_order>
|
36 |
<show_in_default>1</show_in_default>
|
@@ -39,7 +40,9 @@
|
|
39 |
</enabled>
|
40 |
<frequency>
|
41 |
<label>Frequency</label>
|
42 |
-
<depends
|
|
|
|
|
43 |
<frontend_type>select</frontend_type>
|
44 |
<source_model>bronto_common/system_config_source_cron_frequency</source_model>
|
45 |
<backend_model>bronto_newsletter/system_config_backend_cron</backend_model>
|
@@ -50,7 +53,9 @@
|
|
50 |
</frequency>
|
51 |
<interval>
|
52 |
<label>Interval</label>
|
53 |
-
<depends
|
|
|
|
|
54 |
<frontend_type>select</frontend_type>
|
55 |
<source_model>bronto_common/system_config_source_cron_minutes</source_model>
|
56 |
<sort_order>30</sort_order>
|
@@ -61,7 +66,9 @@
|
|
61 |
</interval>
|
62 |
<minutes>
|
63 |
<label>Minute of the Hour</label>
|
64 |
-
<depends
|
|
|
|
|
65 |
<frontend_type>text</frontend_type>
|
66 |
<sort_order>40</sort_order>
|
67 |
<show_in_default>1</show_in_default>
|
@@ -71,7 +78,9 @@
|
|
71 |
</minutes>
|
72 |
<time>
|
73 |
<label>Start Time</label>
|
74 |
-
<depends
|
|
|
|
|
75 |
<frontend_type>time</frontend_type>
|
76 |
<sort_order>50</sort_order>
|
77 |
<show_in_default>1</show_in_default>
|
@@ -80,19 +89,35 @@
|
|
80 |
</time>
|
81 |
<limit>
|
82 |
<label>Limit</label>
|
83 |
-
<depends
|
|
|
|
|
84 |
<frontend_type>select</frontend_type>
|
85 |
-
<source_model>
|
86 |
<sort_order>60</sort_order>
|
87 |
<show_in_default>1</show_in_default>
|
88 |
<show_in_website>0</show_in_website>
|
89 |
<show_in_store>0</show_in_store>
|
90 |
-
<comment>Total
|
91 |
</limit>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
</fields>
|
93 |
</settings>
|
94 |
<checkout>
|
95 |
<label>Checkout</label>
|
|
|
96 |
<frontend_type>text</frontend_type>
|
97 |
<sort_order>2</sort_order>
|
98 |
<show_in_default>1</show_in_default>
|
@@ -144,37 +169,18 @@
|
|
144 |
<show_in_website>1</show_in_website>
|
145 |
<show_in_store>1</show_in_store>
|
146 |
</label_text>
|
147 |
-
<!-- Deprecated: Custom Billing Template not needed
|
148 |
-
<use_custom_template>
|
149 |
-
<label>Use Custom Billing Template?</label>
|
150 |
-
<frontend_type>select</frontend_type>
|
151 |
-
<source_model>adminhtml/system_config_source_yesno</source_model>
|
152 |
-
<sort_order>20</sort_order>
|
153 |
-
<show_in_default>1</show_in_default>
|
154 |
-
<show_in_website>1</show_in_website>
|
155 |
-
<show_in_store>1</show_in_store>
|
156 |
-
<comment><![CDATA[If 'No', uses: <code>bronto/newsletter/billing.phtml</code>]]></comment>
|
157 |
-
</use_custom_template>
|
158 |
-
<billing_template>
|
159 |
-
<label>Billing Template Path</label>
|
160 |
-
<depends><use_custom_template>1</use_custom_template></depends>
|
161 |
-
<frontend_type>text</frontend_type>
|
162 |
-
<sort_order>21</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><![CDATA[<strong>Magento Default:</strong> <code>checkout/onepage/billing.phtml</code>]]></comment>
|
167 |
-
</billing_template>-->
|
168 |
</fields>
|
169 |
</checkout>
|
170 |
<contacts>
|
171 |
<label>Contacts</label>
|
|
|
172 |
<frontend_type>text</frontend_type>
|
173 |
<sort_order>3</sort_order>
|
174 |
<show_in_default>1</show_in_default>
|
175 |
<show_in_website>1</show_in_website>
|
176 |
<show_in_store>1</show_in_store>
|
177 |
-
<comment
|
|
|
178 |
<fields>
|
179 |
<update_status>
|
180 |
<label>Update Status</label>
|
5 |
<label>Newsletter Opt-In</label>
|
6 |
<tab>bronto</tab>
|
7 |
<frontend_type>text</frontend_type>
|
8 |
+
<sort_order>175</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>
|
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>
|
40 |
</enabled>
|
41 |
<frequency>
|
42 |
<label>Frequency</label>
|
43 |
+
<depends>
|
44 |
+
<enabled>1</enabled>
|
45 |
+
</depends>
|
46 |
<frontend_type>select</frontend_type>
|
47 |
<source_model>bronto_common/system_config_source_cron_frequency</source_model>
|
48 |
<backend_model>bronto_newsletter/system_config_backend_cron</backend_model>
|
53 |
</frequency>
|
54 |
<interval>
|
55 |
<label>Interval</label>
|
56 |
+
<depends>
|
57 |
+
<frequency>I</frequency>
|
58 |
+
</depends>
|
59 |
<frontend_type>select</frontend_type>
|
60 |
<source_model>bronto_common/system_config_source_cron_minutes</source_model>
|
61 |
<sort_order>30</sort_order>
|
66 |
</interval>
|
67 |
<minutes>
|
68 |
<label>Minute of the Hour</label>
|
69 |
+
<depends>
|
70 |
+
<frequency>H</frequency>
|
71 |
+
</depends>
|
72 |
<frontend_type>text</frontend_type>
|
73 |
<sort_order>40</sort_order>
|
74 |
<show_in_default>1</show_in_default>
|
78 |
</minutes>
|
79 |
<time>
|
80 |
<label>Start Time</label>
|
81 |
+
<depends>
|
82 |
+
<enabled>1</enabled>
|
83 |
+
</depends>
|
84 |
<frontend_type>time</frontend_type>
|
85 |
<sort_order>50</sort_order>
|
86 |
<show_in_default>1</show_in_default>
|
89 |
</time>
|
90 |
<limit>
|
91 |
<label>Limit</label>
|
92 |
+
<depends>
|
93 |
+
<enabled>1</enabled>
|
94 |
+
</depends>
|
95 |
<frontend_type>select</frontend_type>
|
96 |
+
<source_model>bronto_common/system_config_source_limit</source_model>
|
97 |
<sort_order>60</sort_order>
|
98 |
<show_in_default>1</show_in_default>
|
99 |
<show_in_website>0</show_in_website>
|
100 |
<show_in_store>0</show_in_store>
|
101 |
+
<comment>Total Subscribers to process every cron run.</comment>
|
102 |
</limit>
|
103 |
+
<sync_limit>
|
104 |
+
<label>Sync Limit</label>
|
105 |
+
<depends>
|
106 |
+
<enabled>1</enabled>
|
107 |
+
</depends>
|
108 |
+
<frontend_type>select</frontend_type>
|
109 |
+
<source_model>bronto_common/system_config_source_synclimit</source_model>
|
110 |
+
<sort_order>65</sort_order>
|
111 |
+
<show_in_default>1</show_in_default>
|
112 |
+
<show_in_website>0</show_in_website>
|
113 |
+
<show_in_store>0</show_in_store>
|
114 |
+
<comment>Total Subscribers to sync to queue at a time.</comment>
|
115 |
+
</sync_limit>
|
116 |
</fields>
|
117 |
</settings>
|
118 |
<checkout>
|
119 |
<label>Checkout</label>
|
120 |
+
<frontend_model>bronto_common/adminhtml_system_config_form_fieldset</frontend_model>
|
121 |
<frontend_type>text</frontend_type>
|
122 |
<sort_order>2</sort_order>
|
123 |
<show_in_default>1</show_in_default>
|
169 |
<show_in_website>1</show_in_website>
|
170 |
<show_in_store>1</show_in_store>
|
171 |
</label_text>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
172 |
</fields>
|
173 |
</checkout>
|
174 |
<contacts>
|
175 |
<label>Contacts</label>
|
176 |
+
<frontend_model>bronto_common/adminhtml_system_config_form_fieldset</frontend_model>
|
177 |
<frontend_type>text</frontend_type>
|
178 |
<sort_order>3</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 |
+
<comment>
|
183 |
+
<![CDATA[<strong style="color: red">Warning!</strong> If <strong>Yes</strong>, the Magento subscriber status will overwrite the contact status in Bronto. See <a href="http://a.bron.to/magento" target="_blank">documentation</a> for more details.]]></comment>
|
184 |
<fields>
|
185 |
<update_status>
|
186 |
<label>Update Status</label>
|
app/code/community/Bronto/Newsletter/sql/bronto_newsletter_setup/mysql4-install-1.4.0.php
CHANGED
@@ -6,7 +6,7 @@ $installer = $this;
|
|
6 |
$installer->startSetup();
|
7 |
|
8 |
try {
|
9 |
-
$installer->run("
|
10 |
|
11 |
CREATE TABLE `{$this->getTable('bronto_newsletter_queue')}` (
|
12 |
`status` varchar(32) CHARACTER SET utf8 NOT NULL,
|
6 |
$installer->startSetup();
|
7 |
|
8 |
try {
|
9 |
+
$installer->run("
|
10 |
|
11 |
CREATE TABLE `{$this->getTable('bronto_newsletter_queue')}` (
|
12 |
`status` varchar(32) CHARACTER SET utf8 NOT NULL,
|
app/code/community/Bronto/Newsletter/sql/bronto_newsletter_setup/mysql4-install-1.4.4.php
ADDED
@@ -0,0 +1,29 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
5 |
+
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
try {
|
9 |
+
$installer->run("
|
10 |
+
DROP TABLE IF EXISTS `{$this->getTable('bronto_newsletter_queue')}`;
|
11 |
+
|
12 |
+
CREATE TABLE `{$this->getTable('bronto_newsletter_queue')}` (
|
13 |
+
`queue_id` int(11) NOT NULL AUTO_INCREMENT,
|
14 |
+
`subscriber_id` int(11) NOT NULL,
|
15 |
+
`store` tinyint(4) NOT NULL,
|
16 |
+
`status` varchar(32) CHARACTER SET utf8 NOT NULL,
|
17 |
+
`message_preference` varchar(16) CHARACTER SET utf8 NOT NULL,
|
18 |
+
`source` varchar(16) CHARACTER SET utf8 NOT NULL,
|
19 |
+
`imported` tinyint(4) NOT NULL DEFAULT '0',
|
20 |
+
`subscriber_email` varchar(255) CHARACTER SET utf8 NOT NULL,
|
21 |
+
PRIMARY KEY (`queue_id`,`subscriber_id`,`store`)
|
22 |
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
23 |
+
");
|
24 |
+
|
25 |
+
} catch (Exception $e) {
|
26 |
+
throw new RuntimeException('Failed Creating Newsletter Queue Table: ' . $e->getMessage());
|
27 |
+
}
|
28 |
+
|
29 |
+
$installer->endSetup();
|
app/code/community/Bronto/Newsletter/sql/bronto_newsletter_setup/mysql4-install-1.4.5.php
ADDED
@@ -0,0 +1,56 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
5 |
+
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
try {
|
9 |
+
$installer->run("
|
10 |
+
DROP TABLE IF EXISTS `{$this->getTable('bronto_newsletter_queue')}`;
|
11 |
+
|
12 |
+
CREATE TABLE `{$this->getTable('bronto_newsletter_queue')}` (
|
13 |
+
`queue_id` int(11) NOT NULL AUTO_INCREMENT,
|
14 |
+
`subscriber_id` int(11) NOT NULL,
|
15 |
+
`store` tinyint(4) NOT NULL,
|
16 |
+
`status` varchar(32) CHARACTER SET utf8 NOT NULL,
|
17 |
+
`message_preference` varchar(16) CHARACTER SET utf8 NOT NULL,
|
18 |
+
`source` varchar(16) CHARACTER SET utf8 NOT NULL,
|
19 |
+
`imported` tinyint(4) NOT NULL DEFAULT '0',
|
20 |
+
`subscriber_email` varchar(255) CHARACTER SET utf8 NOT NULL,
|
21 |
+
`bronto_suppressed` varchar(255) DEFAULT NULL,
|
22 |
+
PRIMARY KEY (`queue_id`,`subscriber_id`,`store`)
|
23 |
+
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
|
24 |
+
");
|
25 |
+
|
26 |
+
} catch (Exception $e) {
|
27 |
+
throw new RuntimeException('Failed Creating Newsletter Queue Table: ' . $e->getMessage());
|
28 |
+
}
|
29 |
+
|
30 |
+
try {
|
31 |
+
// Populate New Table
|
32 |
+
$installer->run("
|
33 |
+
INSERT IGNORE INTO `{$this->getTable('bronto_newsletter_queue')}`
|
34 |
+
(
|
35 |
+
SELECT
|
36 |
+
NULL,
|
37 |
+
`newsletter`.`subscriber_id`,
|
38 |
+
`newsletter`.`store_id`,
|
39 |
+
IF(`newsletter`.`subscriber_status` = 1, 'active', IF(`newsletter`.`subscriber_status` = 2, 'transactional', 'unsub')),
|
40 |
+
'html',
|
41 |
+
'api',
|
42 |
+
0,
|
43 |
+
`newsletter`.`subscriber_email`,
|
44 |
+
null
|
45 |
+
FROM `{$this->getTable('newsletter_subscriber')}` `newsletter`
|
46 |
+
WHERE NOT EXISTS(
|
47 |
+
SELECT 1 FROM `{$this->getTable('bronto_newsletter_queue')}` `queue` WHERE
|
48 |
+
`queue`.`subscriber_id`=`newsletter`.`subscriber_id` OR
|
49 |
+
`queue`.`subscriber_email`=`newsletter`.`subscriber_email`
|
50 |
+
));
|
51 |
+
");
|
52 |
+
} catch (Exception $e) {
|
53 |
+
throw new RuntimeException('Failed Populating Newsletter Queue Table: ' . $e->getMessage());
|
54 |
+
}
|
55 |
+
|
56 |
+
$installer->endSetup();
|
app/code/community/Bronto/Newsletter/sql/bronto_newsletter_setup/mysql4-upgrade-1.4.4-1.4.5.php
ADDED
@@ -0,0 +1,44 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
$installer = $this;
|
4 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
5 |
+
|
6 |
+
$installer->startSetup();
|
7 |
+
|
8 |
+
try {
|
9 |
+
$installer->run("
|
10 |
+
ALTER TABLE `{$this->getTable('bronto_newsletter_queue')}`
|
11 |
+
ADD COLUMN `bronto_suppressed` varchar(255) DEFAULT NULL;
|
12 |
+
");
|
13 |
+
|
14 |
+
} catch (Exception $e) {
|
15 |
+
throw new RuntimeException('Error altering table');
|
16 |
+
}
|
17 |
+
|
18 |
+
try {
|
19 |
+
// Populate New Table
|
20 |
+
$installer->run("
|
21 |
+
INSERT IGNORE INTO `{$this->getTable('bronto_newsletter_queue')}`
|
22 |
+
(
|
23 |
+
SELECT
|
24 |
+
NULL,
|
25 |
+
`newsletter`.`subscriber_id`,
|
26 |
+
`newsletter`.`store_id`,
|
27 |
+
IF(`newsletter`.`subscriber_status` = 1, 'active', IF(`newsletter`.`subscriber_status` = 2, 'transactional', 'unsub')),
|
28 |
+
'html',
|
29 |
+
'api',
|
30 |
+
0,
|
31 |
+
`newsletter`.`subscriber_email`,
|
32 |
+
null
|
33 |
+
FROM `{$this->getTable('newsletter_subscriber')}` `newsletter`
|
34 |
+
WHERE NOT EXISTS(
|
35 |
+
SELECT 1 FROM `{$this->getTable('bronto_newsletter_queue')}` `queue` WHERE
|
36 |
+
`queue`.`subscriber_id`=`newsletter`.`subscriber_id` OR
|
37 |
+
`queue`.`subscriber_email`=`newsletter`.`subscriber_email`
|
38 |
+
));
|
39 |
+
");
|
40 |
+
} catch (Exception $e) {
|
41 |
+
throw new RuntimeException('Failed Populating Newsletter Queue Table: ' . $e->getMessage());
|
42 |
+
}
|
43 |
+
|
44 |
+
$installer->endSetup();
|
app/code/community/Bronto/Order/Block/Adminhtml/Sales/Order/View/Tab/Info.php
CHANGED
@@ -14,16 +14,16 @@ class Bronto_Order_Block_Adminhtml_Sales_Order_View_Tab_Info extends Mage_Adminh
|
|
14 |
*/
|
15 |
protected function _toHtml()
|
16 |
{
|
17 |
-
$order
|
18 |
$orderRow = Mage::getModel('bronto_order/queue')->load($order->getId());
|
19 |
-
|
20 |
-
$tid
|
21 |
$imported = $orderRow->getBrontoImported();
|
22 |
|
23 |
-
$deliveryHtml = empty($tid)
|
24 |
$importedHtml = empty($imported) ? $this->_getNoHtml() : $this->_getYesHtml();
|
25 |
|
26 |
-
$html
|
27 |
$html .= <<<SCRIPT
|
28 |
<script>
|
29 |
var orderTable, orderTableRow, orderTableCell;
|
14 |
*/
|
15 |
protected function _toHtml()
|
16 |
{
|
17 |
+
$order = $this->getOrder();
|
18 |
$orderRow = Mage::getModel('bronto_order/queue')->load($order->getId());
|
19 |
+
|
20 |
+
$tid = $orderRow->getBrontoTid();
|
21 |
$imported = $orderRow->getBrontoImported();
|
22 |
|
23 |
+
$deliveryHtml = empty($tid) ? $this->_getNoHtml() : $this->_getYesHtml();
|
24 |
$importedHtml = empty($imported) ? $this->_getNoHtml() : $this->_getYesHtml();
|
25 |
|
26 |
+
$html = parent::_toHtml();
|
27 |
$html .= <<<SCRIPT
|
28 |
<script>
|
29 |
var orderTable, orderTableRow, orderTableCell;
|
app/code/community/Bronto/Order/Block/Adminhtml/System/Config/About.php
CHANGED
@@ -10,15 +10,15 @@ class Bronto_Order_Block_Adminhtml_System_Config_About extends Bronto_Common_Blo
|
|
10 |
|
11 |
/**
|
12 |
* Description for protected
|
13 |
-
* @var string
|
14 |
* @access protected
|
15 |
*/
|
16 |
protected $_module = 'bronto_order';
|
17 |
|
18 |
/**
|
19 |
* Description for protected
|
20 |
-
* @var string
|
21 |
* @access protected
|
22 |
*/
|
23 |
-
protected $_name
|
24 |
}
|
10 |
|
11 |
/**
|
12 |
* Description for protected
|
13 |
+
* @var string
|
14 |
* @access protected
|
15 |
*/
|
16 |
protected $_module = 'bronto_order';
|
17 |
|
18 |
/**
|
19 |
* Description for protected
|
20 |
+
* @var string
|
21 |
* @access protected
|
22 |
*/
|
23 |
+
protected $_name = 'Bronto Order Import for Magento';
|
24 |
}
|
app/code/community/Bronto/Order/Block/Adminhtml/System/Config/Cron.php
CHANGED
@@ -22,10 +22,7 @@ class Bronto_Order_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Bloc
|
|
22 |
*/
|
23 |
protected function _prepareLayout()
|
24 |
{
|
25 |
-
$
|
26 |
-
if ($missingOrders > 0) {
|
27 |
-
$this->addButton($this->getLayout()->createBlock('bronto_order/adminhtml_widget_button_sync'));
|
28 |
-
}
|
29 |
$this->addButton($this->getLayout()->createBlock('bronto_order/adminhtml_widget_button_reset'));
|
30 |
$this->addButton($this->getLayout()->createBlock('bronto_order/adminhtml_widget_button_run'));
|
31 |
|
@@ -38,7 +35,6 @@ class Bronto_Order_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Bloc
|
|
38 |
protected function getProgressBarTotal()
|
39 |
{
|
40 |
return $this->getOrderResourceCollection()
|
41 |
-
->addBrontoNotSuppressedFilter()
|
42 |
->addBrontoHasOrderFilter()
|
43 |
->getSize();
|
44 |
}
|
@@ -55,18 +51,57 @@ class Bronto_Order_Block_Adminhtml_System_Config_Cron extends Bronto_Common_Bloc
|
|
55 |
->getSize();
|
56 |
}
|
57 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
58 |
/**
|
59 |
* @return Bronto_Order_Model_Mysql4_Queue_Collection
|
60 |
*/
|
61 |
protected function getOrderResourceCollection()
|
62 |
{
|
63 |
$collection = Mage::getModel('bronto_order/queue')->getCollection();
|
64 |
-
$storeIds
|
65 |
-
|
66 |
if ($storeIds) {
|
67 |
$collection->addStoreFilter($storeIds);
|
68 |
}
|
69 |
-
|
70 |
return $collection;
|
71 |
}
|
72 |
}
|
22 |
*/
|
23 |
protected function _prepareLayout()
|
24 |
{
|
25 |
+
$this->addButton($this->getLayout()->createBlock('bronto_order/adminhtml_widget_button_sync'));
|
|
|
|
|
|
|
26 |
$this->addButton($this->getLayout()->createBlock('bronto_order/adminhtml_widget_button_reset'));
|
27 |
$this->addButton($this->getLayout()->createBlock('bronto_order/adminhtml_widget_button_run'));
|
28 |
|
35 |
protected function getProgressBarTotal()
|
36 |
{
|
37 |
return $this->getOrderResourceCollection()
|
|
|
38 |
->addBrontoHasOrderFilter()
|
39 |
->getSize();
|
40 |
}
|
51 |
->getSize();
|
52 |
}
|
53 |
|
54 |
+
/**
|
55 |
+
* @return int
|
56 |
+
*/
|
57 |
+
protected function getProgressBarSuppressed()
|
58 |
+
{
|
59 |
+
return $this->getOrderResourceCollection()
|
60 |
+
->addBrontoNotImportedFilter()
|
61 |
+
->addBrontoSuppressedFilter()
|
62 |
+
->getSize();
|
63 |
+
}
|
64 |
+
|
65 |
+
/**
|
66 |
+
* Get number of customers not imported from stores that don't have module enabled
|
67 |
+
* @return int
|
68 |
+
*/
|
69 |
+
protected function getProgressBarDisabled()
|
70 |
+
{
|
71 |
+
$collection = Mage::getModel('bronto_order/queue')->getCollection();
|
72 |
+
$storeIds = Mage::helper('bronto_order')->getStoreIds();
|
73 |
+
|
74 |
+
if ($storeIds) {
|
75 |
+
if (!is_array($storeIds)) {
|
76 |
+
$storeIds = array($storeIds);
|
77 |
+
}
|
78 |
+
foreach ($storeIds as $key => $storeId) {
|
79 |
+
if (Mage::getStoreConfig(Bronto_Order_Helper_Data::XML_PATH_ENABLED, $storeId)) {
|
80 |
+
unset($storeIds[$key]);
|
81 |
+
}
|
82 |
+
}
|
83 |
+
$collection->addStoreFilter($storeIds);
|
84 |
+
|
85 |
+
return $collection->addBrontoNotImportedFilter()
|
86 |
+
->addBrontoNotSuppressedFilter()
|
87 |
+
->getSize();
|
88 |
+
|
89 |
+
}
|
90 |
+
return 0;
|
91 |
+
}
|
92 |
+
|
93 |
/**
|
94 |
* @return Bronto_Order_Model_Mysql4_Queue_Collection
|
95 |
*/
|
96 |
protected function getOrderResourceCollection()
|
97 |
{
|
98 |
$collection = Mage::getModel('bronto_order/queue')->getCollection();
|
99 |
+
$storeIds = Mage::helper('bronto_order')->getStoreIds();
|
100 |
+
|
101 |
if ($storeIds) {
|
102 |
$collection->addStoreFilter($storeIds);
|
103 |
}
|
104 |
+
|
105 |
return $collection;
|
106 |
}
|
107 |
}
|
app/code/community/Bronto/Order/Block/Adminhtml/Widget/Button/Reset.php
CHANGED
@@ -12,17 +12,15 @@ class Bronto_Order_Block_Adminhtml_Widget_Button_Reset extends Mage_Adminhtml_Bl
|
|
12 |
*/
|
13 |
protected function _construct()
|
14 |
{
|
15 |
-
$params = array(
|
16 |
-
'section' => Mage::app()->getRequest()->getParam('section'),
|
17 |
-
'website' => Mage::app()->getRequest()->getParam('website'),
|
18 |
-
'store' => Mage::app()->getRequest()->getParam('store'),
|
19 |
-
);
|
20 |
$this->setLabel('Reset All Orders');
|
21 |
-
$this->setOnClick("deleteConfirm('This will mark all orders as not-imported and will cause the importer to re-process each order again.\\n\\nAre you sure you want to do this?', '" . Mage::helper('
|
22 |
$this->setClass('delete');
|
23 |
|
24 |
-
if (!
|
25 |
$this->setDisabled(true)->setClass('disabled');
|
|
|
|
|
|
|
26 |
}
|
27 |
}
|
28 |
}
|
12 |
*/
|
13 |
protected function _construct()
|
14 |
{
|
|
|
|
|
|
|
|
|
|
|
15 |
$this->setLabel('Reset All Orders');
|
16 |
+
$this->setOnClick("deleteConfirm('This will mark all orders as not-imported and will cause the importer to re-process each order again.\\n\\nAre you sure you want to do this?', '" . Mage::helper('bronto_order')->getScopeUrl('*/order/reset') . "'); return false;");
|
17 |
$this->setClass('delete');
|
18 |
|
19 |
+
if (!Mage::helper('bronto_order')->isModuleActive() || (!Mage::helper('bronto_order')->isDebugEnabled() && !Mage::helper('bronto_order')->isTestModeEnabled())) {
|
20 |
$this->setDisabled(true)->setClass('disabled');
|
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/Order/Block/Adminhtml/Widget/Button/Run.php
CHANGED
@@ -5,22 +5,21 @@
|
|
5 |
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
* @version 2.0.0
|
7 |
*/
|
8 |
-
class Bronto_Order_Block_Adminhtml_Widget_Button_Run
|
|
|
9 |
{
|
10 |
/**
|
11 |
* Internal constructor not depended on params. Can be used for object initialization
|
12 |
*/
|
13 |
protected function _construct()
|
14 |
{
|
15 |
-
$params = array(
|
16 |
-
'section' => Mage::app()->getRequest()->getParam('section'),
|
17 |
-
'website' => Mage::app()->getRequest()->getParam('website'),
|
18 |
-
'store' => Mage::app()->getRequest()->getParam('store'),
|
19 |
-
);
|
20 |
$this->setLabel('Run Now');
|
21 |
-
$this->setOnClick(
|
|
|
|
|
22 |
|
23 |
-
|
|
|
24 |
$this->setDisabled(true)->setClass('disabled');
|
25 |
}
|
26 |
}
|
5 |
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
* @version 2.0.0
|
7 |
*/
|
8 |
+
class Bronto_Order_Block_Adminhtml_Widget_Button_Run
|
9 |
+
extends Mage_Adminhtml_Block_Widget_Button
|
10 |
{
|
11 |
/**
|
12 |
* Internal constructor not depended on params. Can be used for object initialization
|
13 |
*/
|
14 |
protected function _construct()
|
15 |
{
|
|
|
|
|
|
|
|
|
|
|
16 |
$this->setLabel('Run Now');
|
17 |
+
$this->setOnClick(
|
18 |
+
"setLocation('" . Mage::helper('bronto_order')->getScopeUrl('*/order/run') . "'); return false;"
|
19 |
+
);
|
20 |
|
21 |
+
// Check to see if this module meets requirements
|
22 |
+
if (!Mage::helper('bronto_order')->isModuleActive()) {
|
23 |
$this->setDisabled(true)->setClass('disabled');
|
24 |
}
|
25 |
}
|
app/code/community/Bronto/Order/Block/Adminhtml/Widget/Button/Sync.php
CHANGED
@@ -12,19 +12,11 @@ class Bronto_Order_Block_Adminhtml_Widget_Button_Sync extends Mage_Adminhtml_Blo
|
|
12 |
*/
|
13 |
protected function _construct()
|
14 |
{
|
15 |
-
$
|
16 |
-
|
17 |
-
$this->setLabel(sprintf('Sync %d Orders to Queue', $missingOrders));
|
18 |
-
$this->setOnClick("setLocation('" . Mage::helper('adminhtml')->getUrl('*/order/sync') . "'); return false;");
|
19 |
$this->setClass('save');
|
20 |
-
|
21 |
-
|
22 |
-
if ($missingOrders == 0) {
|
23 |
-
$this->setLabel('Sync Complete');
|
24 |
-
$this->setDisabled(true)->setClass('disabled');
|
25 |
-
}
|
26 |
|
27 |
-
if (!
|
28 |
$this->setDisabled(true)->setClass('disabled');
|
29 |
}
|
30 |
}
|
12 |
*/
|
13 |
protected function _construct()
|
14 |
{
|
15 |
+
$this->setLabel($this->__('Sync Orders to Queue'));
|
16 |
+
$this->setOnClick("deleteConfirm('This will ensure all Magento orders are in the queue to import into Bronto\\n\\nThis is meant to be used when the order count does not match the total number of orders in the Magento admin\\n\\nWould you like to continue?', '" . Mage::helper('bronto_order')->getScopeUrl('*/order/sync') . "'); return false;");
|
|
|
|
|
17 |
$this->setClass('save');
|
|
|
|
|
|
|
|
|
|
|
|
|
18 |
|
19 |
+
if (!Mage::helper('bronto_order')->isModuleActive()) {
|
20 |
$this->setDisabled(true)->setClass('disabled');
|
21 |
}
|
22 |
}
|
app/code/community/Bronto/Order/Block/Bta.php
CHANGED
@@ -19,12 +19,20 @@ class Bronto_Order_Block_Bta extends Mage_Core_Block_Text
|
|
19 |
return;
|
20 |
}
|
21 |
|
|
|
|
|
|
|
|
|
|
|
22 |
return "
|
23 |
<script type=\"text/javascript\">
|
24 |
document.write(unescape(\"%3Cscript src='\"
|
25 |
+ ((document.location.protocol == \"https:\") ? \"https:\" : \"http:\")
|
26 |
+ \"//p.bm23.com/bta.js' type='text/javascript'%3E%3C/script%3E\"));
|
27 |
</script>
|
|
|
|
|
|
|
28 |
";
|
29 |
}
|
30 |
}
|
19 |
return;
|
20 |
}
|
21 |
|
22 |
+
$key = md5(
|
23 |
+
Mage::app()->getStore()->getWebsiteId() .
|
24 |
+
Mage::getConfig()->getNode(Mage_Core_Model_App::XML_PATH_INSTALL_DATE)
|
25 |
+
);
|
26 |
+
|
27 |
return "
|
28 |
<script type=\"text/javascript\">
|
29 |
document.write(unescape(\"%3Cscript src='\"
|
30 |
+ ((document.location.protocol == \"https:\") ? \"https:\" : \"http:\")
|
31 |
+ \"//p.bm23.com/bta.js' type='text/javascript'%3E%3C/script%3E\"));
|
32 |
</script>
|
33 |
+
<script type=\"text/javascript\">
|
34 |
+
var bta = new __bta('$key');
|
35 |
+
</script>
|
36 |
";
|
37 |
}
|
38 |
}
|
app/code/community/Bronto/Order/Helper/Data.php
CHANGED
@@ -7,9 +7,10 @@
|
|
7 |
*/
|
8 |
class Bronto_Order_Helper_Data extends Bronto_Common_Helper_Data implements Bronto_Common_Helper_DataInterface
|
9 |
{
|
10 |
-
const XML_PATH_ENABLED
|
11 |
-
const XML_PATH_LIMIT
|
12 |
-
const
|
|
|
13 |
const XML_PATH_INSTALL_DATE = 'bronto_order/settings/install_date';
|
14 |
const XML_PATH_UPGRADE_DATE = 'bronto_order/settings/upgrade_date';
|
15 |
|
@@ -18,7 +19,7 @@ class Bronto_Order_Helper_Data extends Bronto_Common_Helper_Data implements Bron
|
|
18 |
*/
|
19 |
public function isEnabled()
|
20 |
{
|
21 |
-
return (bool)
|
22 |
}
|
23 |
|
24 |
/**
|
@@ -30,6 +31,14 @@ class Bronto_Order_Helper_Data extends Bronto_Common_Helper_Data implements Bron
|
|
30 |
return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId);
|
31 |
}
|
32 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
33 |
/**
|
34 |
* @return int
|
35 |
*/
|
@@ -39,7 +48,7 @@ class Bronto_Order_Helper_Data extends Bronto_Common_Helper_Data implements Bron
|
|
39 |
return false;
|
40 |
}
|
41 |
|
42 |
-
return (int)
|
43 |
}
|
44 |
|
45 |
/**
|
@@ -47,7 +56,7 @@ class Bronto_Order_Helper_Data extends Bronto_Common_Helper_Data implements Bron
|
|
47 |
*/
|
48 |
public function getDescriptionAttribute()
|
49 |
{
|
50 |
-
return
|
51 |
}
|
52 |
|
53 |
/**
|
@@ -59,35 +68,35 @@ class Bronto_Order_Helper_Data extends Bronto_Common_Helper_Data implements Bron
|
|
59 |
{
|
60 |
return 'Bronto_Order';
|
61 |
}
|
62 |
-
|
63 |
/**
|
64 |
* Get Item Product Url
|
65 |
* @param Mage_Sales_Model_Order_Item $item
|
66 |
* @param Mage_Catalog_Model_Product $itemProduct
|
67 |
* @return string
|
68 |
*/
|
69 |
-
public function getItemUrl(Mage_Sales_Model_Order_Item $item, Mage_Catalog_Model_Product $itemProduct)
|
70 |
{
|
71 |
-
$productId = $this->_getIdToUse($item, $itemProduct);
|
72 |
-
return Mage::helper('bronto_common/product')->getProductAttribute($productId, 'url');
|
73 |
}
|
74 |
-
|
75 |
/**
|
76 |
* Get Item image
|
77 |
* @param Mage_Sales_Model_Order_Item $item
|
78 |
* @param Mage_Catalog_Model_Product $itemProduct
|
79 |
* @return string
|
80 |
*/
|
81 |
-
public function getItemImg(Mage_Sales_Model_Order_Item $item, Mage_Catalog_Model_Product $itemProduct)
|
82 |
{
|
83 |
-
if (Mage::helper('bronto_common/product')->getProductAttribute($itemProduct->getId(), 'image')) {
|
84 |
-
return Mage::helper('bronto_common/product')->getProductAttribute($itemProduct->getId(), 'image');
|
85 |
}
|
86 |
-
|
87 |
-
$productId = $this->_getIdToUse($item, $itemProduct, false);
|
88 |
-
return Mage::helper('bronto_common/product')->getProductAttribute($productId, 'image');
|
89 |
}
|
90 |
-
|
91 |
/**
|
92 |
* Get the product ID to use based on Item visibility
|
93 |
* @param Mage_Sales_Model_Order_Item $item
|
@@ -110,7 +119,7 @@ class Bronto_Order_Helper_Data extends Bronto_Common_Helper_Data implements Bron
|
|
110 |
}
|
111 |
}
|
112 |
}
|
113 |
-
|
114 |
/**
|
115 |
* This function gets the order item's info_buyRequest super_product_config values
|
116 |
* if they exist
|
@@ -125,47 +134,39 @@ class Bronto_Order_Helper_Data extends Bronto_Common_Helper_Data implements Bron
|
|
125 |
} elseif (method_exists($item, 'getProductOptionByCode')) {
|
126 |
$buyRequest = $item->getProductOptionByCode('info_buyRequest');
|
127 |
} elseif (method_exists($item, 'getProductOptions')) {
|
128 |
-
$options
|
129 |
$buyRequest = $options['info_buyRequest'];
|
130 |
} elseif (method_exists($item, 'getOptionByCode')) {
|
131 |
$buyRequest = $item->getOptionByCode('info_buyRequest');
|
132 |
} else {
|
133 |
-
|
134 |
return false;
|
135 |
}
|
136 |
-
|
137 |
if ($buyRequest && array_key_exists('super_product_config', $buyRequest)) {
|
138 |
return $buyRequest['super_product_config'];
|
139 |
} elseif ($buyRequest && array_key_exists('product', $buyRequest)) {
|
140 |
return array('product_id' => $buyRequest['product']);
|
141 |
}
|
142 |
}
|
143 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
144 |
/**
|
145 |
* Get Orders which aren't in contact queue
|
146 |
-
* @
|
147 |
-
* @return int|Mage_Sales_Model_Resource_Order_Collection
|
148 |
*/
|
149 |
-
public function getMissingOrders(
|
150 |
{
|
151 |
-
|
152 |
-
|
153 |
-
|
154 |
-
// If just getting count, don't limit results
|
155 |
-
if ($getCount) {
|
156 |
-
$limit = false;
|
157 |
-
} else {
|
158 |
-
$limit = 250;
|
159 |
-
}
|
160 |
-
|
161 |
-
// Get Collection of active orders not already in queue
|
162 |
-
/* @var Mage_Sales_Model_Resource_Order_Collection */
|
163 |
-
$orders = $queue->getMissingOrders($ids, $limit);
|
164 |
-
|
165 |
-
if ($getCount) {
|
166 |
-
return $orders->count();
|
167 |
-
}
|
168 |
-
|
169 |
-
return $orders;
|
170 |
}
|
171 |
}
|
7 |
*/
|
8 |
class Bronto_Order_Helper_Data extends Bronto_Common_Helper_Data implements Bronto_Common_Helper_DataInterface
|
9 |
{
|
10 |
+
const XML_PATH_ENABLED = 'bronto_order/settings/enabled';
|
11 |
+
const XML_PATH_LIMIT = 'bronto_order/settings/limit';
|
12 |
+
const XML_PATH_SYNC_LIMIT = 'bronto_order/settings/sync_limit';
|
13 |
+
const XML_PATH_DESCRIPTION = 'bronto_order/settings/description_attribute';
|
14 |
const XML_PATH_INSTALL_DATE = 'bronto_order/settings/install_date';
|
15 |
const XML_PATH_UPGRADE_DATE = 'bronto_order/settings/upgrade_date';
|
16 |
|
19 |
*/
|
20 |
public function isEnabled()
|
21 |
{
|
22 |
+
return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED);
|
23 |
}
|
24 |
|
25 |
/**
|
31 |
return $this->_disableModule(self::XML_PATH_ENABLED, $scope, $scopeId);
|
32 |
}
|
33 |
|
34 |
+
/**
|
35 |
+
* @return int
|
36 |
+
*/
|
37 |
+
public function getSyncLimit()
|
38 |
+
{
|
39 |
+
return (int)$this->getAdminScopedConfig(self::XML_PATH_SYNC_LIMIT);
|
40 |
+
}
|
41 |
+
|
42 |
/**
|
43 |
* @return int
|
44 |
*/
|
48 |
return false;
|
49 |
}
|
50 |
|
51 |
+
return (int)$this->getAdminScopedConfig(self::XML_PATH_LIMIT);
|
52 |
}
|
53 |
|
54 |
/**
|
56 |
*/
|
57 |
public function getDescriptionAttribute()
|
58 |
{
|
59 |
+
return $this->getAdminScopedConfig(self::XML_PATH_DESCRIPTION);
|
60 |
}
|
61 |
|
62 |
/**
|
68 |
{
|
69 |
return 'Bronto_Order';
|
70 |
}
|
71 |
+
|
72 |
/**
|
73 |
* Get Item Product Url
|
74 |
* @param Mage_Sales_Model_Order_Item $item
|
75 |
* @param Mage_Catalog_Model_Product $itemProduct
|
76 |
* @return string
|
77 |
*/
|
78 |
+
public function getItemUrl(Mage_Sales_Model_Order_Item $item, Mage_Catalog_Model_Product $itemProduct, $storeId = false)
|
79 |
{
|
80 |
+
$productId = $this->_getIdToUse($item, $itemProduct);
|
81 |
+
return Mage::helper('bronto_common/product')->getProductAttribute($productId, 'url', $storeId);
|
82 |
}
|
83 |
+
|
84 |
/**
|
85 |
* Get Item image
|
86 |
* @param Mage_Sales_Model_Order_Item $item
|
87 |
* @param Mage_Catalog_Model_Product $itemProduct
|
88 |
* @return string
|
89 |
*/
|
90 |
+
public function getItemImg(Mage_Sales_Model_Order_Item $item, Mage_Catalog_Model_Product $itemProduct, $storeId = false)
|
91 |
{
|
92 |
+
if (Mage::helper('bronto_common/product')->getProductAttribute($itemProduct->getId(), 'image', $storeId)) {
|
93 |
+
return Mage::helper('bronto_common/product')->getProductAttribute($itemProduct->getId(), 'image', $storeId);
|
94 |
}
|
95 |
+
|
96 |
+
$productId = $this->_getIdToUse($item, $itemProduct, false);
|
97 |
+
return Mage::helper('bronto_common/product')->getProductAttribute($productId, 'image', $storeId);
|
98 |
}
|
99 |
+
|
100 |
/**
|
101 |
* Get the product ID to use based on Item visibility
|
102 |
* @param Mage_Sales_Model_Order_Item $item
|
119 |
}
|
120 |
}
|
121 |
}
|
122 |
+
|
123 |
/**
|
124 |
* This function gets the order item's info_buyRequest super_product_config values
|
125 |
* if they exist
|
134 |
} elseif (method_exists($item, 'getProductOptionByCode')) {
|
135 |
$buyRequest = $item->getProductOptionByCode('info_buyRequest');
|
136 |
} elseif (method_exists($item, 'getProductOptions')) {
|
137 |
+
$options = $item->getProductOptions();
|
138 |
$buyRequest = $options['info_buyRequest'];
|
139 |
} elseif (method_exists($item, 'getOptionByCode')) {
|
140 |
$buyRequest = $item->getOptionByCode('info_buyRequest');
|
141 |
} else {
|
142 |
+
|
143 |
return false;
|
144 |
}
|
145 |
+
|
146 |
if ($buyRequest && array_key_exists('super_product_config', $buyRequest)) {
|
147 |
return $buyRequest['super_product_config'];
|
148 |
} elseif ($buyRequest && array_key_exists('product', $buyRequest)) {
|
149 |
return array('product_id' => $buyRequest['product']);
|
150 |
}
|
151 |
}
|
152 |
+
|
153 |
+
/**
|
154 |
+
* Get Count of orders not in queue
|
155 |
+
* @return int
|
156 |
+
*/
|
157 |
+
public function getMissingOrdersCount()
|
158 |
+
{
|
159 |
+
return Mage::getModel('bronto_order/queue')
|
160 |
+
->getMissingOrdersCount();
|
161 |
+
}
|
162 |
+
|
163 |
/**
|
164 |
* Get Orders which aren't in contact queue
|
165 |
+
* @return array
|
|
|
166 |
*/
|
167 |
+
public function getMissingOrders()
|
168 |
{
|
169 |
+
return Mage::getModel('bronto_order/queue')
|
170 |
+
->getMissingOrders();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
171 |
}
|
172 |
}
|
app/code/community/Bronto/Order/Model/Mysql4/Queue.php
CHANGED
@@ -13,15 +13,24 @@ class Bronto_Order_Model_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstract
|
|
13 |
* @var bool
|
14 |
*/
|
15 |
protected $_isPkAutoIncrement = false;
|
16 |
-
|
17 |
/**
|
18 |
* Initialize Model
|
19 |
-
*
|
20 |
-
* @return void
|
21 |
* @access public
|
22 |
*/
|
23 |
public function _construct()
|
24 |
{
|
25 |
$this->_init('bronto_order/queue', 'queue_id');
|
26 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
27 |
}
|
13 |
* @var bool
|
14 |
*/
|
15 |
protected $_isPkAutoIncrement = false;
|
16 |
+
|
17 |
/**
|
18 |
* Initialize Model
|
19 |
+
*
|
20 |
+
* @return void
|
21 |
* @access public
|
22 |
*/
|
23 |
public function _construct()
|
24 |
{
|
25 |
$this->_init('bronto_order/queue', 'queue_id');
|
26 |
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Get Write adapter instance
|
30 |
+
* @return type
|
31 |
+
*/
|
32 |
+
public function getWriteAdapter()
|
33 |
+
{
|
34 |
+
return $this->_getWriteAdapter();
|
35 |
+
}
|
36 |
}
|
app/code/community/Bronto/Order/Model/Mysql4/Queue/Collection.php
CHANGED
@@ -5,20 +5,21 @@
|
|
5 |
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
* @version 1.1.7
|
7 |
*/
|
8 |
-
class Bronto_Order_Model_Mysql4_Queue_Collection
|
9 |
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
10 |
-
{
|
11 |
/**
|
12 |
* Initialize Model
|
13 |
-
*
|
14 |
-
* @return void
|
15 |
* @access public
|
16 |
*/
|
17 |
-
public function _construct()
|
|
|
18 |
parent::_construct();
|
19 |
$this->_init('bronto_order/queue');
|
20 |
}
|
21 |
-
|
22 |
/**
|
23 |
* @return Bronto_Order_Model_Mysql4_Queue_Collection
|
24 |
*/
|
@@ -27,7 +28,7 @@ class Bronto_Order_Model_Mysql4_Queue_Collection
|
|
27 |
$this->addFieldToFilter('bronto_imported', array('notnull' => true));
|
28 |
return $this;
|
29 |
}
|
30 |
-
|
31 |
/**
|
32 |
* @return Bronto_Order_Model_Mysql4_Queue_Collection
|
33 |
*/
|
@@ -54,7 +55,7 @@ class Bronto_Order_Model_Mysql4_Queue_Collection
|
|
54 |
$this->addFieldToFilter('bronto_suppressed', array('null' => true));
|
55 |
return $this;
|
56 |
}
|
57 |
-
|
58 |
public function addBrontoHasOrderFilter()
|
59 |
{
|
60 |
$this->addFieldToFilter('order_id', array('neq' => 0));
|
@@ -75,13 +76,11 @@ class Bronto_Order_Model_Mysql4_Queue_Collection
|
|
75 |
|
76 |
$storeIds = array_unique($storeIds);
|
77 |
|
78 |
-
if ($index = array_search(null, $storeIds)) {
|
79 |
unset($storeIds[$index]);
|
80 |
$nullCheck = true;
|
81 |
}
|
82 |
|
83 |
-
$storeIds[0] = ($storeIds[0] == '') ? 0 : $storeIds[0];
|
84 |
-
|
85 |
if ($nullCheck) {
|
86 |
$this->getSelect()->where('store_id IN(?) OR store_id IS NULL', $storeIds);
|
87 |
} else {
|
@@ -99,7 +98,7 @@ class Bronto_Order_Model_Mysql4_Queue_Collection
|
|
99 |
*/
|
100 |
public function orderByCreatedAt($dir = self::SORT_ORDER_DESC)
|
101 |
{
|
102 |
-
$this->
|
103 |
return $this;
|
104 |
}
|
105 |
|
@@ -111,7 +110,7 @@ class Bronto_Order_Model_Mysql4_Queue_Collection
|
|
111 |
*/
|
112 |
public function orderByUpdatedAt($dir = self::SORT_ORDER_DESC)
|
113 |
{
|
114 |
-
$this->
|
115 |
return $this;
|
116 |
}
|
117 |
}
|
5 |
* @copyright 2011-2013 Bronto Software, Inc.
|
6 |
* @version 1.1.7
|
7 |
*/
|
8 |
+
class Bronto_Order_Model_Mysql4_Queue_Collection
|
9 |
extends Mage_Core_Model_Mysql4_Collection_Abstract
|
10 |
+
{
|
11 |
/**
|
12 |
* Initialize Model
|
13 |
+
*
|
14 |
+
* @return void
|
15 |
* @access public
|
16 |
*/
|
17 |
+
public function _construct()
|
18 |
+
{
|
19 |
parent::_construct();
|
20 |
$this->_init('bronto_order/queue');
|
21 |
}
|
22 |
+
|
23 |
/**
|
24 |
* @return Bronto_Order_Model_Mysql4_Queue_Collection
|
25 |
*/
|
28 |
$this->addFieldToFilter('bronto_imported', array('notnull' => true));
|
29 |
return $this;
|
30 |
}
|
31 |
+
|
32 |
/**
|
33 |
* @return Bronto_Order_Model_Mysql4_Queue_Collection
|
34 |
*/
|
55 |
$this->addFieldToFilter('bronto_suppressed', array('null' => true));
|
56 |
return $this;
|
57 |
}
|
58 |
+
|
59 |
public function addBrontoHasOrderFilter()
|
60 |
{
|
61 |
$this->addFieldToFilter('order_id', array('neq' => 0));
|
76 |
|
77 |
$storeIds = array_unique($storeIds);
|
78 |
|
79 |
+
if ($index = array_search(null, $storeIds, true)) {
|
80 |
unset($storeIds[$index]);
|
81 |
$nullCheck = true;
|
82 |
}
|
83 |
|
|
|
|
|
84 |
if ($nullCheck) {
|
85 |
$this->getSelect()->where('store_id IN(?) OR store_id IS NULL', $storeIds);
|
86 |
} else {
|
98 |
*/
|
99 |
public function orderByCreatedAt($dir = self::SORT_ORDER_DESC)
|
100 |
{
|
101 |
+
$this->getSelect()->order("created_at $dir");
|
102 |
return $this;
|
103 |
}
|
104 |
|
110 |
*/
|
111 |
public function orderByUpdatedAt($dir = self::SORT_ORDER_DESC)
|
112 |
{
|
113 |
+
$this->getSelect()->order("updated_at $dir");
|
114 |
return $this;
|
115 |
}
|
116 |
}
|
app/code/community/Bronto/Order/Model/Mysql4/Setup.php
CHANGED
@@ -10,9 +10,9 @@ class Bronto_Order_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
|
|
10 |
|
11 |
/**
|
12 |
* Get column definition for attribute
|
13 |
-
*
|
14 |
-
* @param string
|
15 |
-
* @param unknown
|
16 |
* @return string Return description (if any) ...
|
17 |
* @access protected
|
18 |
*/
|
@@ -26,7 +26,7 @@ class Bronto_Order_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
|
|
26 |
|
27 |
return $definition;
|
28 |
}
|
29 |
-
|
30 |
/**
|
31 |
* Remove entity attribute. Overwritten for flat entities support
|
32 |
*
|
@@ -38,8 +38,8 @@ class Bronto_Order_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
|
|
38 |
public function removeAttribute($entityTypeId, $code)
|
39 |
{
|
40 |
if (isset($this->_flatEntityTables[$entityTypeId]) &&
|
41 |
-
$this->_flatTableExist($this->_flatEntityTables[$entityTypeId])
|
42 |
-
{
|
43 |
$this->_removeFlatAttribute($this->_flatEntityTables[$entityTypeId], $code);
|
44 |
$this->_removeGridAttribute($this->_flatEntityTables[$entityTypeId], $code, $entityTypeId);
|
45 |
} else {
|
@@ -47,7 +47,7 @@ class Bronto_Order_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
|
|
47 |
}
|
48 |
return $this;
|
49 |
}
|
50 |
-
|
51 |
/**
|
52 |
* Remove an attribute as separate column in the table
|
53 |
* The sales setup class doesn't support it by default
|
@@ -62,7 +62,7 @@ class Bronto_Order_Model_Mysql4_Setup extends Mage_Sales_Model_Mysql4_Setup
|
|
62 |
$this->getConnection()->dropColumn($this->getTable($table), $attribute);
|
63 |
return $this;
|
64 |
}
|
65 |
-
|
66 |
/**
|
67 |
* Remove attribute from grid
|
68 |
*
|
10 |
|
11 |
/**
|
12 |
* Get column definition for attribute
|
13 |
+
*
|
14 |
+
* @param string $code Parameter description (if any) ...
|
15 |
+
* @param unknown $data Parameter description (if any) ...
|
16 |
* @return string Return description (if any) ...
|
17 |
* @access protected
|
18 |
*/
|
26 |
|
27 |
return $definition;
|
28 |
}
|
29 |
+
|
30 |
/**
|
31 |
* Remove entity attribute. Overwritten for flat entities support
|
32 |
*
|
38 |
public function removeAttribute($entityTypeId, $code)
|
39 |
{
|
40 |
if (isset($this->_flatEntityTables[$entityTypeId]) &&
|
41 |
+
$this->_flatTableExist($this->_flatEntityTables[$entityTypeId])
|
42 |
+
) {
|
43 |
$this->_removeFlatAttribute($this->_flatEntityTables[$entityTypeId], $code);
|
44 |
$this->_removeGridAttribute($this->_flatEntityTables[$entityTypeId], $code, $entityTypeId);
|
45 |
} else {
|
47 |
}
|
48 |
return $this;
|
49 |
}
|
50 |
+
|
51 |
/**
|
52 |
* Remove an attribute as separate column in the table
|
53 |
* The sales setup class doesn't support it by default
|
62 |
$this->getConnection()->dropColumn($this->getTable($table), $attribute);
|
63 |
return $this;
|
64 |
}
|
65 |
+
|
66 |
/**
|
67 |
* Remove attribute from grid
|
68 |
*
|
app/code/community/Bronto/Order/Model/Observer.php
CHANGED
@@ -7,10 +7,22 @@
|
|
7 |
*/
|
8 |
class Bronto_Order_Model_Observer
|
9 |
{
|
|
|
10 |
const NOTICE_IDENTIFER = 'bronto_order';
|
11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
/**
|
|
|
13 |
* @param Varien_Event_Observer $observer
|
|
|
|
|
14 |
*/
|
15 |
public function checkBrontoRequirements(Varien_Event_Observer $observer)
|
16 |
{
|
@@ -19,28 +31,39 @@ class Bronto_Order_Model_Observer
|
|
19 |
}
|
20 |
|
21 |
// Verify Requirements
|
22 |
-
if (
|
23 |
return;
|
24 |
}
|
25 |
}
|
26 |
|
27 |
/**
|
28 |
-
*
|
|
|
|
|
29 |
* @return array
|
|
|
30 |
*/
|
31 |
-
public function processOrdersForStore($storeId
|
32 |
{
|
33 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
$storeId = $store->getId();
|
35 |
-
|
36 |
-
// Set the current store ID
|
37 |
-
Mage::app()->setCurrentStore($storeId);
|
38 |
|
39 |
-
|
40 |
-
|
41 |
|
|
|
42 |
if (!$store->getConfig(Bronto_Order_Helper_Data::XML_PATH_ENABLED)) {
|
43 |
-
|
44 |
return $result;
|
45 |
}
|
46 |
|
@@ -48,17 +71,13 @@ class Bronto_Order_Model_Observer
|
|
48 |
$token = $store->getConfig(Bronto_Common_Helper_Data::XML_PATH_API_TOKEN);
|
49 |
|
50 |
/* @var $api Bronto_Common_Model_Api */
|
51 |
-
$api =
|
52 |
|
53 |
/* @var $orderObject Bronto_Api_Order */
|
54 |
$orderObject = $api->getOrderObject();
|
55 |
|
56 |
-
|
57 |
-
|
58 |
-
Mage::helper('bronto_order')->writeDebug(' Limit empty. Skipping...');
|
59 |
-
return $result;
|
60 |
-
}
|
61 |
-
|
62 |
$orderRows = Mage::getModel('bronto_order/queue')
|
63 |
->getCollection()
|
64 |
->addBrontoNotImportedFilter()
|
@@ -68,33 +87,41 @@ class Bronto_Order_Model_Observer
|
|
68 |
->setPageSize($limit)
|
69 |
->addStoreFilter($storeId)
|
70 |
->getItems();
|
71 |
-
|
|
|
72 |
if (empty($orderRows)) {
|
73 |
-
|
74 |
return $result;
|
75 |
}
|
76 |
|
77 |
/* @var $productHelper Bronto_Common_Helper_Product */
|
78 |
-
$productHelper
|
79 |
$descriptionAttr = $store->getConfig(Bronto_Order_Helper_Data::XML_PATH_DESCRIPTION);
|
80 |
-
$orderCache
|
81 |
|
82 |
-
|
|
|
83 |
$orderId = $orderRow->getOrderId();
|
84 |
-
|
85 |
-
|
|
|
|
|
|
|
86 |
$orderCache[] = $orderId;
|
87 |
|
88 |
/* @var $brontoOrder Bronto_Api_Order_Row */
|
89 |
$brontoOrder = $orderObject->createRow();
|
90 |
-
$brontoOrder->email
|
91 |
-
$brontoOrder->id
|
92 |
$brontoOrder->orderDate = date('c', strtotime($order->getCreatedAt()));
|
|
|
|
|
93 |
if ($tid = $orderRow->getBrontoTid()) {
|
94 |
$brontoOrder->tid = $tid;
|
95 |
}
|
96 |
$brontoOrderItems = array();
|
97 |
|
|
|
98 |
switch ($order->getState()) {
|
99 |
case Mage_Sales_Model_Order::STATE_CANCELED:
|
100 |
case Mage_Sales_Model_Order::STATE_HOLDED:
|
@@ -103,12 +130,21 @@ class Bronto_Order_Model_Observer
|
|
103 |
break;
|
104 |
|
105 |
default:
|
106 |
-
//
|
107 |
-
$items
|
108 |
-
|
109 |
-
|
|
|
|
|
|
|
|
|
|
|
110 |
$itemProduct = Mage::getModel('catalog/product')->load($item->getProductId());
|
|
|
|
|
111 |
switch ($itemProduct->getTypeId()) {
|
|
|
|
|
112 |
case Mage_Catalog_Model_Product_Type::TYPE_BUNDLE:
|
113 |
if (count($item->getChildrenItems()) > 0) {
|
114 |
foreach ($item->getChildrenItems() as $child_item) {
|
@@ -116,28 +152,32 @@ class Bronto_Order_Model_Observer
|
|
116 |
}
|
117 |
}
|
118 |
break;
|
|
|
|
|
119 |
case Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE:
|
120 |
-
$childItems = $item->getChildrenItems();
|
121 |
if (1 === count($childItems)) {
|
122 |
$childItem = $childItems[0];
|
123 |
-
|
124 |
// Collect options applicable to the configurable product
|
125 |
$productAttributeOptions = $itemProduct->getTypeInstance(true)->getConfigurableAttributesAsArray($itemProduct);
|
126 |
|
127 |
// Build Selected Options Name
|
128 |
$nameWithOptions = array();
|
129 |
foreach ($productAttributeOptions as $productAttribute) {
|
130 |
-
$itemValue = $productHelper->getProductAttribute($childItem->getProductId(), $productAttribute['attribute_code']);
|
131 |
$nameWithOptions[] = $productAttribute['label'] . ': ' . $itemValue;
|
132 |
}
|
133 |
-
|
134 |
// Set parent product name to include selected options
|
135 |
$parentName = $item->getName() . ' [' . implode(', ', $nameWithOptions) . ']';
|
136 |
$item->setName($parentName);
|
137 |
}
|
138 |
-
|
139 |
$fullItems[] = $item;
|
140 |
break;
|
|
|
|
|
141 |
case Mage_Catalog_Model_Product_Type::TYPE_GROUPED:
|
142 |
// This condition probably never gets hit, parent grouped items don't show in order
|
143 |
$fullItems[] = $item;
|
@@ -145,118 +185,160 @@ class Bronto_Order_Model_Observer
|
|
145 |
$fullItems[] = $child_item;
|
146 |
}
|
147 |
break;
|
|
|
|
|
148 |
default:
|
149 |
$fullItems[] = $item;
|
150 |
break;
|
151 |
}
|
152 |
}
|
153 |
-
|
154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
155 |
/* @var $product Mage_Catalog_Model_Product */
|
156 |
-
$product
|
157 |
-
|
158 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
159 |
foreach ($categoryIds as $categoryId) {
|
160 |
/* @var $category Mage_Catalog_Model_Category */
|
161 |
-
$category
|
162 |
-
$parent
|
163 |
$categories[] = $parent->getUrlKey() ? $parent->getUrlKey() : $parent->formatUrlKey($parent->getName());
|
164 |
$categories[] = $category->getUrlKey() ? $category->getUrlKey() : $category->formatUrlKey($category->getName());
|
165 |
}
|
|
|
|
|
166 |
$categories = array_unique($categories);
|
167 |
|
168 |
// Write orderItem
|
169 |
$brontoOrderItems[] = array(
|
170 |
-
'id'
|
171 |
-
'sku'
|
172 |
-
'name'
|
173 |
'description' => $productHelper->getProductAttribute($item->getProductId(), $descriptionAttr),
|
174 |
-
'category'
|
175 |
-
'image'
|
176 |
-
'url'
|
177 |
-
'quantity'
|
178 |
-
'price'
|
179 |
);
|
180 |
}
|
181 |
$brontoOrder->products = $brontoOrderItems;
|
182 |
$brontoOrder->persist();
|
183 |
break;
|
184 |
}
|
185 |
-
|
186 |
try {
|
187 |
// Mark order as imported
|
188 |
$orderRow->setBrontoImported(Mage::getSingleton('core/date')->gmtDate());
|
189 |
$orderRow->save();
|
190 |
-
|
191 |
// Flush every 10 orders
|
192 |
if ($result['total'] % 100 === 0) {
|
193 |
-
$result
|
194 |
$orderCache = array();
|
195 |
}
|
196 |
} catch (Exception $e) {
|
197 |
-
|
198 |
|
199 |
// Mark import as *not* imported
|
200 |
$orderRow->setBrontoImported(null);
|
201 |
-
// Do not suppress on Exception
|
202 |
-
//$orderRow->setBrontoSuppressed($e->getMessage());
|
203 |
$orderRow->save();
|
204 |
|
|
|
205 |
$result['error']++;
|
206 |
}
|
207 |
|
|
|
208 |
$result['total']++;
|
209 |
}
|
210 |
}
|
211 |
-
|
212 |
// Final flush (for any we miss)
|
213 |
-
$results = $this->
|
214 |
|
215 |
-
|
216 |
-
|
217 |
-
|
|
|
218 |
|
219 |
-
// Set store back to admin store
|
220 |
-
Mage::app()->setCurrentStore(Mage_Core_Model_App::ADMIN_STORE_ID);
|
221 |
-
|
222 |
return $results;
|
223 |
}
|
224 |
|
225 |
/**
|
226 |
* @param Bronto_Api_Order $orderObject
|
227 |
-
* @param array
|
228 |
-
* @param array
|
229 |
* @return array
|
|
|
230 |
*/
|
231 |
-
|
232 |
{
|
|
|
233 |
$flushResult = $orderObject->flush();
|
234 |
|
235 |
-
|
236 |
-
|
237 |
-
|
|
|
238 |
|
|
|
239 |
foreach ($flushResult as $i => $flushResultRow) {
|
|
|
|
|
240 |
if ($flushResultRow->hasError()) {
|
241 |
-
|
|
|
|
|
|
|
242 |
$errorMessage = $flushResultRow->getErrorMessage();
|
|
|
|
|
243 |
if (isset($orderCache[$i])) {
|
244 |
-
|
245 |
$order = Mage::getModel('sales/order')->load($orderCache[$i]);
|
246 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
247 |
// Reset Bronto Import status
|
248 |
-
|
249 |
->getOrderRow($order->getId(), $order->getQuoteId(), $order->getStoreId())
|
250 |
->setBrontoImported(null)
|
251 |
->setBrontoSuppressed($errorMessage)
|
252 |
->save();
|
253 |
-
|
254 |
-
Mage::helper('bronto_order')->writeError("[{$errorCode}] {$errorMessage} ({$order->getIncrementId})");
|
255 |
-
} else {
|
256 |
-
Mage::helper('bronto_order')->writeError("[{$errorCode}] {$errorMessage}");
|
257 |
}
|
|
|
|
|
|
|
|
|
|
|
258 |
$result['error']++;
|
259 |
} else {
|
|
|
260 |
$result['success']++;
|
261 |
}
|
262 |
}
|
@@ -265,24 +347,45 @@ class Bronto_Order_Model_Observer
|
|
265 |
}
|
266 |
|
267 |
/**
|
|
|
268 |
* @return array
|
|
|
269 |
*/
|
270 |
public function processOrders()
|
271 |
{
|
|
|
272 |
$result = array(
|
273 |
-
'total'
|
274 |
'success' => 0,
|
275 |
-
'error'
|
276 |
);
|
277 |
|
|
|
|
|
|
|
|
|
278 |
$stores = Mage::app()->getStores(true);
|
|
|
|
|
279 |
foreach ($stores as $_store) {
|
280 |
-
|
281 |
-
$
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
282 |
$result['success'] += $storeResult['success'];
|
283 |
-
$result['error']
|
|
|
|
|
|
|
284 |
}
|
285 |
|
286 |
return $result;
|
287 |
}
|
|
|
288 |
}
|
7 |
*/
|
8 |
class Bronto_Order_Model_Observer
|
9 |
{
|
10 |
+
|
11 |
const NOTICE_IDENTIFER = 'bronto_order';
|
12 |
|
13 |
+
private $_helper;
|
14 |
+
|
15 |
+
public function __construct()
|
16 |
+
{
|
17 |
+
/* @var $_helper Bronto_Order_Helper_Data */
|
18 |
+
$this->_helper = Mage::helper(self::NOTICE_IDENTIFER);
|
19 |
+
}
|
20 |
+
|
21 |
/**
|
22 |
+
* Verify that all requirements are met for this module
|
23 |
* @param Varien_Event_Observer $observer
|
24 |
+
* @return null
|
25 |
+
* @access public
|
26 |
*/
|
27 |
public function checkBrontoRequirements(Varien_Event_Observer $observer)
|
28 |
{
|
31 |
}
|
32 |
|
33 |
// Verify Requirements
|
34 |
+
if (!$this->_helper->varifyRequirements(self::NOTICE_IDENTIFER, array('soap', 'openssl'))) {
|
35 |
return;
|
36 |
}
|
37 |
}
|
38 |
|
39 |
/**
|
40 |
+
* Process specified number of items for specified store
|
41 |
+
* @param mixed $storeId can be store object or id
|
42 |
+
* @param int $limit must be greater than 0
|
43 |
* @return array
|
44 |
+
* @access public
|
45 |
*/
|
46 |
+
public function processOrdersForStore($storeId, $limit)
|
47 |
{
|
48 |
+
// Define default results
|
49 |
+
$result = array('total' => 0, 'success' => 0, 'error' => 0);
|
50 |
+
|
51 |
+
// If limit is false or 0, return
|
52 |
+
if (!$limit) {
|
53 |
+
$this->_helper->writeDebug(' Limit empty. Skipping...');
|
54 |
+
return $result;
|
55 |
+
}
|
56 |
+
|
57 |
+
// Get Store object and ID
|
58 |
+
$store = Mage::app()->getStore($storeId);
|
59 |
$storeId = $store->getId();
|
|
|
|
|
|
|
60 |
|
61 |
+
// Log that we have begun importing for this store
|
62 |
+
$this->_helper->writeDebug("Starting Order Import process for store: {$store->getName()} ({$storeId})");
|
63 |
|
64 |
+
// If module is not enabled for this store, log that fact and return
|
65 |
if (!$store->getConfig(Bronto_Order_Helper_Data::XML_PATH_ENABLED)) {
|
66 |
+
$this->_helper->writeDebug(' Module disabled for this store. Skipping...');
|
67 |
return $result;
|
68 |
}
|
69 |
|
71 |
$token = $store->getConfig(Bronto_Common_Helper_Data::XML_PATH_API_TOKEN);
|
72 |
|
73 |
/* @var $api Bronto_Common_Model_Api */
|
74 |
+
$api = $this->_helper->getApi($token);
|
75 |
|
76 |
/* @var $orderObject Bronto_Api_Order */
|
77 |
$orderObject = $api->getOrderObject();
|
78 |
|
79 |
+
// Retrieve order queue rows limited to current limit and filtered
|
80 |
+
// Filter out imported, suppressed, other stores, and items without order ids
|
|
|
|
|
|
|
|
|
81 |
$orderRows = Mage::getModel('bronto_order/queue')
|
82 |
->getCollection()
|
83 |
->addBrontoNotImportedFilter()
|
87 |
->setPageSize($limit)
|
88 |
->addStoreFilter($storeId)
|
89 |
->getItems();
|
90 |
+
|
91 |
+
// If we didn't get any order queue rows with this pull, log and return
|
92 |
if (empty($orderRows)) {
|
93 |
+
$this->_helper->writeVerboseDebug(' No Orders to process. Skipping...');
|
94 |
return $result;
|
95 |
}
|
96 |
|
97 |
/* @var $productHelper Bronto_Common_Helper_Product */
|
98 |
+
$productHelper = Mage::helper('bronto_common/product');
|
99 |
$descriptionAttr = $store->getConfig(Bronto_Order_Helper_Data::XML_PATH_DESCRIPTION);
|
100 |
+
$orderCache = array();
|
101 |
|
102 |
+
// Cycle through each order queue row
|
103 |
+
foreach ($orderRows as $orderRow/* @var $orderRow Bronto_Order_Model_Queue */) {
|
104 |
$orderId = $orderRow->getOrderId();
|
105 |
+
|
106 |
+
// Check if the order id is still attached to an order in magento
|
107 |
+
if ($order = Mage::getModel('sales/order')->load($orderId)/* @var $order Mage_Sales_Model_Order */) {
|
108 |
+
// Log that we are processing the current order
|
109 |
+
$this->_helper->writeDebug(" Processing Order ID: {$orderId}");
|
110 |
$orderCache[] = $orderId;
|
111 |
|
112 |
/* @var $brontoOrder Bronto_Api_Order_Row */
|
113 |
$brontoOrder = $orderObject->createRow();
|
114 |
+
$brontoOrder->email = $order->getCustomerEmail();
|
115 |
+
$brontoOrder->id = $order->getIncrementId();
|
116 |
$brontoOrder->orderDate = date('c', strtotime($order->getCreatedAt()));
|
117 |
+
|
118 |
+
// If there is a conversion tracking id attached to this order, add it to the row
|
119 |
if ($tid = $orderRow->getBrontoTid()) {
|
120 |
$brontoOrder->tid = $tid;
|
121 |
}
|
122 |
$brontoOrderItems = array();
|
123 |
|
124 |
+
// If the order has been cancelled, placed on hold, or closed we delete the row
|
125 |
switch ($order->getState()) {
|
126 |
case Mage_Sales_Model_Order::STATE_CANCELED:
|
127 |
case Mage_Sales_Model_Order::STATE_HOLDED:
|
130 |
break;
|
131 |
|
132 |
default:
|
133 |
+
// Get visible items from order
|
134 |
+
$items = $order->getAllVisibleItems();
|
135 |
+
|
136 |
+
// Keep product order by using a new array
|
137 |
+
$fullItems = array();
|
138 |
+
|
139 |
+
// loop through the items. if it's a bundled item,
|
140 |
+
// replace the parent item with the child items.
|
141 |
+
foreach ($items as $item) {
|
142 |
$itemProduct = Mage::getModel('catalog/product')->load($item->getProductId());
|
143 |
+
|
144 |
+
// Handle product based on product type
|
145 |
switch ($itemProduct->getTypeId()) {
|
146 |
+
|
147 |
+
// Bundled products need child items
|
148 |
case Mage_Catalog_Model_Product_Type::TYPE_BUNDLE:
|
149 |
if (count($item->getChildrenItems()) > 0) {
|
150 |
foreach ($item->getChildrenItems() as $child_item) {
|
152 |
}
|
153 |
}
|
154 |
break;
|
155 |
+
|
156 |
+
// Configurable products just need simple config item
|
157 |
case Mage_Catalog_Model_Product_Type::TYPE_CONFIGURABLE:
|
158 |
+
$childItems = $item->getChildrenItems();
|
159 |
if (1 === count($childItems)) {
|
160 |
$childItem = $childItems[0];
|
161 |
+
|
162 |
// Collect options applicable to the configurable product
|
163 |
$productAttributeOptions = $itemProduct->getTypeInstance(true)->getConfigurableAttributesAsArray($itemProduct);
|
164 |
|
165 |
// Build Selected Options Name
|
166 |
$nameWithOptions = array();
|
167 |
foreach ($productAttributeOptions as $productAttribute) {
|
168 |
+
$itemValue = $productHelper->getProductAttribute($childItem->getProductId(), $productAttribute['attribute_code'], $storeId);
|
169 |
$nameWithOptions[] = $productAttribute['label'] . ': ' . $itemValue;
|
170 |
}
|
171 |
+
|
172 |
// Set parent product name to include selected options
|
173 |
$parentName = $item->getName() . ' [' . implode(', ', $nameWithOptions) . ']';
|
174 |
$item->setName($parentName);
|
175 |
}
|
176 |
+
|
177 |
$fullItems[] = $item;
|
178 |
break;
|
179 |
+
|
180 |
+
// Grouped products need parent and child items
|
181 |
case Mage_Catalog_Model_Product_Type::TYPE_GROUPED:
|
182 |
// This condition probably never gets hit, parent grouped items don't show in order
|
183 |
$fullItems[] = $item;
|
185 |
$fullItems[] = $child_item;
|
186 |
}
|
187 |
break;
|
188 |
+
|
189 |
+
// Anything else (namely simples) just get added to array
|
190 |
default:
|
191 |
$fullItems[] = $item;
|
192 |
break;
|
193 |
}
|
194 |
}
|
195 |
+
|
196 |
+
// Cycle through newly created array of products
|
197 |
+
foreach ($fullItems as $item/* @var $item Mage_Sales_Model_Order_Item */) {
|
198 |
+
// If product has a parent, get that parent product
|
199 |
+
$parent = false;
|
200 |
+
if ($item->getParentItem()) {
|
201 |
+
$parent = Mage::getModel('catalog/product')->setStoreId($storeId)->load($item->getParentItem()->getProductId());
|
202 |
+
}
|
203 |
+
|
204 |
/* @var $product Mage_Catalog_Model_Product */
|
205 |
+
$product = Mage::getModel('catalog/product')->setStoreId($storeId)->load($item->getProductId());
|
206 |
+
|
207 |
+
// If there is a parent product, use that to get category ids
|
208 |
+
if ($parent) {
|
209 |
+
$categoryIds = $parent->getCategoryIds();
|
210 |
+
} else {
|
211 |
+
$categoryIds = $product->getCategoryIds();
|
212 |
+
}
|
213 |
+
|
214 |
+
// Cycle through category ids to pull category details
|
215 |
+
$categories = array();
|
216 |
foreach ($categoryIds as $categoryId) {
|
217 |
/* @var $category Mage_Catalog_Model_Category */
|
218 |
+
$category = Mage::getModel('catalog/category')->load($categoryId);
|
219 |
+
$parent = $category->getParentCategory();
|
220 |
$categories[] = $parent->getUrlKey() ? $parent->getUrlKey() : $parent->formatUrlKey($parent->getName());
|
221 |
$categories[] = $category->getUrlKey() ? $category->getUrlKey() : $category->formatUrlKey($category->getName());
|
222 |
}
|
223 |
+
|
224 |
+
// Check to ensure there are no duplicate categories
|
225 |
$categories = array_unique($categories);
|
226 |
|
227 |
// Write orderItem
|
228 |
$brontoOrderItems[] = array(
|
229 |
+
'id' => $item->getId(),
|
230 |
+
'sku' => $item->getSku(),
|
231 |
+
'name' => $item->getName(),
|
232 |
'description' => $productHelper->getProductAttribute($item->getProductId(), $descriptionAttr),
|
233 |
+
'category' => implode(' ', $categories),
|
234 |
+
'image' => $this->_helper->getItemImg($item, $product, $storeId),
|
235 |
+
'url' => $this->_helper->getItemUrl($item, $product, $storeId),
|
236 |
+
'quantity' => (int)$item->getQtyOrdered(),
|
237 |
+
'price' => (float)$item->getPrice(),
|
238 |
);
|
239 |
}
|
240 |
$brontoOrder->products = $brontoOrderItems;
|
241 |
$brontoOrder->persist();
|
242 |
break;
|
243 |
}
|
244 |
+
|
245 |
try {
|
246 |
// Mark order as imported
|
247 |
$orderRow->setBrontoImported(Mage::getSingleton('core/date')->gmtDate());
|
248 |
$orderRow->save();
|
249 |
+
|
250 |
// Flush every 10 orders
|
251 |
if ($result['total'] % 100 === 0) {
|
252 |
+
$result = $this->_flushOrders($orderObject, $orderCache, $result);
|
253 |
$orderCache = array();
|
254 |
}
|
255 |
} catch (Exception $e) {
|
256 |
+
$this->_helper->writeError($e);
|
257 |
|
258 |
// Mark import as *not* imported
|
259 |
$orderRow->setBrontoImported(null);
|
|
|
|
|
260 |
$orderRow->save();
|
261 |
|
262 |
+
// increment number of errors
|
263 |
$result['error']++;
|
264 |
}
|
265 |
|
266 |
+
// increment total number of items processed
|
267 |
$result['total']++;
|
268 |
}
|
269 |
}
|
270 |
+
|
271 |
// Final flush (for any we miss)
|
272 |
+
$results = $this->_flushOrders($orderObject, $orderCache, $result);
|
273 |
|
274 |
+
// Log results
|
275 |
+
$this->_helper->writeDebug(' Success: ' . $results['success']);
|
276 |
+
$this->_helper->writeDebug(' Error: ' . $results['error']);
|
277 |
+
$this->_helper->writeDebug(' Total: ' . $results['total']);
|
278 |
|
|
|
|
|
|
|
279 |
return $results;
|
280 |
}
|
281 |
|
282 |
/**
|
283 |
* @param Bronto_Api_Order $orderObject
|
284 |
+
* @param array $orderCache
|
285 |
+
* @param array $result
|
286 |
* @return array
|
287 |
+
* @access protected
|
288 |
*/
|
289 |
+
protected function _flushOrders($orderObject, $orderCache, $result)
|
290 |
{
|
291 |
+
// Get delivery results from order object
|
292 |
$flushResult = $orderObject->flush();
|
293 |
|
294 |
+
// Log Order import flush process starting
|
295 |
+
$this->_helper->writeVerboseDebug('===== FLUSH =====', 'bronto_order_api.log');
|
296 |
+
$this->_helper->writeVerboseDebug(var_export($orderObject->getApi()->getLastRequest(), true), 'bronto_order_api.log');
|
297 |
+
$this->_helper->writeVerboseDebug(var_export($orderObject->getApi()->getLastResponse(), true), 'bronto_order_api.log');
|
298 |
|
299 |
+
// Cycle through flush results and handle any errors that were returned
|
300 |
foreach ($flushResult as $i => $flushResultRow) {
|
301 |
+
$order = Mage::getModel('sales/order')->load($orderCache[$i]);
|
302 |
+
|
303 |
if ($flushResultRow->hasError()) {
|
304 |
+
// Get error code from result
|
305 |
+
$errorCode = $flushResultRow->getErrorCode();
|
306 |
+
|
307 |
+
// Get error message from result
|
308 |
$errorMessage = $flushResultRow->getErrorMessage();
|
309 |
+
|
310 |
+
// Check to see if this item exists in the order cache
|
311 |
if (isset($orderCache[$i])) {
|
312 |
+
/* @var $order Mage_Sales_Model_Order */
|
313 |
$order = Mage::getModel('sales/order')->load($orderCache[$i]);
|
314 |
+
|
315 |
+
// If error code is 915, try to pull customer email address
|
316 |
+
if (915 == $errorCode) {
|
317 |
+
if ($customerEmail = $order->getCustomerEmail()) {
|
318 |
+
$errorMessage = "Invalid Email Address: `{$customerEmail}`";
|
319 |
+
} else {
|
320 |
+
$errorMessage = "Email Address is empty for this order";
|
321 |
+
}
|
322 |
+
}
|
323 |
+
|
324 |
+
// Append order id to message to assiste troubleshooting
|
325 |
+
$errorMessage .= " (Order #: {$order->getIncrementId()})";
|
326 |
+
|
327 |
// Reset Bronto Import status
|
328 |
+
Mage::getModel('bronto_order/queue')
|
329 |
->getOrderRow($order->getId(), $order->getQuoteId(), $order->getStoreId())
|
330 |
->setBrontoImported(null)
|
331 |
->setBrontoSuppressed($errorMessage)
|
332 |
->save();
|
|
|
|
|
|
|
|
|
333 |
}
|
334 |
+
|
335 |
+
// Log and Display error message
|
336 |
+
$this->_helper->writeError("[{$errorCode}] {$errorMessage}");
|
337 |
+
|
338 |
+
// Increment number of errors
|
339 |
$result['error']++;
|
340 |
} else {
|
341 |
+
// Increment number of successes
|
342 |
$result['success']++;
|
343 |
}
|
344 |
}
|
347 |
}
|
348 |
|
349 |
/**
|
350 |
+
* Process Orders for all stores
|
351 |
* @return array
|
352 |
+
* @access public
|
353 |
*/
|
354 |
public function processOrders()
|
355 |
{
|
356 |
+
// Set default result values
|
357 |
$result = array(
|
358 |
+
'total' => 0,
|
359 |
'success' => 0,
|
360 |
+
'error' => 0,
|
361 |
);
|
362 |
|
363 |
+
// Get limit value from config
|
364 |
+
$limit = $this->_helper->getLimit();
|
365 |
+
|
366 |
+
// Pull array of stores to cycle through
|
367 |
$stores = Mage::app()->getStores(true);
|
368 |
+
|
369 |
+
// Cycle through stores
|
370 |
foreach ($stores as $_store) {
|
371 |
+
// If limit is spent, don't process
|
372 |
+
if ($limit <= 0) {
|
373 |
+
continue;
|
374 |
+
}
|
375 |
+
|
376 |
+
// Process Orders for store and collect results
|
377 |
+
$storeResult = $this->processOrdersForStore($_store, $limit);
|
378 |
+
|
379 |
+
// Append results to totals
|
380 |
+
$result['total'] += $storeResult['total'];
|
381 |
$result['success'] += $storeResult['success'];
|
382 |
+
$result['error'] += $storeResult['error'];
|
383 |
+
|
384 |
+
// Decrement limit by resultant total
|
385 |
+
$limit = $limit - $storeResult['total'];
|
386 |
}
|
387 |
|
388 |
return $result;
|
389 |
}
|
390 |
+
|
391 |
}
|
app/code/community/Bronto/Order/Model/Order/Observer.php
CHANGED
@@ -16,12 +16,12 @@ class Bronto_Order_Model_Order_Observer
|
|
16 |
{
|
17 |
/* @var $order Mage_Sales_Model_Order */
|
18 |
$order = $observer->getCreditmemo()->getOrder();
|
19 |
-
|
20 |
/* @var $contactQueue Bronto_Order_Model_Queue */
|
21 |
$orderRow = Mage::getModel('bronto_order/queue')
|
22 |
-
|
23 |
-
|
24 |
-
|
25 |
}
|
26 |
|
27 |
/**
|
@@ -33,12 +33,12 @@ class Bronto_Order_Model_Order_Observer
|
|
33 |
{
|
34 |
/* @var $order Mage_Sales_Model_Order */
|
35 |
$order = $observer->getPayment()->getOrder();
|
36 |
-
|
37 |
/* @var $contactQueue Bronto_Order_Model_Queue */
|
38 |
$orderRow = Mage::getModel('bronto_order/queue')
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
}
|
43 |
|
44 |
/**
|
@@ -51,23 +51,23 @@ class Bronto_Order_Model_Order_Observer
|
|
51 |
{
|
52 |
/* @var $order Mage_Sales_Model_Order */
|
53 |
$order = $observer->getOrder();
|
54 |
-
|
55 |
/* @var $contactQueue Bronto_Order_Model_Queue */
|
56 |
$orderRow = Mage::getModel('bronto_order/queue')
|
57 |
-
|
58 |
-
|
59 |
foreach (Mage::getModel('core/cookie')->get() as $key => $value) {
|
60 |
if (stripos($key, "tid") !== false) {
|
61 |
$orderRow->setBrontoTid($value);
|
62 |
-
|
63 |
break;
|
64 |
}
|
65 |
}
|
66 |
-
|
67 |
$orderRow
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
}
|
73 |
}
|
16 |
{
|
17 |
/* @var $order Mage_Sales_Model_Order */
|
18 |
$order = $observer->getCreditmemo()->getOrder();
|
19 |
+
|
20 |
/* @var $contactQueue Bronto_Order_Model_Queue */
|
21 |
$orderRow = Mage::getModel('bronto_order/queue')
|
22 |
+
->getOrderRow($order->getId(), $order->getQuoteId(), $order->getStoreId())
|
23 |
+
->setBrontoImported(null)
|
24 |
+
->save();
|
25 |
}
|
26 |
|
27 |
/**
|
33 |
{
|
34 |
/* @var $order Mage_Sales_Model_Order */
|
35 |
$order = $observer->getPayment()->getOrder();
|
36 |
+
|
37 |
/* @var $contactQueue Bronto_Order_Model_Queue */
|
38 |
$orderRow = Mage::getModel('bronto_order/queue')
|
39 |
+
->getOrderRow($order->getId(), $order->getQuoteId(), $order->getStoreId())
|
40 |
+
->setBrontoImported(null)
|
41 |
+
->save();
|
42 |
}
|
43 |
|
44 |
/**
|
51 |
{
|
52 |
/* @var $order Mage_Sales_Model_Order */
|
53 |
$order = $observer->getOrder();
|
54 |
+
|
55 |
/* @var $contactQueue Bronto_Order_Model_Queue */
|
56 |
$orderRow = Mage::getModel('bronto_order/queue')
|
57 |
+
->getOrderRow($order->getId(), $order->getQuoteId(), $order->getStoreId());
|
58 |
+
|
59 |
foreach (Mage::getModel('core/cookie')->get() as $key => $value) {
|
60 |
if (stripos($key, "tid") !== false) {
|
61 |
$orderRow->setBrontoTid($value);
|
62 |
+
|
63 |
break;
|
64 |
}
|
65 |
}
|
66 |
+
|
67 |
$orderRow
|
68 |
+
->setCreatedAt($order->getCreatedAt())
|
69 |
+
->setUpdatedAt($order->getUpdatedAt())
|
70 |
+
->setBrontoImported(null)
|
71 |
+
->save();
|
72 |
}
|
73 |
}
|
app/code/community/Bronto/Order/Model/Queue.php
CHANGED
@@ -7,12 +7,13 @@
|
|
7 |
*/
|
8 |
class Bronto_Order_Model_Queue extends Mage_Core_Model_Abstract
|
9 |
{
|
|
|
10 |
public function _construct()
|
11 |
{
|
12 |
parent::_construct();
|
13 |
$this->_init('bronto_order/queue');
|
14 |
}
|
15 |
-
|
16 |
/**
|
17 |
* Retrieve Order Queue Row
|
18 |
* @param int $orderId
|
@@ -26,10 +27,10 @@ class Bronto_Order_Model_Queue extends Mage_Core_Model_Abstract
|
|
26 |
if ((false === $orderId && false === $quoteId) || false === $storeId) {
|
27 |
return $this;
|
28 |
}
|
29 |
-
|
30 |
// Create Collection
|
31 |
$collection = $this->getCollection();
|
32 |
-
|
33 |
// Add Filters
|
34 |
if (($quoteId > 0) && ($orderId > 0)) {
|
35 |
$collection->getSelect()->where("`quote_id` = $quoteId OR `order_id` = $orderId");
|
@@ -39,7 +40,7 @@ class Bronto_Order_Model_Queue extends Mage_Core_Model_Abstract
|
|
39 |
$collection->addFieldToFilter('order_id', $orderId);
|
40 |
}
|
41 |
$collection->addFieldToFilter('store_id', $storeId);
|
42 |
-
|
43 |
try {
|
44 |
// Handle Results
|
45 |
if ($collection->count() == 1) {
|
@@ -66,41 +67,80 @@ class Bronto_Order_Model_Queue extends Mage_Core_Model_Abstract
|
|
66 |
} catch (Exception $e) {
|
67 |
Mage::helper('bronto_order')->writeDebug("Exception Thrown pulling order row");
|
68 |
}
|
69 |
-
|
70 |
return $this;
|
71 |
}
|
72 |
-
|
73 |
-
|
|
|
|
|
|
|
|
|
74 |
{
|
75 |
-
|
76 |
-
$
|
77 |
-
|
78 |
-
|
79 |
-
|
80 |
-
|
81 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
}
|
83 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
84 |
/**
|
85 |
* Get collection of orders which aren't already in the queue, but should be
|
86 |
-
* @
|
87 |
-
* @return Mage_Sales_Model_Resource_Order_Collection
|
88 |
*/
|
89 |
-
public function getMissingOrders(
|
90 |
{
|
91 |
-
|
92 |
-
|
93 |
-
|
94 |
-
|
95 |
-
|
96 |
-
|
97 |
-
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
-
|
|
|
|
|
|
|
|
|
|
|
105 |
}
|
|
|
106 |
}
|
7 |
*/
|
8 |
class Bronto_Order_Model_Queue extends Mage_Core_Model_Abstract
|
9 |
{
|
10 |
+
|
11 |
public function _construct()
|
12 |
{
|
13 |
parent::_construct();
|
14 |
$this->_init('bronto_order/queue');
|
15 |
}
|
16 |
+
|
17 |
/**
|
18 |
* Retrieve Order Queue Row
|
19 |
* @param int $orderId
|
27 |
if ((false === $orderId && false === $quoteId) || false === $storeId) {
|
28 |
return $this;
|
29 |
}
|
30 |
+
|
31 |
// Create Collection
|
32 |
$collection = $this->getCollection();
|
33 |
+
|
34 |
// Add Filters
|
35 |
if (($quoteId > 0) && ($orderId > 0)) {
|
36 |
$collection->getSelect()->where("`quote_id` = $quoteId OR `order_id` = $orderId");
|
40 |
$collection->addFieldToFilter('order_id', $orderId);
|
41 |
}
|
42 |
$collection->addFieldToFilter('store_id', $storeId);
|
43 |
+
|
44 |
try {
|
45 |
// Handle Results
|
46 |
if ($collection->count() == 1) {
|
67 |
} catch (Exception $e) {
|
68 |
Mage::helper('bronto_order')->writeDebug("Exception Thrown pulling order row");
|
69 |
}
|
70 |
+
|
71 |
return $this;
|
72 |
}
|
73 |
+
|
74 |
+
/**
|
75 |
+
* Get Count of missing orders
|
76 |
+
* @return int
|
77 |
+
*/
|
78 |
+
public function getMissingOrdersCount()
|
79 |
{
|
80 |
+
// Get Resources
|
81 |
+
$resource = $this->getResource();
|
82 |
+
$adapter = $resource->getWriteAdapter();
|
83 |
+
|
84 |
+
// Build Select Statement
|
85 |
+
$select = $adapter->select();
|
86 |
+
$select->from(
|
87 |
+
array('order' => $resource->getTable('sales/order')), array(new Zend_Db_Expr('COUNT(entity_id) as count'))
|
88 |
+
)
|
89 |
+
->where('NOT EXISTS (?)', $this->_getSubselect($resource, $adapter));
|
90 |
+
|
91 |
+
// Get Results
|
92 |
+
$result = $adapter->query($select)->fetch();
|
93 |
+
|
94 |
+
if (array_key_exists('count', $result)) {
|
95 |
+
return $result['count'];
|
96 |
+
} else {
|
97 |
+
return 0;
|
98 |
+
}
|
99 |
}
|
100 |
+
|
101 |
+
/**
|
102 |
+
* Get Sub-Select Statement that limits results
|
103 |
+
* @param Bronto_Order_Model_Mysql4_Queue $resource
|
104 |
+
* @param type $adapter
|
105 |
+
* @return Varien_Db_Select
|
106 |
+
*/
|
107 |
+
private function _getSubselect($resource, $adapter)
|
108 |
+
{
|
109 |
+
// Build Sub-Select Statement
|
110 |
+
$subselect = $adapter->select()
|
111 |
+
->from(
|
112 |
+
array('queue' => $resource->getTable('bronto_order/queue')), array(new Zend_Db_Expr(1))
|
113 |
+
)
|
114 |
+
->where('queue.order_id = order.entity_id');
|
115 |
+
|
116 |
+
return $subselect;
|
117 |
+
}
|
118 |
+
|
119 |
/**
|
120 |
* Get collection of orders which aren't already in the queue, but should be
|
121 |
+
* @return array
|
|
|
122 |
*/
|
123 |
+
public function getMissingOrders()
|
124 |
{
|
125 |
+
// Get Resources
|
126 |
+
$resource = $this->getResource();
|
127 |
+
$adapter = $resource->getWriteAdapter();
|
128 |
+
|
129 |
+
// Get Sync Limit Value
|
130 |
+
$count = Mage::helper('bronto_order')->getSyncLimit();
|
131 |
+
|
132 |
+
// Build Select Statement
|
133 |
+
$select = $adapter->select()
|
134 |
+
->from(
|
135 |
+
array('order' => $resource->getTable('sales/order')), array('entity_id', 'store_id', 'quote_id', 'created_at')
|
136 |
+
)
|
137 |
+
->where('NOT EXISTS (?)', $this->_getSubselect($resource, $adapter))
|
138 |
+
->limit($count);
|
139 |
+
|
140 |
+
// Get Results
|
141 |
+
$result = $adapter->query($select)->fetchAll();
|
142 |
+
|
143 |
+
return $result;
|
144 |
}
|
145 |
+
|
146 |
}
|
app/code/community/Bronto/Order/Model/Quote/Observer.php
CHANGED
@@ -17,15 +17,15 @@ class Bronto_Order_Model_Quote_Observer
|
|
17 |
{
|
18 |
/* @var $quote Mage_Sales_Model_Quote */
|
19 |
$quote = $observer->getQuote();
|
20 |
-
|
21 |
/* @var $contactQueue Bronto_Order_Model_Queue */
|
22 |
$orderRow = Mage::getModel('bronto_order/queue')
|
23 |
-
|
24 |
-
|
25 |
foreach (Mage::getModel('core/cookie')->get() as $key => $value) {
|
26 |
if (stripos($key, "tid_") !== false) {
|
27 |
$orderRow->setBrontoTid($value)->save();
|
28 |
-
|
29 |
break;
|
30 |
}
|
31 |
}
|
17 |
{
|
18 |
/* @var $quote Mage_Sales_Model_Quote */
|
19 |
$quote = $observer->getQuote();
|
20 |
+
|
21 |
/* @var $contactQueue Bronto_Order_Model_Queue */
|
22 |
$orderRow = Mage::getModel('bronto_order/queue')
|
23 |
+
->getOrderRow(null, $quote->getId(), $quote->getStoreId());
|
24 |
+
|
25 |
foreach (Mage::getModel('core/cookie')->get() as $key => $value) {
|
26 |
if (stripos($key, "tid_") !== false) {
|
27 |
$orderRow->setBrontoTid($value)->save();
|
28 |
+
|
29 |
break;
|
30 |
}
|
31 |
}
|
app/code/community/Bronto/Order/Model/System/Config/Backend/Cron.php
CHANGED
@@ -15,5 +15,5 @@ class Bronto_Order_Model_System_Config_Backend_Cron extends Bronto_Common_Model_
|
|
15 |
/**
|
16 |
* @var string
|
17 |
*/
|
18 |
-
protected $_cron_model_path
|
19 |
}
|
15 |
/**
|
16 |
* @var string
|
17 |
*/
|
18 |
+
protected $_cron_model_path = 'crontab/jobs/bronto_order_import/run/model';
|
19 |
}
|
app/code/community/Bronto/Order/Model/System/Config/Source/Description.php
CHANGED
@@ -14,7 +14,7 @@ class Bronto_Order_Model_System_Config_Source_Description
|
|
14 |
{
|
15 |
return array(
|
16 |
'short_description' => 'short_description',
|
17 |
-
'description'
|
18 |
);
|
19 |
}
|
20 |
}
|
14 |
{
|
15 |
return array(
|
16 |
'short_description' => 'short_description',
|
17 |
+
'description' => 'description',
|
18 |
);
|
19 |
}
|
20 |
}
|
app/code/community/Bronto/Order/Test/Config/Config.php
DELETED
@@ -1,235 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Bronto_Order_Test_Config_Config
|
3 |
-
extends EcomDev_PHPUnit_Test_Case_Config
|
4 |
-
{
|
5 |
-
// {{{ blocksProvider()
|
6 |
-
|
7 |
-
public function blocksProvider()
|
8 |
-
{
|
9 |
-
return array(
|
10 |
-
array('bronto_order/bta', 'Bronto_Order_Block_Bta'),
|
11 |
-
array('bronto_order/adminhtml_sales_order_view_tab_info', 'Bronto_Order_Block_Adminhtml_Sales_Order_View_Tab_Info'),
|
12 |
-
array('bronto_order/adminhtml_system_config_about', 'Bronto_Order_Block_Adminhtml_System_Config_About'),
|
13 |
-
array('bronto_order/adminhtml_system_config_cron', 'Bronto_Order_Block_Adminhtml_System_Config_Cron'),
|
14 |
-
array('bronto_order/adminhtml_widget_button_reset', 'Bronto_Order_Block_Adminhtml_Widget_Button_Reset'),
|
15 |
-
array('bronto_order/adminhtml_widget_button_run', 'Bronto_Order_Block_Adminhtml_Widget_Button_Run'),
|
16 |
-
);
|
17 |
-
}
|
18 |
-
|
19 |
-
// }}}
|
20 |
-
// {{{ resourceModelProvider()
|
21 |
-
|
22 |
-
public function resourceModelProvider()
|
23 |
-
{
|
24 |
-
return array(
|
25 |
-
array('bronto_order_mysql4/setup', 'Bronto_Order_Model_Mysql4_Setup'),
|
26 |
-
array('bronto_order_mysql4/queue', 'Bronto_Order_Model_Mysql4_Queue'),
|
27 |
-
array('bronto_order_mysql4/queue_collection', 'Bronto_Order_Model_Mysql4_Queue_Collection'),
|
28 |
-
);
|
29 |
-
}
|
30 |
-
|
31 |
-
// }}}
|
32 |
-
// {{{ modelsProvider()
|
33 |
-
|
34 |
-
public function modelsProvider()
|
35 |
-
{
|
36 |
-
return array(
|
37 |
-
array('bronto_order/system_config_backend_cron', 'Bronto_Order_Model_System_Config_Backend_Cron'),
|
38 |
-
array('bronto_order/system_config_source_description', 'Bronto_Order_Model_System_Config_Source_Description'),
|
39 |
-
array('bronto_order/system_config_source_limit', 'Bronto_Order_Model_System_Config_Source_Limit'),
|
40 |
-
array('bronto_order/queue', 'Bronto_Order_Model_Queue'),
|
41 |
-
);
|
42 |
-
}
|
43 |
-
|
44 |
-
// }}}
|
45 |
-
// {{{ helpersProvider()
|
46 |
-
|
47 |
-
public function helpersProvider()
|
48 |
-
{
|
49 |
-
return array(
|
50 |
-
array('bronto_order/data', 'Bronto_Order_Helper_Data'),
|
51 |
-
);
|
52 |
-
}
|
53 |
-
|
54 |
-
// }}}
|
55 |
-
// {{{ observersProvider()
|
56 |
-
|
57 |
-
public function observersProvider()
|
58 |
-
{
|
59 |
-
return array(
|
60 |
-
array('global', 'sales_order_save_before', 'bronto_order/order_observer', 'markOrderForReimport'),
|
61 |
-
array('frontend', 'sales_quote_save_before', 'bronto_order/quote_observer', 'addTidToQuote'),
|
62 |
-
array('adminhtml', 'controller_action_predispatch', 'bronto_order/observer', 'checkBrontoRequirements'),
|
63 |
-
);
|
64 |
-
}
|
65 |
-
|
66 |
-
// }}}
|
67 |
-
// {{{ definedLayoutFilesProvider()
|
68 |
-
|
69 |
-
public function definedLayoutFilesProvider()
|
70 |
-
{
|
71 |
-
return array(
|
72 |
-
/*array('frontend', 'bronto/user.xml'),*/
|
73 |
-
);
|
74 |
-
}
|
75 |
-
|
76 |
-
// }}}
|
77 |
-
// {{{ themeLayoutFilesExistProvider()
|
78 |
-
|
79 |
-
public function themeLayoutFilesExistProvider()
|
80 |
-
{
|
81 |
-
return array(
|
82 |
-
/*array('frontend', 'bronto/user.xml', 'adsinc', 'adsinc'),*/
|
83 |
-
);
|
84 |
-
}
|
85 |
-
|
86 |
-
// }}}
|
87 |
-
|
88 |
-
/**
|
89 |
-
* @test
|
90 |
-
* @group amd
|
91 |
-
* @group config
|
92 |
-
*/
|
93 |
-
public function assertOrderModuleVersionGreaterThanOrEquals()
|
94 |
-
{
|
95 |
-
$this->assertModuleVersionGreaterThanOrEquals('1.1.5');
|
96 |
-
}
|
97 |
-
|
98 |
-
// {{{ assertOrderModuleInLocalCodePool()
|
99 |
-
|
100 |
-
/**
|
101 |
-
* @test
|
102 |
-
* @group amd
|
103 |
-
* @group config
|
104 |
-
*/
|
105 |
-
public function assertOrderModuleInCommunityCodePool()
|
106 |
-
{
|
107 |
-
$this->assertModuleCodePool('community');
|
108 |
-
}
|
109 |
-
|
110 |
-
// }}}
|
111 |
-
// {{{ assertOrderModelAliases()
|
112 |
-
|
113 |
-
/**
|
114 |
-
* @test
|
115 |
-
* @group amd
|
116 |
-
* @group config
|
117 |
-
* @dataProvider modelsProvider
|
118 |
-
*/
|
119 |
-
public function assertOrderModelAliases(
|
120 |
-
$classAlias,
|
121 |
-
$expectedClassName
|
122 |
-
) {
|
123 |
-
$this->assertModelAlias($classAlias, $expectedClassName);
|
124 |
-
}
|
125 |
-
|
126 |
-
// }}}
|
127 |
-
// {{{ assertOrderResourceModelAliases()
|
128 |
-
|
129 |
-
/**
|
130 |
-
* @test
|
131 |
-
* @group amd
|
132 |
-
* @group config
|
133 |
-
* @dataProvider resourceModelProvider
|
134 |
-
*/
|
135 |
-
public function assertOrderResourceModelAliases(
|
136 |
-
$classAlias,
|
137 |
-
$expectedClassName
|
138 |
-
) {
|
139 |
-
$this->assertResourceModelAlias($classAlias, $expectedClassName);
|
140 |
-
}
|
141 |
-
|
142 |
-
// }}}
|
143 |
-
// {{{ assertOrderBlockAliases()
|
144 |
-
|
145 |
-
/**
|
146 |
-
* @test
|
147 |
-
* @group amd
|
148 |
-
* @group config
|
149 |
-
* @dataProvider blocksProvider
|
150 |
-
*/
|
151 |
-
public function assertOrderBlockAliases(
|
152 |
-
$classAlias,
|
153 |
-
$expectedClassName
|
154 |
-
) {
|
155 |
-
$this->assertBlockAlias($classAlias, $expectedClassName);
|
156 |
-
}
|
157 |
-
|
158 |
-
// }}}
|
159 |
-
// {{{ assertOrderHelperAliases()
|
160 |
-
|
161 |
-
/**
|
162 |
-
* @test
|
163 |
-
* @group amd
|
164 |
-
* @group config
|
165 |
-
* @dataProvider helpersProvider
|
166 |
-
*/
|
167 |
-
public function assertOrderHelperAliases(
|
168 |
-
$classAlias,
|
169 |
-
$expectedClassName
|
170 |
-
) {
|
171 |
-
$this->assertHelperAlias($classAlias, $expectedClassName);
|
172 |
-
}
|
173 |
-
|
174 |
-
// }}}
|
175 |
-
// {{{ assertOrderEventObserversDefined()
|
176 |
-
|
177 |
-
/**
|
178 |
-
* @test
|
179 |
-
* @group config
|
180 |
-
* @group amd
|
181 |
-
* @dataProvider observersProvider
|
182 |
-
*/
|
183 |
-
public function assertOrderEventObserversDefined(
|
184 |
-
$area,
|
185 |
-
$eventName,
|
186 |
-
$observerClassAlias,
|
187 |
-
$observerMethod
|
188 |
-
) {
|
189 |
-
$this->assertEventObserverDefined(
|
190 |
-
$area,
|
191 |
-
$eventName,
|
192 |
-
$observerClassAlias,
|
193 |
-
$observerMethod
|
194 |
-
);
|
195 |
-
}
|
196 |
-
|
197 |
-
// }}}
|
198 |
-
// {{{ assertOrderLayoutFileDefined()
|
199 |
-
|
200 |
-
/**
|
201 |
-
* test
|
202 |
-
* @group config
|
203 |
-
* @group amd
|
204 |
-
* @dataProvider definedLayoutFilesProvider
|
205 |
-
*/
|
206 |
-
public function assertOrderLayoutFileDefined($area, $expectedFileName)
|
207 |
-
{
|
208 |
-
$this->assertLayoutFileDefined($area, $expectedFileName);
|
209 |
-
}
|
210 |
-
|
211 |
-
// }}}
|
212 |
-
// {{{ assertOrderLayoutFileExistsForDefaultTheme()
|
213 |
-
|
214 |
-
/**
|
215 |
-
* test
|
216 |
-
* @group config
|
217 |
-
* @group amd
|
218 |
-
* @dataProvider themeLayoutFilesExistProvider
|
219 |
-
*/
|
220 |
-
public function assertOrderLayoutFileExistsForDefaultTheme(
|
221 |
-
$area,
|
222 |
-
$filename,
|
223 |
-
$theme,
|
224 |
-
$designPackage
|
225 |
-
) {
|
226 |
-
$this->assertLayoutFileExistsInTheme(
|
227 |
-
$area,
|
228 |
-
$filename,
|
229 |
-
$theme,
|
230 |
-
$designPackage
|
231 |
-
);
|
232 |
-
}
|
233 |
-
|
234 |
-
// }}}
|
235 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/Order/controllers/Adminhtml/OrderController.php
CHANGED
@@ -6,22 +6,31 @@
|
|
6 |
*/
|
7 |
class Bronto_Order_Adminhtml_OrderController extends Mage_Adminhtml_Controller_Action
|
8 |
{
|
|
|
9 |
/**
|
10 |
* Run immediately
|
11 |
*/
|
12 |
public function runAction()
|
13 |
{
|
|
|
|
|
|
|
|
|
|
|
14 |
try {
|
15 |
-
$result = array('total' => 0, 'success' => 0, 'error' => 0);
|
16 |
-
$model = Mage::getModel('bronto_order/observer');
|
17 |
-
$helper = Mage::helper('bronto_order');
|
18 |
-
|
19 |
if ($storeIds = $helper->getStoreIds()) {
|
|
|
|
|
|
|
20 |
foreach ($storeIds as $storeId) {
|
21 |
-
$
|
22 |
-
|
|
|
|
|
|
|
23 |
$result['success'] += $storeResult['success'];
|
24 |
-
$result['error']
|
|
|
25 |
}
|
26 |
} else {
|
27 |
$result = $model->processOrders();
|
@@ -32,13 +41,14 @@ class Bronto_Order_Adminhtml_OrderController extends Mage_Adminhtml_Controller_A
|
|
32 |
} else {
|
33 |
$this->_getSession()->addError('Scheduled Import failed: ' . $result);
|
34 |
}
|
35 |
-
|
36 |
} catch (Exception $e) {
|
37 |
$this->_getSession()->addError($e->getMessage());
|
38 |
-
|
39 |
}
|
40 |
|
41 |
-
$
|
|
|
|
|
42 |
}
|
43 |
|
44 |
/**
|
@@ -46,44 +56,50 @@ class Bronto_Order_Adminhtml_OrderController extends Mage_Adminhtml_Controller_A
|
|
46 |
*/
|
47 |
public function resetAction()
|
48 |
{
|
49 |
-
$helper
|
50 |
-
$storeIds
|
51 |
-
|
52 |
-
$
|
53 |
|
|
|
54 |
if ($storeIds) {
|
55 |
-
$
|
56 |
}
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
$
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
|
|
|
|
|
|
65 |
}
|
66 |
-
|
67 |
-
$
|
|
|
|
|
68 |
}
|
69 |
-
|
70 |
/**
|
71 |
* Pull Orders from Order Table if not in queue
|
72 |
*/
|
73 |
public function syncAction()
|
74 |
{
|
|
|
75 |
$imported = 0;
|
76 |
-
|
77 |
-
|
78 |
try {
|
79 |
-
$orders =
|
80 |
-
$waiting
|
81 |
-
|
82 |
if ($waiting > 0) {
|
83 |
foreach ($orders as $order) {
|
84 |
-
Mage::getModel('bronto_order/queue')->getOrderRow($order
|
85 |
-
->setQuoteId($order
|
86 |
-
->setCreatedAt($order
|
87 |
->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate())
|
88 |
->setBrontoImported(0)
|
89 |
->save();
|
@@ -92,12 +108,15 @@ class Bronto_Order_Adminhtml_OrderController extends Mage_Adminhtml_Controller_A
|
|
92 |
}
|
93 |
}
|
94 |
} catch (Exception $e) {
|
95 |
-
|
96 |
$this->_getSession()->addError('Sync failed: ' . $e->getMessage());
|
97 |
}
|
98 |
-
|
99 |
$this->_getSession()->addSuccess(sprintf("%d of %d Orders were added to the Queue", $imported, $waiting));
|
100 |
-
|
|
|
|
|
|
|
101 |
}
|
102 |
|
103 |
/**
|
@@ -114,7 +133,7 @@ class Bronto_Order_Adminhtml_OrderController extends Mage_Adminhtml_Controller_A
|
|
114 |
* Will forward to deniedAction(), if not allowed.
|
115 |
*
|
116 |
* @param string $section
|
117 |
-
* @return bool
|
118 |
*/
|
119 |
protected function _isSectionAllowed($section)
|
120 |
{
|
@@ -138,4 +157,5 @@ class Bronto_Order_Adminhtml_OrderController extends Mage_Adminhtml_Controller_A
|
|
138 |
return false;
|
139 |
}
|
140 |
}
|
|
|
141 |
}
|
6 |
*/
|
7 |
class Bronto_Order_Adminhtml_OrderController extends Mage_Adminhtml_Controller_Action
|
8 |
{
|
9 |
+
|
10 |
/**
|
11 |
* Run immediately
|
12 |
*/
|
13 |
public function runAction()
|
14 |
{
|
15 |
+
$result = array('total' => 0, 'success' => 0, 'error' => 0);
|
16 |
+
$model = Mage::getModel('bronto_order/observer');
|
17 |
+
$helper = Mage::helper('bronto_order');
|
18 |
+
$limit = $helper->getLimit();
|
19 |
+
|
20 |
try {
|
|
|
|
|
|
|
|
|
21 |
if ($storeIds = $helper->getStoreIds()) {
|
22 |
+
if (!is_array($storeIds)) {
|
23 |
+
$storeIds = array($storeIds);
|
24 |
+
}
|
25 |
foreach ($storeIds as $storeId) {
|
26 |
+
if ($limit <= 0) {
|
27 |
+
continue;
|
28 |
+
}
|
29 |
+
$storeResult = $model->processOrdersForStore($storeId, $limit);
|
30 |
+
$result['total'] += $storeResult['total'];
|
31 |
$result['success'] += $storeResult['success'];
|
32 |
+
$result['error'] += $storeResult['error'];
|
33 |
+
$limit = $limit - $storeResult['total'];
|
34 |
}
|
35 |
} else {
|
36 |
$result = $model->processOrders();
|
41 |
} else {
|
42 |
$this->_getSession()->addError('Scheduled Import failed: ' . $result);
|
43 |
}
|
|
|
44 |
} catch (Exception $e) {
|
45 |
$this->_getSession()->addError($e->getMessage());
|
46 |
+
$helper->writeError($e);
|
47 |
}
|
48 |
|
49 |
+
$returnParams = array('section' => 'bronto_order');
|
50 |
+
$returnParams = array_merge($returnParams, $helper->getScopeParams());
|
51 |
+
$this->_redirect('*/system_config/edit', $returnParams);
|
52 |
}
|
53 |
|
54 |
/**
|
56 |
*/
|
57 |
public function resetAction()
|
58 |
{
|
59 |
+
$helper = Mage::helper('bronto_order');
|
60 |
+
$storeIds = $helper->getStoreIds();
|
61 |
+
$resource = Mage::getResourceModel('bronto_order/queue');
|
62 |
+
$adapter = $resource->getWriteAdapter();
|
63 |
|
64 |
+
$where = array();
|
65 |
if ($storeIds) {
|
66 |
+
$where = array('store_id IN (?)' => $storeIds);
|
67 |
}
|
68 |
+
|
69 |
+
try {
|
70 |
+
$adapter->update(
|
71 |
+
$resource->getTable('bronto_order/queue'), array(
|
72 |
+
'bronto_imported' => null,
|
73 |
+
'bronto_suppressed' => null,
|
74 |
+
), $where
|
75 |
+
);
|
76 |
+
} catch (Exception $e) {
|
77 |
+
$helper->writeError($e);
|
78 |
+
$this->_getSession()->addError('Reset failed: ' . $e->getMessage());
|
79 |
}
|
80 |
+
|
81 |
+
$returnParams = array('section' => 'bronto_order');
|
82 |
+
$returnParams = array_merge($returnParams, $helper->getScopeParams());
|
83 |
+
$this->_redirect('*/system_config/edit', $returnParams);
|
84 |
}
|
85 |
+
|
86 |
/**
|
87 |
* Pull Orders from Order Table if not in queue
|
88 |
*/
|
89 |
public function syncAction()
|
90 |
{
|
91 |
+
$helper = Mage::helper('bronto_order');
|
92 |
$imported = 0;
|
93 |
+
|
|
|
94 |
try {
|
95 |
+
$orders = $helper->getMissingOrders();
|
96 |
+
$waiting = count($orders);
|
97 |
+
|
98 |
if ($waiting > 0) {
|
99 |
foreach ($orders as $order) {
|
100 |
+
Mage::getModel('bronto_order/queue')->getOrderRow($order['entity_id'], null, $order['store_id'])
|
101 |
+
->setQuoteId($order['quote_id'])
|
102 |
+
->setCreatedAt($order['created_at'])
|
103 |
->setUpdatedAt(Mage::getSingleton('core/date')->gmtDate())
|
104 |
->setBrontoImported(0)
|
105 |
->save();
|
108 |
}
|
109 |
}
|
110 |
} catch (Exception $e) {
|
111 |
+
$helper->writeError($e);
|
112 |
$this->_getSession()->addError('Sync failed: ' . $e->getMessage());
|
113 |
}
|
114 |
+
|
115 |
$this->_getSession()->addSuccess(sprintf("%d of %d Orders were added to the Queue", $imported, $waiting));
|
116 |
+
|
117 |
+
$returnParams = array('section' => 'bronto_order');
|
118 |
+
$returnParams = array_merge($returnParams, $helper->getScopeParams());
|
119 |
+
$this->_redirect('*/system_config/edit', $returnParams);
|
120 |
}
|
121 |
|
122 |
/**
|
133 |
* Will forward to deniedAction(), if not allowed.
|
134 |
*
|
135 |
* @param string $section
|
136 |
+
* @return bool
|
137 |
*/
|
138 |
protected function _isSectionAllowed($section)
|
139 |
{
|
157 |
return false;
|
158 |
}
|
159 |
}
|
160 |
+
|
161 |
}
|
app/code/community/Bronto/Order/etc/adminhtml.xml
CHANGED
@@ -10,6 +10,7 @@
|
|
10 |
<children>
|
11 |
<bronto_order module="bronto_order">
|
12 |
<title>Bronto Order Import Section</title>
|
|
|
13 |
</bronto_order>
|
14 |
</children>
|
15 |
</config>
|
10 |
<children>
|
11 |
<bronto_order module="bronto_order">
|
12 |
<title>Bronto Order Import Section</title>
|
13 |
+
<sort_order>9995</sort_order>
|
14 |
</bronto_order>
|
15 |
</children>
|
16 |
</config>
|
app/code/community/Bronto/Order/etc/config.xml
CHANGED
@@ -24,7 +24,9 @@
|
|
24 |
<bronto_order_mysql4>
|
25 |
<class>Bronto_Order_Model_Mysql4</class>
|
26 |
<entities>
|
27 |
-
<queue
|
|
|
|
|
28 |
</entities>
|
29 |
</bronto_order_mysql4>
|
30 |
</models>
|
@@ -103,7 +105,8 @@
|
|
103 |
<blocks>
|
104 |
<adminhtml>
|
105 |
<rewrite>
|
106 |
-
<sales_order_view_tab_info>bronto_order/adminhtml_sales_order_view_tab_info
|
|
|
107 |
</rewrite>
|
108 |
</adminhtml>
|
109 |
</blocks>
|
@@ -125,14 +128,17 @@
|
|
125 |
<interval>15</interval>
|
126 |
<minutes>0</minutes>
|
127 |
<limit>250</limit>
|
|
|
128 |
<description_attribute>short_description</description_attribute>
|
129 |
</settings>
|
130 |
</bronto_order>
|
131 |
</default>
|
132 |
<crontab>
|
133 |
<jobs>
|
134 |
-
<bronto_order_import>
|
135 |
-
<run
|
|
|
|
|
136 |
</bronto_order_import>
|
137 |
</jobs>
|
138 |
</crontab>
|
@@ -147,30 +153,11 @@
|
|
147 |
</observers>
|
148 |
</controller_action_predispatch>
|
149 |
</events>
|
150 |
-
<acl>
|
151 |
-
<resources>
|
152 |
-
<admin>
|
153 |
-
<children>
|
154 |
-
<system>
|
155 |
-
<children>
|
156 |
-
<config>
|
157 |
-
<children>
|
158 |
-
<bronto_order module="bronto_order">
|
159 |
-
<title>Bronto Order Import Section</title>
|
160 |
-
</bronto_order>
|
161 |
-
</children>
|
162 |
-
</config>
|
163 |
-
</children>
|
164 |
-
</system>
|
165 |
-
</children>
|
166 |
-
</admin>
|
167 |
-
</resources>
|
168 |
-
</acl>
|
169 |
</adminhtml>
|
170 |
<phpunit>
|
171 |
<suite>
|
172 |
<modules>
|
173 |
-
<Bronto_Order
|
174 |
</modules>
|
175 |
</suite>
|
176 |
</phpunit>
|
24 |
<bronto_order_mysql4>
|
25 |
<class>Bronto_Order_Model_Mysql4</class>
|
26 |
<entities>
|
27 |
+
<queue>
|
28 |
+
<table>bronto_order_queue</table>
|
29 |
+
</queue>
|
30 |
</entities>
|
31 |
</bronto_order_mysql4>
|
32 |
</models>
|
105 |
<blocks>
|
106 |
<adminhtml>
|
107 |
<rewrite>
|
108 |
+
<sales_order_view_tab_info>bronto_order/adminhtml_sales_order_view_tab_info
|
109 |
+
</sales_order_view_tab_info>
|
110 |
</rewrite>
|
111 |
</adminhtml>
|
112 |
</blocks>
|
128 |
<interval>15</interval>
|
129 |
<minutes>0</minutes>
|
130 |
<limit>250</limit>
|
131 |
+
<sync_limit>1000</sync_limit>
|
132 |
<description_attribute>short_description</description_attribute>
|
133 |
</settings>
|
134 |
</bronto_order>
|
135 |
</default>
|
136 |
<crontab>
|
137 |
<jobs>
|
138 |
+
<bronto_order_import>
|
139 |
+
<run>
|
140 |
+
<model>bronto_order/observer::processOrders</model>
|
141 |
+
</run>
|
142 |
</bronto_order_import>
|
143 |
</jobs>
|
144 |
</crontab>
|
153 |
</observers>
|
154 |
</controller_action_predispatch>
|
155 |
</events>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
156 |
</adminhtml>
|
157 |
<phpunit>
|
158 |
<suite>
|
159 |
<modules>
|
160 |
+
<Bronto_Order/>
|
161 |
</modules>
|
162 |
</suite>
|
163 |
</phpunit>
|
app/code/community/Bronto/Order/etc/system.xml
CHANGED
@@ -31,6 +31,7 @@
|
|
31 |
<label>Enable Module</label>
|
32 |
<frontend_type>select</frontend_type>
|
33 |
<frontend_model>bronto_common/adminhtml_system_config_form_field</frontend_model>
|
|
|
34 |
<source_model>adminhtml/system_config_source_yesno</source_model>
|
35 |
<sort_order>0</sort_order>
|
36 |
<show_in_default>1</show_in_default>
|
@@ -39,59 +40,84 @@
|
|
39 |
</enabled>
|
40 |
<frequency>
|
41 |
<label>Frequency</label>
|
42 |
-
<depends
|
|
|
|
|
43 |
<frontend_type>select</frontend_type>
|
44 |
<source_model>bronto_common/system_config_source_cron_frequency</source_model>
|
45 |
<backend_model>bronto_order/system_config_backend_cron</backend_model>
|
46 |
<sort_order>20</sort_order>
|
47 |
<show_in_default>1</show_in_default>
|
48 |
-
<show_in_website>
|
49 |
-
<show_in_store>
|
50 |
</frequency>
|
51 |
<interval>
|
52 |
<label>Interval</label>
|
53 |
-
<depends
|
|
|
|
|
54 |
<frontend_type>select</frontend_type>
|
55 |
<source_model>bronto_common/system_config_source_cron_minutes</source_model>
|
56 |
<sort_order>30</sort_order>
|
57 |
<show_in_default>1</show_in_default>
|
58 |
-
<show_in_website>
|
59 |
-
<show_in_store>
|
60 |
<comment>Set this value larger than your cron.php launch period.</comment>
|
61 |
</interval>
|
62 |
<minutes>
|
63 |
<label>Minute of the Hour</label>
|
64 |
-
<depends
|
|
|
|
|
65 |
<frontend_type>text</frontend_type>
|
66 |
<sort_order>40</sort_order>
|
67 |
<show_in_default>1</show_in_default>
|
68 |
-
<show_in_website>
|
69 |
-
<show_in_store>
|
70 |
<comment>Valid range: 0-59 (default 0).</comment>
|
71 |
</minutes>
|
72 |
<time>
|
73 |
<label>Start Time</label>
|
74 |
-
<depends
|
|
|
|
|
75 |
<frontend_type>time</frontend_type>
|
76 |
<sort_order>50</sort_order>
|
77 |
<show_in_default>1</show_in_default>
|
78 |
-
<show_in_website>
|
79 |
-
<show_in_store>
|
80 |
</time>
|
81 |
<limit>
|
82 |
<label>Limit</label>
|
83 |
-
<depends
|
|
|
|
|
84 |
<frontend_type>select</frontend_type>
|
85 |
-
<source_model>
|
86 |
<sort_order>60</sort_order>
|
87 |
<show_in_default>1</show_in_default>
|
88 |
-
<show_in_website>
|
89 |
-
<show_in_store>
|
90 |
<comment>Total Orders to process every cron run.</comment>
|
91 |
</limit>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
92 |
<description_attribute>
|
93 |
<label>Product Description Attribute</label>
|
94 |
-
<depends
|
|
|
|
|
95 |
<frontend_type>select</frontend_type>
|
96 |
<source_model>bronto_order/system_config_source_description</source_model>
|
97 |
<sort_order>70</sort_order>
|
@@ -107,7 +133,7 @@
|
|
107 |
<frontend_model>bronto_order/adminhtml_system_config_cron</frontend_model>
|
108 |
<sort_order>2</sort_order>
|
109 |
<show_in_default>1</show_in_default>
|
110 |
-
<show_in_website>
|
111 |
<show_in_store>1</show_in_store>
|
112 |
</cron_list>
|
113 |
</groups>
|
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>
|
40 |
</enabled>
|
41 |
<frequency>
|
42 |
<label>Frequency</label>
|
43 |
+
<depends>
|
44 |
+
<enabled>1</enabled>
|
45 |
+
</depends>
|
46 |
<frontend_type>select</frontend_type>
|
47 |
<source_model>bronto_common/system_config_source_cron_frequency</source_model>
|
48 |
<backend_model>bronto_order/system_config_backend_cron</backend_model>
|
49 |
<sort_order>20</sort_order>
|
50 |
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>1</show_in_website>
|
52 |
+
<show_in_store>1</show_in_store>
|
53 |
</frequency>
|
54 |
<interval>
|
55 |
<label>Interval</label>
|
56 |
+
<depends>
|
57 |
+
<frequency>I</frequency>
|
58 |
+
</depends>
|
59 |
<frontend_type>select</frontend_type>
|
60 |
<source_model>bronto_common/system_config_source_cron_minutes</source_model>
|
61 |
<sort_order>30</sort_order>
|
62 |
<show_in_default>1</show_in_default>
|
63 |
+
<show_in_website>1</show_in_website>
|
64 |
+
<show_in_store>1</show_in_store>
|
65 |
<comment>Set this value larger than your cron.php launch period.</comment>
|
66 |
</interval>
|
67 |
<minutes>
|
68 |
<label>Minute of the Hour</label>
|
69 |
+
<depends>
|
70 |
+
<frequency>H</frequency>
|
71 |
+
</depends>
|
72 |
<frontend_type>text</frontend_type>
|
73 |
<sort_order>40</sort_order>
|
74 |
<show_in_default>1</show_in_default>
|
75 |
+
<show_in_website>1</show_in_website>
|
76 |
+
<show_in_store>1</show_in_store>
|
77 |
<comment>Valid range: 0-59 (default 0).</comment>
|
78 |
</minutes>
|
79 |
<time>
|
80 |
<label>Start Time</label>
|
81 |
+
<depends>
|
82 |
+
<enabled>1</enabled>
|
83 |
+
</depends>
|
84 |
<frontend_type>time</frontend_type>
|
85 |
<sort_order>50</sort_order>
|
86 |
<show_in_default>1</show_in_default>
|
87 |
+
<show_in_website>1</show_in_website>
|
88 |
+
<show_in_store>1</show_in_store>
|
89 |
</time>
|
90 |
<limit>
|
91 |
<label>Limit</label>
|
92 |
+
<depends>
|
93 |
+
<enabled>1</enabled>
|
94 |
+
</depends>
|
95 |
<frontend_type>select</frontend_type>
|
96 |
+
<source_model>bronto_common/system_config_source_limit</source_model>
|
97 |
<sort_order>60</sort_order>
|
98 |
<show_in_default>1</show_in_default>
|
99 |
+
<show_in_website>1</show_in_website>
|
100 |
+
<show_in_store>1</show_in_store>
|
101 |
<comment>Total Orders to process every cron run.</comment>
|
102 |
</limit>
|
103 |
+
<sync_limit>
|
104 |
+
<label>Sync Limit</label>
|
105 |
+
<depends>
|
106 |
+
<enabled>1</enabled>
|
107 |
+
</depends>
|
108 |
+
<frontend_type>select</frontend_type>
|
109 |
+
<source_model>bronto_common/system_config_source_synclimit</source_model>
|
110 |
+
<sort_order>65</sort_order>
|
111 |
+
<show_in_default>1</show_in_default>
|
112 |
+
<show_in_website>1</show_in_website>
|
113 |
+
<show_in_store>1</show_in_store>
|
114 |
+
<comment>Total Orders to sync to queue at a time.</comment>
|
115 |
+
</sync_limit>
|
116 |
<description_attribute>
|
117 |
<label>Product Description Attribute</label>
|
118 |
+
<depends>
|
119 |
+
<enabled>1</enabled>
|
120 |
+
</depends>
|
121 |
<frontend_type>select</frontend_type>
|
122 |
<source_model>bronto_order/system_config_source_description</source_model>
|
123 |
<sort_order>70</sort_order>
|
133 |
<frontend_model>bronto_order/adminhtml_system_config_cron</frontend_model>
|
134 |
<sort_order>2</sort_order>
|
135 |
<show_in_default>1</show_in_default>
|
136 |
+
<show_in_website>1</show_in_website>
|
137 |
<show_in_store>1</show_in_store>
|
138 |
</cron_list>
|
139 |
</groups>
|
app/code/community/Bronto/Order/sql/bronto_order_setup/mysql4-install-1.0.0.php
CHANGED
@@ -8,19 +8,19 @@ $installer->startSetup();
|
|
8 |
//
|
9 |
// Quote Attributes
|
10 |
$installer->addAttribute('quote', 'bronto_tid', array(
|
11 |
-
'type'
|
12 |
'required' => false,
|
13 |
));
|
14 |
|
15 |
//
|
16 |
// Order Attributes
|
17 |
$installer->addAttribute('order', 'bronto_tid', array(
|
18 |
-
'type'
|
19 |
'required' => false,
|
20 |
));
|
21 |
|
22 |
$installer->addAttribute('order', 'bronto_imported', array(
|
23 |
-
'type'
|
24 |
'required' => false,
|
25 |
));
|
26 |
|
8 |
//
|
9 |
// Quote Attributes
|
10 |
$installer->addAttribute('quote', 'bronto_tid', array(
|
11 |
+
'type' => 'varchar',
|
12 |
'required' => false,
|
13 |
));
|
14 |
|
15 |
//
|
16 |
// Order Attributes
|
17 |
$installer->addAttribute('order', 'bronto_tid', array(
|
18 |
+
'type' => 'varchar',
|
19 |
'required' => false,
|
20 |
));
|
21 |
|
22 |
$installer->addAttribute('order', 'bronto_imported', array(
|
23 |
+
'type' => 'datetime',
|
24 |
'required' => false,
|
25 |
));
|
26 |
|
app/code/community/Bronto/Order/sql/bronto_order_setup/mysql4-install-1.1.8.php
ADDED
@@ -0,0 +1,53 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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_Mysql4_Setup */
|
8 |
+
|
9 |
+
$installer->startSetup();
|
10 |
+
|
11 |
+
try {
|
12 |
+
// Create New Table
|
13 |
+
$installer->run("
|
14 |
+
DROP TABLE IF EXISTS `{$this->getTable('bronto_order_queue')}`;
|
15 |
+
|
16 |
+
CREATE TABLE `{$this->getTable('bronto_order_queue')}` (
|
17 |
+
`queue_id` int(10) NOT NULL AUTO_INCREMENT,
|
18 |
+
`order_id` int(10) unsigned NOT NULL COMMENT 'Order Entity Id',
|
19 |
+
`quote_id` int(11) unsigned NOT NULL COMMENT 'Quote Id',
|
20 |
+
`store_id` smallint(5) unsigned NOT NULL COMMENT 'Store Id',
|
21 |
+
`bronto_tid` varchar(255) DEFAULT NULL COMMENT 'Bronto Tid',
|
22 |
+
`bronto_imported` datetime DEFAULT NULL COMMENT 'Bronto Imported',
|
23 |
+
`created_at` timestamp NULL DEFAULT NULL COMMENT 'Created At',
|
24 |
+
`updated_at` timestamp NULL DEFAULT NULL COMMENT 'Updated At',
|
25 |
+
`bronto_suppressed` varchar(255) DEFAULT NULL,
|
26 |
+
PRIMARY KEY (`queue_id`,`order_id`,`store_id`,`quote_id`),
|
27 |
+
KEY `IDX_BRONTO_ORDER_QUEUE_STORE_ID` (`store_id`),
|
28 |
+
KEY `IDX_BRONTO_ORDER_QUEUE_QUOTE_ID` (`quote_id`),
|
29 |
+
KEY `IDX_BRONTO_ORDER_QUEUE_BRONTO_IMPORTED` (`bronto_imported`),
|
30 |
+
KEY `IDX_BRONTO_ORDER_QUEUE_CREATED_AT` (`created_at`),
|
31 |
+
KEY `IDX_BRONTO_ORDER_QUEUE_UPDATED_AT` (`updated_at`),
|
32 |
+
CONSTRAINT `FK_BRONTO_ORDER_QUEUE_STORE_ID_CORE_STORE_STORE_ID` FOREIGN KEY (`store_id`)
|
33 |
+
REFERENCES {$this->getTable('core_store')} (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE
|
34 |
+
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Order Import Queue'
|
35 |
+
|
36 |
+
");
|
37 |
+
} catch (Exception $e) {
|
38 |
+
throw new RuntimeException('Failed Creating Order Queue Table: ' . $e->getMessage());
|
39 |
+
}
|
40 |
+
|
41 |
+
try {
|
42 |
+
// Populate New Table
|
43 |
+
$installer->run("
|
44 |
+
INSERT IGNORE INTO `{$this->getTable('bronto_order_queue')}`
|
45 |
+
(`order_id`, `quote_id`, `store_id`, `bronto_tid`, `bronto_imported`, `created_at`, `updated_at`)
|
46 |
+
SELECT `entity_id`, `quote_id`, `store_id`, NULL, NULL, `created_at`, `updated_at`
|
47 |
+
FROM `{$this->getTable('sales/order')}`;
|
48 |
+
");
|
49 |
+
} catch (Exception $e) {
|
50 |
+
throw new RuntimeException('Failed Populating Order Queue Table: ' . $e->getMessage());
|
51 |
+
}
|
52 |
+
|
53 |
+
$installer->endSetup();
|
app/code/community/Bronto/Order/sql/bronto_order_setup/{mysql4-upgrade-1.1.5-1.1.6.php → mysql4-upgrade-1.0.0-1.1.6.php}
RENAMED
@@ -28,7 +28,7 @@ try {
|
|
28 |
CONSTRAINT `FK_BRONTO_ORDER_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
|
29 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Order Import Queue';
|
30 |
");
|
31 |
-
|
32 |
// Populate New Table
|
33 |
$installer->run("
|
34 |
INSERT IGNORE INTO `{$this->getTable('bronto_order_queue')}`
|
28 |
CONSTRAINT `FK_BRONTO_ORDER_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
|
29 |
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Bronto Order Import Queue';
|
30 |
");
|
31 |
+
|
32 |
// Populate New Table
|
33 |
$installer->run("
|
34 |
INSERT IGNORE INTO `{$this->getTable('bronto_order_queue')}`
|
app/code/community/Bronto/PermissionChecker/Block/Adminhtml/System/Config/About.php
DELETED
@@ -1,54 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* About header for admin module config
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package PermissionChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
|
21 |
-
/**
|
22 |
-
* About header for admin module config
|
23 |
-
*
|
24 |
-
* @category Bronto
|
25 |
-
* @package PermissionChecker
|
26 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
27 |
-
* @copyright 2012 Atlantic BT
|
28 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
29 |
-
* @version Release: @package_version@
|
30 |
-
* @link <>
|
31 |
-
* @see References to other sections (if any)...
|
32 |
-
*/
|
33 |
-
class Bronto_PermissionChecker_Block_Adminhtml_System_Config_About
|
34 |
-
extends Bronto_Common_Block_Adminhtml_System_Config_About
|
35 |
-
{
|
36 |
-
// {{{ properties
|
37 |
-
|
38 |
-
|
39 |
-
/**
|
40 |
-
* Module name
|
41 |
-
* @var string
|
42 |
-
* @access protected
|
43 |
-
*/
|
44 |
-
protected $_module = 'bronto_permissionchecker';
|
45 |
-
|
46 |
-
/**
|
47 |
-
* User descriptive module name
|
48 |
-
* @var string
|
49 |
-
* @access protected
|
50 |
-
*/
|
51 |
-
protected $_name = 'Bronto File System Permissions Checker Module';
|
52 |
-
|
53 |
-
// }}}
|
54 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/PermissionChecker/Block/Adminhtml/System/Config/Permissionchecker.php
DELETED
@@ -1,78 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Permission checker
|
5 |
-
*
|
6 |
-
* This is the heart of the permission checker that glues together and fires
|
7 |
-
* the Chain of responsibility
|
8 |
-
*
|
9 |
-
* PHP version 5
|
10 |
-
*
|
11 |
-
* The license text...
|
12 |
-
*
|
13 |
-
* @category Bronto
|
14 |
-
* @package PermissionChecker
|
15 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
16 |
-
* @copyright 2012 Atlantic BT
|
17 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
18 |
-
* @version CVS: $Id:$
|
19 |
-
* @link <>
|
20 |
-
* @see References to other sections (if any)...
|
21 |
-
*/
|
22 |
-
|
23 |
-
/**
|
24 |
-
* Permission checker
|
25 |
-
*
|
26 |
-
* This is the heart of the permission checker that glues together and fires
|
27 |
-
* the Chain of responsibility
|
28 |
-
*
|
29 |
-
* @category Bronto
|
30 |
-
* @package PermissionChecker
|
31 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
32 |
-
* @copyright 2012 Atlantic BT
|
33 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
34 |
-
* @version Release: @package_version@
|
35 |
-
* @link <>
|
36 |
-
* @see References to other sections (if any)...
|
37 |
-
*/
|
38 |
-
class Bronto_PermissionChecker_Block_Adminhtml_System_Config_Permissionchecker
|
39 |
-
extends Mage_Adminhtml_Block_Abstract
|
40 |
-
implements Varien_Data_Form_Element_Renderer_Interface
|
41 |
-
{
|
42 |
-
// {{{ render()
|
43 |
-
|
44 |
-
|
45 |
-
/**
|
46 |
-
* Render all files that don't validate to the proper permissions
|
47 |
-
*
|
48 |
-
* @param Varien_Data_Form_Element_Abstract $element Form element
|
49 |
-
*
|
50 |
-
* @return string
|
51 |
-
* @access public
|
52 |
-
*/
|
53 |
-
public function render(Varien_Data_Form_Element_Abstract $element)
|
54 |
-
{
|
55 |
-
// Chain of Responsibility
|
56 |
-
// each checker looks through its designated area to validate the node we're at.
|
57 |
-
$file = Mage::getModel('bronto_permissionchecker/validator_file');
|
58 |
-
$dir = Mage::getModel('bronto_permissionchecker/validator_directory', array($file));
|
59 |
-
$group = Mage::getModel('bronto_permissionchecker/validator_group', array($dir));
|
60 |
-
$owner = Mage::getModel('bronto_permissionchecker/validator_owner', array($group));
|
61 |
-
|
62 |
-
$checker = Mage::getModel('bronto_permissionchecker/validator_checker', array($owner));
|
63 |
-
|
64 |
-
$directory = new RecursiveDirectoryIterator(Mage::getBaseDir());
|
65 |
-
$filter = new Bronto_PermissionChecker_Model_Validator_Filter_PatternIterator($directory);
|
66 |
-
$iterator = new RecursiveIteratorIterator(
|
67 |
-
$filter,
|
68 |
-
RecursiveIteratorIterator::LEAVES_ONLY,
|
69 |
-
RecursiveIteratorIterator::CATCH_GET_CHILD
|
70 |
-
);
|
71 |
-
$invalidFiles = $checker->validateSettings($iterator);
|
72 |
-
|
73 |
-
$printer = new Bronto_PermissionChecker_Model_Validator_Printer();
|
74 |
-
return $printer->render($invalidFiles);
|
75 |
-
}
|
76 |
-
|
77 |
-
// }}}
|
78 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/PermissionChecker/Block/Printer.php
DELETED
@@ -1,77 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Table generator
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package PermissionChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Table generator
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package PermissionChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
class Bronto_PermissionChecker_Block_Printer
|
33 |
-
extends Mage_Adminhtml_Block_Template
|
34 |
-
{
|
35 |
-
// {{{ properties
|
36 |
-
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Parity bit
|
40 |
-
* @var integer
|
41 |
-
* @access protected
|
42 |
-
*/
|
43 |
-
protected $_i = 0;
|
44 |
-
|
45 |
-
// }}}
|
46 |
-
// {{{ _construct()
|
47 |
-
|
48 |
-
|
49 |
-
/**
|
50 |
-
* psuedo constructor
|
51 |
-
*
|
52 |
-
* @return void
|
53 |
-
* @access public
|
54 |
-
*/
|
55 |
-
public function _construct()
|
56 |
-
{
|
57 |
-
parent::_construct();
|
58 |
-
$this->setTemplate('bronto/permissionchecker/errors.phtml');
|
59 |
-
}
|
60 |
-
|
61 |
-
// }}}
|
62 |
-
// {{{ getParity()
|
63 |
-
|
64 |
-
|
65 |
-
/**
|
66 |
-
* Get if even or odd
|
67 |
-
*
|
68 |
-
* @return string
|
69 |
-
* @access public
|
70 |
-
*/
|
71 |
-
public function getParity()
|
72 |
-
{
|
73 |
-
return $this->_i++ % 2 ? 'even' : '';
|
74 |
-
}
|
75 |
-
|
76 |
-
// }}}
|
77 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/PermissionChecker/Helper/Data.php
DELETED
@@ -1,33 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
/**
|
3 |
-
* Data helper
|
4 |
-
*
|
5 |
-
* PHP version 5
|
6 |
-
*
|
7 |
-
* The license text...
|
8 |
-
*
|
9 |
-
* @category Permissions
|
10 |
-
* @package PermissionChecker
|
11 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
12 |
-
* @copyright 2012 Atlantic BT
|
13 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
14 |
-
* @version CVS: $Id:$
|
15 |
-
* @link <>
|
16 |
-
* @see References to other sections (if any)...
|
17 |
-
*/
|
18 |
-
|
19 |
-
/**
|
20 |
-
* Data helper
|
21 |
-
*
|
22 |
-
* @category Permissions
|
23 |
-
* @package PermissionChecker
|
24 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
25 |
-
* @copyright 2012 Atlantic BT
|
26 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
27 |
-
* @version Release: @package_version@
|
28 |
-
* @link <>
|
29 |
-
* @see References to other sections (if any)...
|
30 |
-
*/
|
31 |
-
class Bronto_PermissionChecker_Helper_Data extends Bronto_Common_Helper_Data
|
32 |
-
{
|
33 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/PermissionChecker/Model/Validator/Directory.php
DELETED
@@ -1,65 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Directory Validator
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package PermissionChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Directory Validator
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package PermissionChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
class Bronto_PermissionChecker_Model_Validator_Directory
|
33 |
-
extends Bronto_PermissionChecker_Model_Validator_ValidatorAbstract
|
34 |
-
{
|
35 |
-
// {{{ validateSetting()
|
36 |
-
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Validate directory
|
40 |
-
*
|
41 |
-
* Checks to see if file is directory and if permissions match expected
|
42 |
-
*
|
43 |
-
* @param SplFileInfo $file File to check
|
44 |
-
* @param array $badFiles current array of bad files to report
|
45 |
-
*
|
46 |
-
* @return array
|
47 |
-
* @access public
|
48 |
-
*/
|
49 |
-
public function validateSetting(SplFileInfo $file, array $badFiles)
|
50 |
-
{
|
51 |
-
if ($file->isDir()) {
|
52 |
-
$filePermission = Mage::getStoreConfig('permission_checker/settings/directories');
|
53 |
-
$filePermLen = strlen($filePermission);
|
54 |
-
$octalPerms = substr(sprintf('%o', $file->getPerms()), -$filePermLen);
|
55 |
-
|
56 |
-
if ($octalPerms != $filePermission) {
|
57 |
-
$path = substr_replace($file->__toString(), '', 0, strlen(Mage::getBaseDir()) + 1);
|
58 |
-
$badFiles[$path]['perms'] = $octalPerms;
|
59 |
-
}
|
60 |
-
}
|
61 |
-
return parent::validateSetting($file, $badFiles);
|
62 |
-
}
|
63 |
-
|
64 |
-
// }}}
|
65 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/PermissionChecker/Model/Validator/File.php
DELETED
@@ -1,67 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Validate file permission
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package PermissionChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Validate file permission
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package PermissionChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
class Bronto_PermissionChecker_Model_Validator_File
|
33 |
-
extends Bronto_PermissionChecker_Model_Validator_ValidatorAbstract
|
34 |
-
{
|
35 |
-
// {{{ validateSetting()
|
36 |
-
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Validate file permissions
|
40 |
-
*
|
41 |
-
* Checks to see if file permissions match correctly
|
42 |
-
*
|
43 |
-
* @param SplFileInfo $file File to check
|
44 |
-
* @param array $badFiles current array of bad files to report
|
45 |
-
*
|
46 |
-
* @return array
|
47 |
-
* @access public
|
48 |
-
*/
|
49 |
-
public function validateSetting(SplFileInfo $file, array $badFiles)
|
50 |
-
{
|
51 |
-
if ($file->isFile()) {
|
52 |
-
$filePermission = Mage::getStoreConfig('permission_checker/settings/files');
|
53 |
-
// This allows us to handle how big a sub string to return
|
54 |
-
// which will dynamically account for extra permission bits. i.e. (sticky bits)
|
55 |
-
$filePermLen = strlen($filePermission);
|
56 |
-
$octalPerms = substr(sprintf('%o', $file->getPerms()), -$filePermLen);
|
57 |
-
|
58 |
-
if ($octalPerms != $filePermission) {
|
59 |
-
$path = substr_replace($file->__toString(), '', 0, strlen(Mage::getBaseDir()) + 1);
|
60 |
-
$badFiles[$path]['perms'] = $octalPerms;
|
61 |
-
}
|
62 |
-
}
|
63 |
-
return parent::validateSetting($file, $badFiles);
|
64 |
-
}
|
65 |
-
|
66 |
-
// }}}
|
67 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/PermissionChecker/Model/Validator/Filter/PatternIterator.php
DELETED
@@ -1,55 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* File Filter iterator
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package PermissionChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* File Filter iterator
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package PermissionChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
class Bronto_PermissionChecker_Model_Validator_Filter_PatternIterator
|
33 |
-
extends RecursiveFilterIterator
|
34 |
-
{
|
35 |
-
// {{{ accept()
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Check file name to see if it matches anything that needs to be filtered
|
39 |
-
*
|
40 |
-
* @return boolean
|
41 |
-
* @access public
|
42 |
-
*/
|
43 |
-
public function accept()
|
44 |
-
{
|
45 |
-
$exclusions = Mage::getStoreConfig('permission_checker/settings/exclude');
|
46 |
-
$exclusions = explode(',', $exclusions);
|
47 |
-
$exclusions[] = '.';
|
48 |
-
$exclusions[] = '..';
|
49 |
-
array_walk($exclusions, create_function('&$val', '$val = trim($val);'));
|
50 |
-
|
51 |
-
return !in_array($this->current()->getBasename(), $exclusions);
|
52 |
-
}
|
53 |
-
|
54 |
-
// }}}
|
55 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/PermissionChecker/Model/Validator/Group.php
DELETED
@@ -1,69 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Validate File Group
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package PermissionChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Validate File Group
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package PermissionChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
class Bronto_PermissionChecker_Model_Validator_Group
|
33 |
-
extends Bronto_PermissionChecker_Model_Validator_ValidatorAbstract
|
34 |
-
{
|
35 |
-
// {{{ validateSetting()
|
36 |
-
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Validate Group
|
40 |
-
*
|
41 |
-
* Checks to see if file group setting matches expected
|
42 |
-
*
|
43 |
-
* @param SplFileInfo $file File to check
|
44 |
-
* @param array $badFiles current array of bad files to report
|
45 |
-
*
|
46 |
-
* @return array
|
47 |
-
* @access public
|
48 |
-
*/
|
49 |
-
public function validateSetting(SplFileInfo $file, array $badFiles)
|
50 |
-
{
|
51 |
-
$targetGroup = Mage::getStoreConfig('permission_checker/settings/group');
|
52 |
-
if (!empty($targetGroup)) {
|
53 |
-
// Account for name and/or gid
|
54 |
-
if (filter_var($targetGroup, FILTER_VALIDATE_INT)) {
|
55 |
-
$actualGroup = $file->getGroup();
|
56 |
-
} else {
|
57 |
-
$group = posix_getgrgid($file->getGroup());
|
58 |
-
$actualGroup = $group['name'];
|
59 |
-
}
|
60 |
-
if ($actualGroup != $targetGroup) {
|
61 |
-
$path = substr_replace($file->__toString(), '', 0, strlen(Mage::getBaseDir()) + 1);
|
62 |
-
$badFiles[$path]['group'] = $actualGroup;
|
63 |
-
}
|
64 |
-
}
|
65 |
-
return parent::validateSetting($file, $badFiles);
|
66 |
-
}
|
67 |
-
|
68 |
-
// }}}
|
69 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/PermissionChecker/Model/Validator/Owner.php
DELETED
@@ -1,69 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* File Owner Validator
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package PermissionChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* File Owner Validator
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package PermissionChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
class Bronto_PermissionChecker_Model_Validator_Owner
|
33 |
-
extends Bronto_PermissionChecker_Model_Validator_ValidatorAbstract
|
34 |
-
{
|
35 |
-
// {{{ validateSetting()
|
36 |
-
|
37 |
-
|
38 |
-
/**
|
39 |
-
* Validate Owner
|
40 |
-
*
|
41 |
-
* Checks to see if file owner setting matches expected
|
42 |
-
*
|
43 |
-
* @param SplFileInfo $file File to check
|
44 |
-
* @param array $badFiles current array of bad files to report
|
45 |
-
*
|
46 |
-
* @return array
|
47 |
-
* @access public
|
48 |
-
*/
|
49 |
-
public function validateSetting(SplFileInfo $file, array $badFiles)
|
50 |
-
{
|
51 |
-
$targetOwner = Mage::getStoreConfig('permission_checker/settings/owner');
|
52 |
-
if (!empty($targetOwner)) {
|
53 |
-
// Account for name and/or gid
|
54 |
-
if (filter_var($targetGroup, FILTER_VALIDATE_INT)) {
|
55 |
-
$actualOwner = $file->getOwner();
|
56 |
-
} else {
|
57 |
-
$owner = posix_getpwuid($file->getOwner());
|
58 |
-
$actualOwner = $owner['name'];
|
59 |
-
}
|
60 |
-
if ($actualOwner != $targetOwner) {
|
61 |
-
$path = substr_replace($file->__toString(), '', 0, strlen(Mage::getBaseDir()) + 1);
|
62 |
-
$badFiles[$path]['owner'] = $actualOwner;
|
63 |
-
}
|
64 |
-
}
|
65 |
-
return parent::validateSetting($file, $badFiles);
|
66 |
-
}
|
67 |
-
|
68 |
-
// }}}
|
69 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/PermissionChecker/Model/Validator/Printer.php
DELETED
@@ -1,53 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Render the block view
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package PermissionChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Render the block view
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package PermissionChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
class Bronto_PermissionChecker_Model_Validator_Printer
|
33 |
-
{
|
34 |
-
// {{{ render()
|
35 |
-
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Render block view
|
39 |
-
*
|
40 |
-
* @param array $errors bad files to print
|
41 |
-
*
|
42 |
-
* @return string
|
43 |
-
* @access public
|
44 |
-
*/
|
45 |
-
public function render(array $errors)
|
46 |
-
{
|
47 |
-
$block = Mage::app()->getLayout()->createBlock('bronto_permissionchecker/printer');
|
48 |
-
$block->setErrors($errors);
|
49 |
-
return $block->toHtml();
|
50 |
-
}
|
51 |
-
|
52 |
-
// }}}
|
53 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/PermissionChecker/Model/Validator/ValidatorInterface.php
DELETED
@@ -1,48 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
|
3 |
-
/**
|
4 |
-
* Validator interface
|
5 |
-
*
|
6 |
-
* PHP version 5
|
7 |
-
*
|
8 |
-
* The license text...
|
9 |
-
*
|
10 |
-
* @category Bronto
|
11 |
-
* @package PermissionChecker
|
12 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
13 |
-
* @copyright 2012 Atlantic BT
|
14 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
15 |
-
* @version CVS: $Id:$
|
16 |
-
* @link <>
|
17 |
-
* @see References to other sections (if any)...
|
18 |
-
*/
|
19 |
-
|
20 |
-
/**
|
21 |
-
* Validator interface
|
22 |
-
*
|
23 |
-
* @category Bronto
|
24 |
-
* @package PermissionChecker
|
25 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
26 |
-
* @copyright 2012 Atlantic BT
|
27 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
28 |
-
* @version Release: @package_version@
|
29 |
-
* @link <>
|
30 |
-
* @see References to other sections (if any)...
|
31 |
-
*/
|
32 |
-
interface Bronto_PermissionChecker_Model_Validator_ValidatorInterface
|
33 |
-
{
|
34 |
-
// {{{ validateSetting()
|
35 |
-
|
36 |
-
|
37 |
-
/**
|
38 |
-
* Validate business logic for chain of responsibility nodes
|
39 |
-
*
|
40 |
-
* @param SplFileInfo $file File node to check
|
41 |
-
* @param array $badFiles existing bad files to report on
|
42 |
-
*
|
43 |
-
* @access public
|
44 |
-
*/
|
45 |
-
public function validateSetting(SplFileInfo $file, array $badFiles);
|
46 |
-
|
47 |
-
// }}}
|
48 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/PermissionChecker/Test/Config/Config.php
DELETED
@@ -1,197 +0,0 @@
|
|
1 |
-
<?php
|
2 |
-
class Bronto_PermissionChecker_Test_Config_Config
|
3 |
-
extends EcomDev_PHPUnit_Test_Case_Config
|
4 |
-
{
|
5 |
-
public function blocksProvider()
|
6 |
-
{
|
7 |
-
return array(
|
8 |
-
array('bronto_permissionchecker/printer', 'Bronto_PermissionChecker_Block_Printer'),
|
9 |
-
array('bronto_permissionchecker/adminhtml_system_config_about', 'Bronto_PermissionChecker_Block_Adminhtml_System_Config_About'),
|
10 |
-
array('bronto_permissionchecker/adminhtml_system_config_permissionchecker', 'Bronto_PermissionChecker_Block_Adminhtml_System_Config_Permissionchecker'),
|
11 |
-
);
|
12 |
-
}
|
13 |
-
|
14 |
-
public function resourceModelProvider()
|
15 |
-
{
|
16 |
-
return array();
|
17 |
-
}
|
18 |
-
|
19 |
-
public function modelsProvider()
|
20 |
-
{
|
21 |
-
return array(
|
22 |
-
array('bronto_permissionchecker/validator_checker', 'Bronto_PermissionChecker_Model_Validator_Checker'),
|
23 |
-
array('bronto_permissionchecker/validator_directory', 'Bronto_PermissionChecker_Model_Validator_Directory'),
|
24 |
-
array('bronto_permissionchecker/validator_file', 'Bronto_PermissionChecker_Model_Validator_File'),
|
25 |
-
array('bronto_permissionchecker/validator_group', 'Bronto_PermissionChecker_Model_Validator_Group'),
|
26 |
-
array('bronto_permissionchecker/validator_owner', 'Bronto_PermissionChecker_Model_Validator_Owner'),
|
27 |
-
array('bronto_permissionchecker/validator_printer', 'Bronto_PermissionChecker_Model_Validator_Printer'),
|
28 |
-
array('bronto_permissionchecker/validator_validatorabstract', 'Bronto_PermissionChecker_Model_Validator_Validatorabstract'),
|
29 |
-
array('bronto_permissionchecker/validator_validatorinterface', 'Bronto_PermissionChecker_Model_Validator_Validatorinterface'),
|
30 |
-
array('bronto_permissionchecker/validator_filter_patterniterator', 'Bronto_PermissionChecker_Model_Validator_Filter_Patterniterator'),
|
31 |
-
);
|
32 |
-
}
|
33 |
-
|
34 |
-
public function helpersProvider()
|
35 |
-
{
|
36 |
-
return array(
|
37 |
-
array('bronto_permissionchecker/data', 'Bronto_PermissionChecker_Helper_Data'),
|
38 |
-
);
|
39 |
-
}
|
40 |
-
|
41 |
-
public function observersProvider()
|
42 |
-
{
|
43 |
-
return array();
|
44 |
-
}
|
45 |
-
|
46 |
-
public function definedLayoutFilesProvider()
|
47 |
-
{
|
48 |
-
return array();
|
49 |
-
}
|
50 |
-
|
51 |
-
public function themeLayoutFilesExistProvider()
|
52 |
-
{
|
53 |
-
return array();
|
54 |
-
}
|
55 |
-
|
56 |
-
public function dependsProvider()
|
57 |
-
{
|
58 |
-
return array();
|
59 |
-
}
|
60 |
-
|
61 |
-
/**
|
62 |
-
* @test
|
63 |
-
* @group amd
|
64 |
-
* @group config
|
65 |
-
*/
|
66 |
-
public function assertPermissionCheckerModuleVersionGreaterThanOrEquals()
|
67 |
-
{
|
68 |
-
$this->assertModuleVersionGreaterThanOrEquals('0.1.0');
|
69 |
-
}
|
70 |
-
|
71 |
-
/**
|
72 |
-
* @test
|
73 |
-
* @group amd
|
74 |
-
* @group config
|
75 |
-
*/
|
76 |
-
public function assertPermissionCheckerModuleInCommunityCodePool()
|
77 |
-
{
|
78 |
-
$this->assertModuleCodePool('community');
|
79 |
-
}
|
80 |
-
|
81 |
-
/**
|
82 |
-
* test
|
83 |
-
* @group amd
|
84 |
-
* @group config
|
85 |
-
* @dataProvider dependsProvider
|
86 |
-
*/
|
87 |
-
public function assertPermissionCheckerModuleDepends(
|
88 |
-
$requiredModuleName
|
89 |
-
) {
|
90 |
-
$this->assertModuleDepends($requiredModuleName);
|
91 |
-
}
|
92 |
-
|
93 |
-
/**
|
94 |
-
* @test
|
95 |
-
* @group amd
|
96 |
-
* @group config
|
97 |
-
* @dataProvider modelsProvider
|
98 |
-
*/
|
99 |
-
public function assertPermissionCheckerModelAliases(
|
100 |
-
$classAlias,
|
101 |
-
$expectedClassName
|
102 |
-
) {
|
103 |
-
$this->assertModelAlias($classAlias, $expectedClassName);
|
104 |
-
}
|
105 |
-
|
106 |
-
/**
|
107 |
-
* test
|
108 |
-
* @group amd
|
109 |
-
* @group config
|
110 |
-
* @dataProvider resourceModelProvider
|
111 |
-
*/
|
112 |
-
public function assertPermissionCheckerResourceModelAliases(
|
113 |
-
$classAlias,
|
114 |
-
$expectedClassName
|
115 |
-
) {
|
116 |
-
$this->assertResourceModelAlias($classAlias, $expectedClassName);
|
117 |
-
}
|
118 |
-
|
119 |
-
/**
|
120 |
-
* @test
|
121 |
-
* @group amd
|
122 |
-
* @group config
|
123 |
-
* @dataProvider blocksProvider
|
124 |
-
*/
|
125 |
-
public function assertPermissionCheckerBlockAliases(
|
126 |
-
$classAlias,
|
127 |
-
$expectedClassName
|
128 |
-
) {
|
129 |
-
$this->assertBlockAlias($classAlias, $expectedClassName);
|
130 |
-
}
|
131 |
-
|
132 |
-
/**
|
133 |
-
* @test
|
134 |
-
* @group amd
|
135 |
-
* @group config
|
136 |
-
* @dataProvider helpersProvider
|
137 |
-
*/
|
138 |
-
public function assertPermissionCheckerHelperAliases(
|
139 |
-
$classAlias,
|
140 |
-
$expectedClassName
|
141 |
-
) {
|
142 |
-
$this->assertHelperAlias($classAlias, $expectedClassName);
|
143 |
-
}
|
144 |
-
|
145 |
-
/**
|
146 |
-
* test
|
147 |
-
* @group amd
|
148 |
-
* @group config
|
149 |
-
* @dataProvider observersProvider
|
150 |
-
*/
|
151 |
-
function assertPermissionCheckerEventObserverDefined (
|
152 |
-
$area,
|
153 |
-
$eventName,
|
154 |
-
$observerClassAlias,
|
155 |
-
$observerMethod
|
156 |
-
) {
|
157 |
-
$this->assertEventObserverDefined(
|
158 |
-
$area,
|
159 |
-
$eventName,
|
160 |
-
$observerClassAlias,
|
161 |
-
$observerMethod
|
162 |
-
);
|
163 |
-
}
|
164 |
-
|
165 |
-
/**
|
166 |
-
* test
|
167 |
-
* @group amd
|
168 |
-
* @group config
|
169 |
-
* @dataProvider definedLayoutFilesProvider
|
170 |
-
*/
|
171 |
-
public function assertPermissionCheckerLayoutFileDefined (
|
172 |
-
$area,
|
173 |
-
$expectedFileName
|
174 |
-
) {
|
175 |
-
$this->assertLayoutFileDefined($area, $expectedFileName);
|
176 |
-
}
|
177 |
-
|
178 |
-
/**
|
179 |
-
* test
|
180 |
-
* @group amd
|
181 |
-
* @group config
|
182 |
-
* @dataProvider themeLayoutFilesExistProvider
|
183 |
-
*/
|
184 |
-
public function assertPermissionCheckerLayoutFileExistsInTheme (
|
185 |
-
$area,
|
186 |
-
$filename,
|
187 |
-
$theme,
|
188 |
-
$designPackage
|
189 |
-
) {
|
190 |
-
$this->assertLayoutFileExistsInTheme(
|
191 |
-
$area,
|
192 |
-
$filename,
|
193 |
-
$theme,
|
194 |
-
$designPackage
|
195 |
-
);
|
196 |
-
}
|
197 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/PermissionChecker/etc/adminhtml.xml
DELETED
@@ -1,32 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* @category Bronto
|
5 |
-
* @package PermissionChecker
|
6 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
7 |
-
* @copyright 2012 Atlantic BT
|
8 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
9 |
-
*/
|
10 |
-
-->
|
11 |
-
<config>
|
12 |
-
<acl>
|
13 |
-
<resources>
|
14 |
-
<admin>
|
15 |
-
<children>
|
16 |
-
<system>
|
17 |
-
<children>
|
18 |
-
<config>
|
19 |
-
<children>
|
20 |
-
<permission_checker translate="title" module="bronto_permissionchecker">
|
21 |
-
<title>Permission Checker</title>
|
22 |
-
<sort_order>10</sort_order>
|
23 |
-
</permission_checker>
|
24 |
-
</children>
|
25 |
-
</config>
|
26 |
-
</children>
|
27 |
-
</system>
|
28 |
-
</children>
|
29 |
-
</admin>
|
30 |
-
</resources>
|
31 |
-
</acl>
|
32 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/PermissionChecker/etc/config.xml
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<!--
|
3 |
-
/**
|
4 |
-
* @category Bronto
|
5 |
-
* @package PermissionChecker
|
6 |
-
* @author Jamie Kahgee <jamie.kahgee@atlanticbt.com>
|
7 |
-
* @copyright 2012 Atlantic BT
|
8 |
-
* @license http://www.atlanticbt.com/ Atlantic BT
|
9 |
-
*/
|
10 |
-
-->
|
11 |
-
<config>
|
12 |
-
<modules>
|
13 |
-
<Bronto_PermissionChecker>
|
14 |
-
<version>0.1.0</version>
|
15 |
-
</Bronto_PermissionChecker>
|
16 |
-
</modules>
|
17 |
-
|
18 |
-
<global>
|
19 |
-
<blocks>
|
20 |
-
<bronto_permissionchecker>
|
21 |
-
<class>Bronto_PermissionChecker_Block</class>
|
22 |
-
</bronto_permissionchecker>
|
23 |
-
</blocks>
|
24 |
-
|
25 |
-
<helpers>
|
26 |
-
<bronto_permissionchecker>
|
27 |
-
<class>Bronto_PermissionChecker_Helper</class>
|
28 |
-
</bronto_permissionchecker>
|
29 |
-
</helpers>
|
30 |
-
|
31 |
-
<models>
|
32 |
-
<bronto_permissionchecker>
|
33 |
-
<class>Bronto_PermissionChecker_Model</class>
|
34 |
-
</bronto_permissionchecker>
|
35 |
-
</models>
|
36 |
-
</global>
|
37 |
-
<admin>
|
38 |
-
<routers>
|
39 |
-
<adminhtml>
|
40 |
-
<args>
|
41 |
-
<modules>
|
42 |
-
<bronto_permissionchecker before="Mage_Adminhtml">Bronto_PermissionChecker_Adminhtml</bronto_permissionchecker>
|
43 |
-
</modules>
|
44 |
-
</args>
|
45 |
-
</adminhtml>
|
46 |
-
</routers>
|
47 |
-
</admin>
|
48 |
-
<phpunit>
|
49 |
-
<suite>
|
50 |
-
<modules>
|
51 |
-
<Bronto_PermissionChecker />
|
52 |
-
</modules>
|
53 |
-
</suite>
|
54 |
-
</phpunit>
|
55 |
-
<default>
|
56 |
-
<permission_checker>
|
57 |
-
<settings>
|
58 |
-
<directories>755</directories>
|
59 |
-
<files>644</files>
|
60 |
-
<exclude>media, var, errors, build, .git, .svn, shell, pkginfo, includes</exclude>
|
61 |
-
</settings>
|
62 |
-
</permission_checker>
|
63 |
-
</default>
|
64 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/PermissionChecker/etc/system.xml
DELETED
@@ -1,79 +0,0 @@
|
|
1 |
-
<?xml version="1.0"?>
|
2 |
-
<config>
|
3 |
-
<sections>
|
4 |
-
<permission_checker translate="label" module="core">
|
5 |
-
<label>Permission Checker</label>
|
6 |
-
<tab>bronto</tab>
|
7 |
-
<sort_order>800</sort_order>
|
8 |
-
<show_in_default>1</show_in_default>
|
9 |
-
<show_in_website>1</show_in_website>
|
10 |
-
<show_in_store>1</show_in_store>
|
11 |
-
<groups>
|
12 |
-
<settings translate="label">
|
13 |
-
<label>Settings</label>
|
14 |
-
<frontend_type>text</frontend_type>
|
15 |
-
<sort_order>1</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 |
-
<expanded>1</expanded>
|
20 |
-
<fields>
|
21 |
-
<owner translate="label comment">
|
22 |
-
<label>Owner</label>
|
23 |
-
<comment>Owner to check for, (can be name or uid)</comment>
|
24 |
-
<frontend_type>text</frontend_type>
|
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 |
-
</owner>
|
30 |
-
<group translate="label comment">
|
31 |
-
<label>Group</label>
|
32 |
-
<comment>Group to check for, (can be name or gid)</comment>
|
33 |
-
<frontend_type>text</frontend_type>
|
34 |
-
<sort_order>2</sort_order>
|
35 |
-
<show_in_default>1</show_in_default>
|
36 |
-
<show_in_website>1</show_in_website>
|
37 |
-
<show_in_store>1</show_in_store>
|
38 |
-
</group>
|
39 |
-
<directories translate="label comment">
|
40 |
-
<label>Directories</label>
|
41 |
-
<comment>Directory permission to check, standard is 755</comment>
|
42 |
-
<frontend_type>text</frontend_type>
|
43 |
-
<sort_order>3</sort_order>
|
44 |
-
<show_in_default>1</show_in_default>
|
45 |
-
<show_in_website>1</show_in_website>
|
46 |
-
<show_in_store>1</show_in_store>
|
47 |
-
</directories>
|
48 |
-
<files translate="label comment">
|
49 |
-
<label>Files</label>
|
50 |
-
<comment>File permission to check, standard is 644</comment>
|
51 |
-
<frontend_type>text</frontend_type>
|
52 |
-
<sort_order>4</sort_order>
|
53 |
-
<show_in_default>1</show_in_default>
|
54 |
-
<show_in_website>1</show_in_website>
|
55 |
-
<show_in_store>1</show_in_store>
|
56 |
-
</files>
|
57 |
-
<exclude translate="label comment">
|
58 |
-
<label>Exclude Patterns</label>
|
59 |
-
<comment>Nodes to exclude</comment>
|
60 |
-
<frontend_type>text</frontend_type>
|
61 |
-
<sort_order>5</sort_order>
|
62 |
-
<show_in_default>1</show_in_default>
|
63 |
-
<show_in_website>1</show_in_website>
|
64 |
-
<show_in_store>1</show_in_store>
|
65 |
-
</exclude>
|
66 |
-
</fields>
|
67 |
-
</settings>
|
68 |
-
<permissionchecker>
|
69 |
-
<frontend_type>text</frontend_type>
|
70 |
-
<frontend_model>bronto_permissionchecker/adminhtml_system_config_permissionchecker</frontend_model>
|
71 |
-
<sort_order>2</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 |
-
</permissionchecker>
|
76 |
-
</groups>
|
77 |
-
</permission_checker>
|
78 |
-
</sections>
|
79 |
-
</config>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder.php
CHANGED
@@ -22,5 +22,15 @@ class Bronto_Reminder_Block_Adminhtml_Reminder extends Mage_Adminhtml_Block_Widg
|
|
22 |
$this->_headerText = Mage::helper('bronto_reminder')->__('Bronto Reminder Email Rules');
|
23 |
$this->_addButtonLabel = Mage::helper('bronto_reminder')->__('Add New Rule');
|
24 |
parent::__construct();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
25 |
}
|
26 |
}
|
22 |
$this->_headerText = Mage::helper('bronto_reminder')->__('Bronto Reminder Email Rules');
|
23 |
$this->_addButtonLabel = Mage::helper('bronto_reminder')->__('Add New Rule');
|
24 |
parent::__construct();
|
25 |
+
$this->setTemplate('bronto/reminder/grid/container.phtml');
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Get link to transactional email configuration
|
30 |
+
* @return type
|
31 |
+
*/
|
32 |
+
public function getConfigLink()
|
33 |
+
{
|
34 |
+
return Mage::helper($this->_blockGroup)->getConfigLink();
|
35 |
}
|
36 |
}
|
app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit.php
CHANGED
@@ -10,7 +10,7 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit extends Mage_Adminhtml_Block
|
|
10 |
/**
|
11 |
* @var string
|
12 |
*/
|
13 |
-
protected $_objectId
|
14 |
|
15 |
/**
|
16 |
* @var string
|
@@ -27,6 +27,7 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit extends Mage_Adminhtml_Block
|
|
27 |
parent::__construct();
|
28 |
$rule = Mage::registry('current_reminder_rule');
|
29 |
$this->removeButton('reset');
|
|
|
30 |
|
31 |
if ($rule) {
|
32 |
$this->_updateButton('save', 'label', Mage::helper('bronto_reminder')->__('Save'));
|
@@ -35,7 +36,7 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit extends Mage_Adminhtml_Block
|
|
35 |
if ($rule->getId()) {
|
36 |
$confirm = Mage::helper('bronto_reminder')->__('Are you sure you want to match this rule now?');
|
37 |
$this->_addButton('match_now', array(
|
38 |
-
'label'
|
39 |
'onclick' => "confirmSetLocation('{$confirm}', '{$this->getMatchUrl()}')"
|
40 |
), -1);
|
41 |
if ($limit = Mage::helper('bronto_reminder')->getOneRunLimit()) {
|
@@ -43,10 +44,10 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit extends Mage_Adminhtml_Block
|
|
43 |
}
|
44 |
|
45 |
$sendButtonSettings = array(
|
46 |
-
'label'
|
47 |
);
|
48 |
|
49 |
-
if (!Mage::helper('bronto_reminder')->
|
50 |
$sendButtonSettings['disabled'] = 'disabled';
|
51 |
} else {
|
52 |
$sendButtonSettings['onclick'] = "confirmSetLocation('{$confirm}', '{$this->getRunUrl()}')";
|
@@ -56,8 +57,8 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit extends Mage_Adminhtml_Block
|
|
56 |
}
|
57 |
|
58 |
$this->_addButton('save_and_continue_edit', array(
|
59 |
-
'class'
|
60 |
-
'label'
|
61 |
'onclick' => 'editForm.submit($(\'edit_form\').action + \'back/edit/\')',
|
62 |
), 3);
|
63 |
}
|
@@ -68,8 +69,7 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit extends Mage_Adminhtml_Block
|
|
68 |
$rule = Mage::registry('current_reminder_rule');
|
69 |
if ($rule->getRuleId()) {
|
70 |
return Mage::helper('bronto_reminder')->__("Edit Rule '%s'", $this->htmlEscape($rule->getName()));
|
71 |
-
}
|
72 |
-
else {
|
73 |
return Mage::helper('bronto_reminder')->__('New Rule');
|
74 |
}
|
75 |
}
|
10 |
/**
|
11 |
* @var string
|
12 |
*/
|
13 |
+
protected $_objectId = 'id';
|
14 |
|
15 |
/**
|
16 |
* @var string
|
27 |
parent::__construct();
|
28 |
$rule = Mage::registry('current_reminder_rule');
|
29 |
$this->removeButton('reset');
|
30 |
+
$this->setValidationUrl($this->getUrl('*/*/validate'));
|
31 |
|
32 |
if ($rule) {
|
33 |
$this->_updateButton('save', 'label', Mage::helper('bronto_reminder')->__('Save'));
|
36 |
if ($rule->getId()) {
|
37 |
$confirm = Mage::helper('bronto_reminder')->__('Are you sure you want to match this rule now?');
|
38 |
$this->_addButton('match_now', array(
|
39 |
+
'label' => Mage::helper('bronto_reminder')->__('Match Now'),
|
40 |
'onclick' => "confirmSetLocation('{$confirm}', '{$this->getMatchUrl()}')"
|
41 |
), -1);
|
42 |
if ($limit = Mage::helper('bronto_reminder')->getOneRunLimit()) {
|
44 |
}
|
45 |
|
46 |
$sendButtonSettings = array(
|
47 |
+
'label' => Mage::helper('bronto_reminder')->__('Send Now')
|
48 |
);
|
49 |
|
50 |
+
if (!Mage::helper('bronto_reminder')->isAllowSendForAny()) {
|
51 |
$sendButtonSettings['disabled'] = 'disabled';
|
52 |
} else {
|
53 |
$sendButtonSettings['onclick'] = "confirmSetLocation('{$confirm}', '{$this->getRunUrl()}')";
|
57 |
}
|
58 |
|
59 |
$this->_addButton('save_and_continue_edit', array(
|
60 |
+
'class' => 'save',
|
61 |
+
'label' => Mage::helper('bronto_reminder')->__('Save and Continue Edit'),
|
62 |
'onclick' => 'editForm.submit($(\'edit_form\').action + \'back/edit/\')',
|
63 |
), 3);
|
64 |
}
|
69 |
$rule = Mage::registry('current_reminder_rule');
|
70 |
if ($rule->getRuleId()) {
|
71 |
return Mage::helper('bronto_reminder')->__("Edit Rule '%s'", $this->htmlEscape($rule->getName()));
|
72 |
+
} else {
|
|
|
73 |
return Mage::helper('bronto_reminder')->__('New Rule');
|
74 |
}
|
75 |
}
|
app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tab/Bronto.php
CHANGED
@@ -14,43 +14,59 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_Bronto extends Mage_Admi
|
|
14 |
*/
|
15 |
protected function _prepareForm()
|
16 |
{
|
17 |
-
$form
|
18 |
$model = Mage::registry('current_reminder_rule');
|
19 |
|
20 |
$fieldset = $form->addFieldset('message_fieldset', array(
|
21 |
-
'legend'
|
22 |
'table_class' => 'form-list stores-tree',
|
23 |
-
'comment'
|
24 |
));
|
25 |
|
26 |
foreach (Mage::app()->getWebsites() as $website) {
|
|
|
|
|
|
|
|
|
|
|
27 |
$fieldset->addField("website_message_{$website->getId()}", 'note', array(
|
28 |
-
'label'
|
29 |
'fieldset_html_class' => 'website',
|
30 |
));
|
31 |
-
foreach ($website->getGroups() as $group) {
|
32 |
$stores = $group->getStores();
|
|
|
33 |
if (count($stores) == 0) {
|
34 |
continue;
|
35 |
}
|
36 |
$fieldset->addField("group_message_{$group->getId()}", 'note', array(
|
37 |
-
'label'
|
38 |
'fieldset_html_class' => 'store-group',
|
39 |
));
|
40 |
-
foreach ($stores as $store) {
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
|
|
|
|
53 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
54 |
}
|
55 |
}
|
56 |
|
14 |
*/
|
15 |
protected function _prepareForm()
|
16 |
{
|
17 |
+
$form = new Varien_Data_Form();
|
18 |
$model = Mage::registry('current_reminder_rule');
|
19 |
|
20 |
$fieldset = $form->addFieldset('message_fieldset', array(
|
21 |
+
'legend' => Mage::helper('bronto_reminder')->__('Bronto Messages'),
|
22 |
'table_class' => 'form-list stores-tree',
|
23 |
+
'comment' => Mage::helper('bronto_reminder')->__('Messages will be sent only for specified store views. Message store view matches the store view customer was registered on.'),
|
24 |
));
|
25 |
|
26 |
foreach (Mage::app()->getWebsites() as $website) {
|
27 |
+
$groups = $website->getGroups();
|
28 |
+
|
29 |
+
if (count($groups) == 0) {
|
30 |
+
continue;
|
31 |
+
}
|
32 |
$fieldset->addField("website_message_{$website->getId()}", 'note', array(
|
33 |
+
'label' => $website->getName(),
|
34 |
'fieldset_html_class' => 'website',
|
35 |
));
|
36 |
+
foreach ($website->getGroups() as $gkey => $group) {
|
37 |
$stores = $group->getStores();
|
38 |
+
|
39 |
if (count($stores) == 0) {
|
40 |
continue;
|
41 |
}
|
42 |
$fieldset->addField("group_message_{$group->getId()}", 'note', array(
|
43 |
+
'label' => $group->getName(),
|
44 |
'fieldset_html_class' => 'store-group',
|
45 |
));
|
46 |
+
foreach ($stores as $key => $store) {
|
47 |
+
if (Mage::helper('bronto_reminder')->isEnabled($store->getId())) {
|
48 |
+
$values = Mage::helper('bronto_reminder/message')->getMessagesOptionsArray($store->getId(), $website->getId());
|
49 |
+
|
50 |
+
$fieldset->addField("store_message_{$store->getId()}", 'select', array(
|
51 |
+
'name' => "store_messages[{$store->getId()}]",
|
52 |
+
'required' => false,
|
53 |
+
'label' => $store->getName(),
|
54 |
+
'values' => $values,
|
55 |
+
'fieldset_html_class' => 'store',
|
56 |
+
'disabled' => count($values) == 1 ? true : false,
|
57 |
+
));
|
58 |
+
} else {
|
59 |
+
unset($stores[$key]);
|
60 |
+
}
|
61 |
}
|
62 |
+
if (count($stores) == 0) {
|
63 |
+
unset($groups[$gkey]);
|
64 |
+
$fieldset->removeField("group_message_{$group->getId()}");
|
65 |
+
}
|
66 |
+
}
|
67 |
+
|
68 |
+
if (count($groups) == 0) {
|
69 |
+
$fieldset->removeField("website_message_{$website->getId()}");
|
70 |
}
|
71 |
}
|
72 |
|
app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tab/Conditions.php
CHANGED
@@ -16,7 +16,7 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_Conditions extends Mage_
|
|
16 |
->setTemplate('promo/fieldset.phtml')
|
17 |
->setNewChildUrl($this->getUrl('*/*/newConditionHtml/form/rule_conditions_fieldset'));
|
18 |
$fieldset = $form->addFieldset('rule_conditions_fieldset', array(
|
19 |
-
'legend'
|
20 |
'comment' => Mage::helper('bronto_reminder')->__('Rule will work only if at least one condition is specified.'),
|
21 |
))->setRenderer($renderer);
|
22 |
|
16 |
->setTemplate('promo/fieldset.phtml')
|
17 |
->setNewChildUrl($this->getUrl('*/*/newConditionHtml/form/rule_conditions_fieldset'));
|
18 |
$fieldset = $form->addFieldset('rule_conditions_fieldset', array(
|
19 |
+
'legend' => Mage::helper('bronto_reminder')->__('Conditions'),
|
20 |
'comment' => Mage::helper('bronto_reminder')->__('Rule will work only if at least one condition is specified.'),
|
21 |
))->setRenderer($renderer);
|
22 |
|
app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tab/Customers.php
CHANGED
@@ -16,7 +16,7 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_Customers extends Mage_A
|
|
16 |
$this->setId('customerGrid');
|
17 |
$this->setUseAjax(true);
|
18 |
$this->setDefaultSort('email');
|
19 |
-
$this->setDefaultDir('ASC');
|
20 |
$this->setDefaultFilter(array('grid_is_active' => 1));
|
21 |
}
|
22 |
|
@@ -42,36 +42,36 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_Customers extends Mage_A
|
|
42 |
protected function _prepareColumns()
|
43 |
{
|
44 |
$this->addColumn('grid_entity_id', array(
|
45 |
-
'header'
|
46 |
-
'align'
|
47 |
-
'width'
|
48 |
-
'index'
|
49 |
'renderer' => 'bronto_reminder/adminhtml_widget_grid_column_renderer_id'
|
50 |
));
|
51 |
|
52 |
$this->addColumn('grid_email', array(
|
53 |
-
'header'
|
54 |
-
'type'
|
55 |
-
'align'
|
56 |
-
'index'
|
57 |
'renderer' => 'bronto_reminder/adminhtml_widget_grid_column_renderer_email'
|
58 |
));
|
59 |
|
60 |
$this->addColumn('grid_associated_at', array(
|
61 |
-
'header'
|
62 |
-
'align'
|
63 |
-
'width'
|
64 |
-
'type'
|
65 |
-
'default'
|
66 |
-
'index'
|
67 |
));
|
68 |
|
69 |
$this->addColumn('grid_is_active', array(
|
70 |
-
'header'
|
71 |
-
'align'
|
72 |
-
'type'
|
73 |
-
'index'
|
74 |
-
'options'
|
75 |
'0' => Mage::helper('bronto_reminder')->__('No'),
|
76 |
'1' => Mage::helper('bronto_reminder')->__('Yes')
|
77 |
)
|
@@ -80,48 +80,48 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_Customers extends Mage_A
|
|
80 |
if (class_exists('Mage_SalesRule_Model_Coupon', false)) {
|
81 |
|
82 |
$this->addColumn('grid_code', array(
|
83 |
-
'header'
|
84 |
-
'align'
|
85 |
-
'default'
|
86 |
-
'index'
|
87 |
));
|
88 |
|
89 |
$this->addColumn('grid_usage_limit', array(
|
90 |
-
'header'
|
91 |
-
'align'
|
92 |
-
'default'
|
93 |
-
'index'
|
94 |
));
|
95 |
|
96 |
$this->addColumn('grid_usage_per_customer', array(
|
97 |
-
'header'
|
98 |
-
'align'
|
99 |
-
'default'
|
100 |
-
'index'
|
101 |
));
|
102 |
|
103 |
}
|
104 |
|
105 |
$this->addColumn('grid_emails_sent', array(
|
106 |
-
'header'
|
107 |
-
'align'
|
108 |
-
'default'
|
109 |
-
'index'
|
110 |
));
|
111 |
|
112 |
$this->addColumn('grid_emails_failed', array(
|
113 |
-
'header'
|
114 |
-
'align'
|
115 |
-
'index'
|
116 |
));
|
117 |
|
118 |
$this->addColumn('grid_last_sent', array(
|
119 |
-
'header'
|
120 |
-
'align'
|
121 |
-
'width'
|
122 |
-
'type'
|
123 |
-
'default'
|
124 |
-
'index'
|
125 |
));
|
126 |
|
127 |
return parent::_prepareColumns();
|
16 |
$this->setId('customerGrid');
|
17 |
$this->setUseAjax(true);
|
18 |
$this->setDefaultSort('email');
|
19 |
+
$this->setDefaultDir('ASC');
|
20 |
$this->setDefaultFilter(array('grid_is_active' => 1));
|
21 |
}
|
22 |
|
42 |
protected function _prepareColumns()
|
43 |
{
|
44 |
$this->addColumn('grid_entity_id', array(
|
45 |
+
'header' => Mage::helper('bronto_reminder')->__('ID'),
|
46 |
+
'align' => 'center',
|
47 |
+
'width' => 50,
|
48 |
+
'index' => 'entity_id',
|
49 |
'renderer' => 'bronto_reminder/adminhtml_widget_grid_column_renderer_id'
|
50 |
));
|
51 |
|
52 |
$this->addColumn('grid_email', array(
|
53 |
+
'header' => Mage::helper('bronto_reminder')->__('Email'),
|
54 |
+
'type' => 'text',
|
55 |
+
'align' => 'left',
|
56 |
+
'index' => 'email',
|
57 |
'renderer' => 'bronto_reminder/adminhtml_widget_grid_column_renderer_email'
|
58 |
));
|
59 |
|
60 |
$this->addColumn('grid_associated_at', array(
|
61 |
+
'header' => Mage::helper('bronto_reminder')->__('Matched At'),
|
62 |
+
'align' => 'left',
|
63 |
+
'width' => 150,
|
64 |
+
'type' => 'datetime',
|
65 |
+
'default' => '--',
|
66 |
+
'index' => 'associated_at'
|
67 |
));
|
68 |
|
69 |
$this->addColumn('grid_is_active', array(
|
70 |
+
'header' => Mage::helper('bronto_reminder')->__('Thread Active'),
|
71 |
+
'align' => 'left',
|
72 |
+
'type' => 'options',
|
73 |
+
'index' => 'is_active',
|
74 |
+
'options' => array(
|
75 |
'0' => Mage::helper('bronto_reminder')->__('No'),
|
76 |
'1' => Mage::helper('bronto_reminder')->__('Yes')
|
77 |
)
|
80 |
if (class_exists('Mage_SalesRule_Model_Coupon', false)) {
|
81 |
|
82 |
$this->addColumn('grid_code', array(
|
83 |
+
'header' => Mage::helper('bronto_reminder')->__('Coupon'),
|
84 |
+
'align' => 'left',
|
85 |
+
'default' => Mage::helper('bronto_reminder')->__('N/A'),
|
86 |
+
'index' => 'code'
|
87 |
));
|
88 |
|
89 |
$this->addColumn('grid_usage_limit', array(
|
90 |
+
'header' => Mage::helper('bronto_reminder')->__('Coupon Usage Limit'),
|
91 |
+
'align' => 'left',
|
92 |
+
'default' => '0',
|
93 |
+
'index' => 'usage_limit'
|
94 |
));
|
95 |
|
96 |
$this->addColumn('grid_usage_per_customer', array(
|
97 |
+
'header' => Mage::helper('bronto_reminder')->__('Coupon Usage per Customer'),
|
98 |
+
'align' => 'left',
|
99 |
+
'default' => '0',
|
100 |
+
'index' => 'usage_per_customer'
|
101 |
));
|
102 |
|
103 |
}
|
104 |
|
105 |
$this->addColumn('grid_emails_sent', array(
|
106 |
+
'header' => Mage::helper('bronto_reminder')->__('Emails Sent'),
|
107 |
+
'align' => 'left',
|
108 |
+
'default' => '0',
|
109 |
+
'index' => 'emails_sent'
|
110 |
));
|
111 |
|
112 |
$this->addColumn('grid_emails_failed', array(
|
113 |
+
'header' => Mage::helper('bronto_reminder')->__('Emails Failed'),
|
114 |
+
'align' => 'left',
|
115 |
+
'index' => 'emails_failed'
|
116 |
));
|
117 |
|
118 |
$this->addColumn('grid_last_sent', array(
|
119 |
+
'header' => Mage::helper('bronto_reminder')->__('Last Sent At'),
|
120 |
+
'align' => 'left',
|
121 |
+
'width' => 150,
|
122 |
+
'type' => 'datetime',
|
123 |
+
'default' => '--',
|
124 |
+
'index' => 'last_sent'
|
125 |
));
|
126 |
|
127 |
return parent::_prepareColumns();
|
app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tab/General.php
CHANGED
@@ -13,7 +13,7 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_General extends Mage_Adm
|
|
13 |
$model = Mage::registry('current_reminder_rule');
|
14 |
|
15 |
$fieldset = $form->addFieldset('base_fieldset', array(
|
16 |
-
'legend'
|
17 |
'comment' => Mage::helper('bronto_reminder')->__('Reminder emails may promote a shopping cart price rule with or without coupon. If a shopping cart price rule defines an auto-generated coupon, this reminder rule will generate a random coupon code for each customer.'),
|
18 |
));
|
19 |
|
@@ -24,13 +24,13 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_General extends Mage_Adm
|
|
24 |
}
|
25 |
|
26 |
$fieldset->addField('name', 'text', array(
|
27 |
-
'name'
|
28 |
-
'label'
|
29 |
'required' => true,
|
30 |
));
|
31 |
|
32 |
$fieldset->addField('description', 'textarea', array(
|
33 |
-
'name'
|
34 |
'label' => Mage::helper('bronto_reminder')->__('Description'),
|
35 |
'style' => 'width: 98%; height: 100px;',
|
36 |
));
|
@@ -38,11 +38,11 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_General extends Mage_Adm
|
|
38 |
if (class_exists('Mage_Adminhtml_Block_Promo_Widget_Chooser', false)) {
|
39 |
|
40 |
$field = $fieldset->addField('salesrule_id', 'note', array(
|
41 |
-
'name'
|
42 |
'label' => Mage::helper('bronto_reminder')->__('Shopping Cart Price Rule'),
|
43 |
'class' => 'widget-option',
|
44 |
'value' => $model->getSalesruleId(),
|
45 |
-
'note'
|
46 |
));
|
47 |
|
48 |
$model->unsSalesruleId();
|
@@ -58,20 +58,20 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_General extends Mage_Adm
|
|
58 |
}
|
59 |
|
60 |
if (!Mage::app()->isSingleStoreMode()) {
|
61 |
-
$fieldset->addField('website_ids','multiselect',array(
|
62 |
-
'name'
|
63 |
'required' => true,
|
64 |
-
'label'
|
65 |
-
'values'
|
66 |
-
'value'
|
67 |
));
|
68 |
}
|
69 |
|
70 |
$fieldset->addField('is_active', 'select', array(
|
71 |
-
'label'
|
72 |
-
'name'
|
73 |
'required' => true,
|
74 |
-
'options'
|
75 |
'1' => Mage::helper('bronto_reminder')->__('Active'),
|
76 |
'0' => Mage::helper('bronto_reminder')->__('Inactive'),
|
77 |
),
|
@@ -84,21 +84,21 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_General extends Mage_Adm
|
|
84 |
$dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
|
85 |
|
86 |
$fieldset->addField('active_from', 'date', array(
|
87 |
-
'name'
|
88 |
-
'label'
|
89 |
-
'title'
|
90 |
-
'image'
|
91 |
'input_format' => Varien_Date::DATE_INTERNAL_FORMAT,
|
92 |
-
'format'
|
93 |
));
|
94 |
|
95 |
$fieldset->addField('active_to', 'date', array(
|
96 |
-
'name'
|
97 |
-
'label'
|
98 |
-
'title'
|
99 |
-
'image'
|
100 |
'input_format' => Varien_Date::DATE_INTERNAL_FORMAT,
|
101 |
-
'format'
|
102 |
));
|
103 |
|
104 |
// $subfieldset = $form->addFieldset('sub_fieldset', array(
|
@@ -129,7 +129,7 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tab_General extends Mage_Adm
|
|
129 |
public function getChooserConfig()
|
130 |
{
|
131 |
return array(
|
132 |
-
'button' => array('open'=>'Select Rule...'),
|
133 |
'type' => 'adminhtml/promo_widget_chooser_rule'
|
134 |
);
|
135 |
}
|
13 |
$model = Mage::registry('current_reminder_rule');
|
14 |
|
15 |
$fieldset = $form->addFieldset('base_fieldset', array(
|
16 |
+
'legend' => Mage::helper('bronto_reminder')->__('General'),
|
17 |
'comment' => Mage::helper('bronto_reminder')->__('Reminder emails may promote a shopping cart price rule with or without coupon. If a shopping cart price rule defines an auto-generated coupon, this reminder rule will generate a random coupon code for each customer.'),
|
18 |
));
|
19 |
|
24 |
}
|
25 |
|
26 |
$fieldset->addField('name', 'text', array(
|
27 |
+
'name' => 'name',
|
28 |
+
'label' => Mage::helper('bronto_reminder')->__('Rule Name'),
|
29 |
'required' => true,
|
30 |
));
|
31 |
|
32 |
$fieldset->addField('description', 'textarea', array(
|
33 |
+
'name' => 'description',
|
34 |
'label' => Mage::helper('bronto_reminder')->__('Description'),
|
35 |
'style' => 'width: 98%; height: 100px;',
|
36 |
));
|
38 |
if (class_exists('Mage_Adminhtml_Block_Promo_Widget_Chooser', false)) {
|
39 |
|
40 |
$field = $fieldset->addField('salesrule_id', 'note', array(
|
41 |
+
'name' => 'salesrule_id',
|
42 |
'label' => Mage::helper('bronto_reminder')->__('Shopping Cart Price Rule'),
|
43 |
'class' => 'widget-option',
|
44 |
'value' => $model->getSalesruleId(),
|
45 |
+
'note' => Mage::helper('bronto_reminder')->__('Promotion rule this reminder will advertise.'),
|
46 |
));
|
47 |
|
48 |
$model->unsSalesruleId();
|
58 |
}
|
59 |
|
60 |
if (!Mage::app()->isSingleStoreMode()) {
|
61 |
+
$fieldset->addField('website_ids', 'multiselect', array(
|
62 |
+
'name' => 'website_ids',
|
63 |
'required' => true,
|
64 |
+
'label' => Mage::helper('newsletter')->__('Assigned to Websites'),
|
65 |
+
'values' => Mage::getSingleton('adminhtml/system_store')->getWebsiteValuesForForm(),
|
66 |
+
'value' => $model->getWebsiteIds()
|
67 |
));
|
68 |
}
|
69 |
|
70 |
$fieldset->addField('is_active', 'select', array(
|
71 |
+
'label' => Mage::helper('bronto_reminder')->__('Status'),
|
72 |
+
'name' => 'is_active',
|
73 |
'required' => true,
|
74 |
+
'options' => array(
|
75 |
'1' => Mage::helper('bronto_reminder')->__('Active'),
|
76 |
'0' => Mage::helper('bronto_reminder')->__('Inactive'),
|
77 |
),
|
84 |
$dateFormatIso = Mage::app()->getLocale()->getDateFormat(Mage_Core_Model_Locale::FORMAT_TYPE_SHORT);
|
85 |
|
86 |
$fieldset->addField('active_from', 'date', array(
|
87 |
+
'name' => 'active_from',
|
88 |
+
'label' => Mage::helper('bronto_reminder')->__('Active From'),
|
89 |
+
'title' => Mage::helper('bronto_reminder')->__('Active From'),
|
90 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif'),
|
91 |
'input_format' => Varien_Date::DATE_INTERNAL_FORMAT,
|
92 |
+
'format' => $dateFormatIso
|
93 |
));
|
94 |
|
95 |
$fieldset->addField('active_to', 'date', array(
|
96 |
+
'name' => 'active_to',
|
97 |
+
'label' => Mage::helper('bronto_reminder')->__('Active To'),
|
98 |
+
'title' => Mage::helper('bronto_reminder')->__('Active To'),
|
99 |
+
'image' => $this->getSkinUrl('images/grid-cal.gif'),
|
100 |
'input_format' => Varien_Date::DATE_INTERNAL_FORMAT,
|
101 |
+
'format' => $dateFormatIso
|
102 |
));
|
103 |
|
104 |
// $subfieldset = $form->addFieldset('sub_fieldset', array(
|
129 |
public function getChooserConfig()
|
130 |
{
|
131 |
return array(
|
132 |
+
'button' => array('open' => 'Select Rule...'),
|
133 |
'type' => 'adminhtml/promo_widget_chooser_rule'
|
134 |
);
|
135 |
}
|
app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Edit/Tabs.php
CHANGED
@@ -28,17 +28,17 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tabs extends Mage_Adminhtml_
|
|
28 |
protected function _beforeToHtml()
|
29 |
{
|
30 |
$this->addTab('general_section', array(
|
31 |
-
'label'
|
32 |
'content' => $this->getLayout()->createBlock('bronto_reminder/adminhtml_reminder_edit_tab_general')->toHtml(),
|
33 |
));
|
34 |
|
35 |
$this->addTab('conditions_section', array(
|
36 |
-
'label'
|
37 |
'content' => $this->getLayout()->createBlock('bronto_reminder/adminhtml_reminder_edit_tab_conditions')->toHtml()
|
38 |
));
|
39 |
|
40 |
$this->addTab('bronto_section', array(
|
41 |
-
'label'
|
42 |
'content' => $this->getLayout()->createBlock('bronto_reminder/adminhtml_reminder_edit_tab_bronto')->toHtml()
|
43 |
));
|
44 |
|
@@ -46,7 +46,7 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Edit_Tabs extends Mage_Adminhtml_
|
|
46 |
if ($rule && $rule->getId()) {
|
47 |
$this->addTab('matched_customers', array(
|
48 |
'label' => Mage::helper('bronto_reminder')->__('Matched Customers'),
|
49 |
-
'url'
|
50 |
'class' => 'ajax'
|
51 |
));
|
52 |
}
|
28 |
protected function _beforeToHtml()
|
29 |
{
|
30 |
$this->addTab('general_section', array(
|
31 |
+
'label' => Mage::helper('bronto_reminder')->__('Rule Information'),
|
32 |
'content' => $this->getLayout()->createBlock('bronto_reminder/adminhtml_reminder_edit_tab_general')->toHtml(),
|
33 |
));
|
34 |
|
35 |
$this->addTab('conditions_section', array(
|
36 |
+
'label' => Mage::helper('bronto_reminder')->__('Conditions'),
|
37 |
'content' => $this->getLayout()->createBlock('bronto_reminder/adminhtml_reminder_edit_tab_conditions')->toHtml()
|
38 |
));
|
39 |
|
40 |
$this->addTab('bronto_section', array(
|
41 |
+
'label' => Mage::helper('bronto_reminder')->__('Bronto Settings'),
|
42 |
'content' => $this->getLayout()->createBlock('bronto_reminder/adminhtml_reminder_edit_tab_bronto')->toHtml()
|
43 |
));
|
44 |
|
46 |
if ($rule && $rule->getId()) {
|
47 |
$this->addTab('matched_customers', array(
|
48 |
'label' => Mage::helper('bronto_reminder')->__('Matched Customers'),
|
49 |
+
'url' => $this->getUrl('*/*/customerGrid', array('rule_id' => $rule->getId())),
|
50 |
'class' => 'ajax'
|
51 |
));
|
52 |
}
|
app/code/community/Bronto/Reminder/Block/Adminhtml/Reminder/Grid.php
CHANGED
@@ -27,43 +27,43 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Grid extends Mage_Adminhtml_Block
|
|
27 |
protected function _prepareColumns()
|
28 |
{
|
29 |
$this->addColumn('rule_id', array(
|
30 |
-
'header'
|
31 |
-
'align'
|
32 |
-
'width'
|
33 |
-
'index'
|
34 |
));
|
35 |
|
36 |
$this->addColumn('name', array(
|
37 |
-
'header'
|
38 |
-
'align'
|
39 |
-
'index'
|
40 |
));
|
41 |
|
42 |
$this->addColumn('from_date', array(
|
43 |
-
'header'
|
44 |
-
'align'
|
45 |
-
'width'
|
46 |
-
'type'
|
47 |
-
'default'
|
48 |
-
'index'
|
49 |
));
|
50 |
|
51 |
$this->addColumn('to_date', array(
|
52 |
-
'header'
|
53 |
-
'align'
|
54 |
-
'width'
|
55 |
-
'type'
|
56 |
-
'default'
|
57 |
-
'index'
|
58 |
));
|
59 |
|
60 |
$this->addColumn('is_active', array(
|
61 |
-
'header'
|
62 |
-
'align'
|
63 |
-
'width'
|
64 |
-
'index'
|
65 |
-
'type'
|
66 |
-
'options'
|
67 |
1 => 'Active',
|
68 |
0 => 'Inactive',
|
69 |
),
|
@@ -71,13 +71,13 @@ class Bronto_Reminder_Block_Adminhtml_Reminder_Grid extends Mage_Adminhtml_Block
|
|
71 |
|
72 |
if (!Mage::app()->isSingleStoreMode()) {
|
73 |
$this->addColumn('rule_website', array(
|
74 |
-
'header'
|
75 |
-
'align'
|
76 |
-
'index'
|
77 |
-
'type'
|
78 |
-
'sortable'
|
79 |
-
'options'
|
80 |
-
'width'
|
81 |
));
|
82 |
}
|
83 |
return parent::_prepareColumns();
|
27 |
protected function _prepareColumns()
|
28 |
{
|
29 |
$this->addColumn('rule_id', array(
|
30 |
+
'header' => Mage::helper('bronto_reminder')->__('ID'),
|
31 |
+
'align' => 'right',
|
32 |
+
'width' => '50px',
|
33 |
+
'index' => 'rule_id',
|
34 |
));
|
35 |
|
36 |
$this->addColumn('name', array(
|
37 |
+
'header' => Mage::helper('bronto_reminder')->__('Rule Name'),
|
38 |
+
'align' => 'left',
|
39 |
+
'index' => 'name',
|
40 |
));
|
41 |
|
42 |
$this->addColumn('from_date', array(
|
43 |
+
'header' => Mage::helper('bronto_reminder')->__('Active From'),
|
44 |
+
'align' => 'left',
|
45 |
+
'width' => '120px',
|
46 |
+
'type' => 'date',
|
47 |
+
'default' => '--',
|
48 |
+
'index' => 'active_from',
|
49 |
));
|
50 |
|
51 |
$this->addColumn('to_date', array(
|
52 |
+
'header' => Mage::helper('bronto_reminder')->__('Active To'),
|
53 |
+
'align' => 'left',
|
54 |
+
'width' => '120px',
|
55 |
+
'type' => 'date',
|
56 |
+
'default' => '--',
|
57 |
+
'index' => 'active_to',
|
58 |
));
|
59 |
|
60 |
$this->addColumn('is_active', array(
|
61 |
+
'header' => Mage::helper('bronto_reminder')->__('Status'),
|
62 |
+
'align' => 'left',
|
63 |
+
'width' => '80px',
|
64 |
+
'index' => 'is_active',
|
65 |
+
'type' => 'options',
|
66 |
+
'options' => array(
|
67 |
1 => 'Active',
|
68 |
0 => 'Inactive',
|
69 |
),
|
71 |
|
72 |
if (!Mage::app()->isSingleStoreMode()) {
|
73 |
$this->addColumn('rule_website', array(
|
74 |
+
'header' => Mage::helper('bronto_reminder')->__('Website'),
|
75 |
+
'align' => 'left',
|
76 |
+
'index' => 'website_ids',
|
77 |
+
'type' => 'options',
|
78 |
+
'sortable' => false,
|
79 |
+
'options' => Mage::getSingleton('adminhtml/system_store')->getWebsiteOptionHash(),
|
80 |
+
'width' => 200,
|
81 |
));
|
82 |
}
|
83 |
return parent::_prepareColumns();
|
app/code/community/Bronto/Reminder/Block/Adminhtml/System/Config/About.php
CHANGED
@@ -15,5 +15,5 @@ class Bronto_Reminder_Block_Adminhtml_System_Config_About extends Bronto_Common_
|
|
15 |
/**
|
16 |
* @var string
|
17 |
*/
|
18 |
-
protected $_name
|
19 |
}
|
15 |
/**
|
16 |
* @var string
|
17 |
*/
|
18 |
+
protected $_name = 'Bronto Reminder/Follow Up Email Module';
|
19 |
}
|
app/code/community/Bronto/Reminder/Block/Adminhtml/System/Config/Settings.php
CHANGED
@@ -5,7 +5,7 @@
|
|
5 |
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
* @version 1.5.0
|
7 |
*/
|
8 |
-
class Bronto_Reminder_Block_Adminhtml_System_Config_Settings
|
9 |
extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
10 |
{
|
11 |
/**
|
@@ -17,7 +17,7 @@ class Bronto_Reminder_Block_Adminhtml_System_Config_Settings
|
|
17 |
protected function _getHeaderCommentHtml($element)
|
18 |
{
|
19 |
$url = Mage::helper('adminhtml')->getUrl('/reminders');
|
20 |
-
$element->setComment("
|
21 |
return parent::_getHeaderCommentHtml($element);
|
22 |
}
|
23 |
}
|
5 |
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
* @version 1.5.0
|
7 |
*/
|
8 |
+
class Bronto_Reminder_Block_Adminhtml_System_Config_Settings
|
9 |
extends Mage_Adminhtml_Block_System_Config_Form_Fieldset
|
10 |
{
|
11 |
/**
|
17 |
protected function _getHeaderCommentHtml($element)
|
18 |
{
|
19 |
$url = Mage::helper('adminhtml')->getUrl('/reminders');
|
20 |
+
$element->setComment("Additional configuration located at: <strong>Promotions › <a href=\"{$url}\">Bronto Reminder Emails</a></strong><br/><br/>");
|
21 |
return parent::_getHeaderCommentHtml($element);
|
22 |
}
|
23 |
}
|
app/code/community/Bronto/Reminder/Helper/Data.php
CHANGED
@@ -7,14 +7,14 @@
|
|
7 |
*/
|
8 |
class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements Bronto_Common_Helper_DataInterface
|
9 |
{
|
10 |
-
const XML_PATH_ENABLED
|
11 |
-
const XML_PATH_ALLOW_SEND
|
12 |
-
const XML_PATH_TIME
|
13 |
-
const XML_PATH_INTERVAL
|
14 |
-
const XML_PATH_FREQUENCY
|
15 |
-
const XML_PATH_FREQUENCY_MIN
|
16 |
-
const XML_PATH_SEND_LIMIT
|
17 |
-
const XML_PATH_EMAIL_IDENTITY
|
18 |
const XML_PATH_EMAIL_THRESHOLD = 'bronto_reminder/settings/threshold';
|
19 |
|
20 |
/**
|
@@ -27,33 +27,117 @@ class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements B
|
|
27 |
return 'Bronto_Reminder';
|
28 |
}
|
29 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
/**
|
31 |
* @return bool
|
32 |
*/
|
33 |
-
public function isEnabled()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
34 |
{
|
35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
}
|
37 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
/**
|
39 |
* @param null|string|bool|int|Mage_Core_Model_Store $store
|
40 |
* @return bool
|
41 |
*/
|
42 |
public function isAllowSend($store = null)
|
43 |
{
|
44 |
-
return (bool)
|
45 |
}
|
46 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
47 |
/**
|
48 |
* Text to display when reminder module not allowed to send emails
|
49 |
* @return type
|
50 |
*/
|
51 |
public function getNotAllowedText()
|
52 |
{
|
53 |
-
$url =
|
54 |
$messageText = $this->__('Rules are currently unable to send emails.
|
55 |
You can enable this function in the System Configuration <a href="' . $url . '">Reminder Emails</a>');
|
56 |
-
|
57 |
return $messageText;
|
58 |
}
|
59 |
|
@@ -74,7 +158,7 @@ class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements B
|
|
74 |
{
|
75 |
switch ($this->getCronFrequency()) {
|
76 |
case 'I':
|
77 |
-
return (int)
|
78 |
break;
|
79 |
case 'H':
|
80 |
return 60;
|
@@ -85,15 +169,15 @@ class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements B
|
|
85 |
default:
|
86 |
return 5;
|
87 |
break;
|
88 |
-
}
|
89 |
}
|
90 |
-
|
91 |
/**
|
92 |
* @return string
|
93 |
*/
|
94 |
public function getCronFrequency()
|
95 |
{
|
96 |
-
return
|
97 |
}
|
98 |
|
99 |
/**
|
@@ -101,7 +185,7 @@ class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements B
|
|
101 |
*/
|
102 |
public function getOneRunLimit()
|
103 |
{
|
104 |
-
return (int)
|
105 |
}
|
106 |
|
107 |
/**
|
@@ -109,7 +193,7 @@ class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements B
|
|
109 |
*/
|
110 |
public function getEmailIdentity()
|
111 |
{
|
112 |
-
return (string)
|
113 |
}
|
114 |
|
115 |
/**
|
@@ -121,6 +205,71 @@ class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements B
|
|
121 |
return 0;
|
122 |
}
|
123 |
|
124 |
-
return (int)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
125 |
}
|
126 |
}
|
7 |
*/
|
8 |
class Bronto_Reminder_Helper_Data extends Bronto_Common_Helper_Data implements Bronto_Common_Helper_DataInterface
|
9 |
{
|
10 |
+
const XML_PATH_ENABLED = 'bronto_reminder/settings/enabled';
|
11 |
+
const XML_PATH_ALLOW_SEND = 'bronto_reminder/settings/allow_send';
|
12 |
+
const XML_PATH_TIME = 'bronto_reminder/settings/time';
|
13 |
+
const XML_PATH_INTERVAL = 'bronto_reminder/settings/interval';
|
14 |
+
const XML_PATH_FREQUENCY = 'bronto_reminder/settings/frequency';
|
15 |
+
const XML_PATH_FREQUENCY_MIN = 'bronto_reminder/settings/minutes';
|
16 |
+
const XML_PATH_SEND_LIMIT = 'bronto_reminder/settings/limit';
|
17 |
+
const XML_PATH_EMAIL_IDENTITY = 'bronto_reminder/settings/identity';
|
18 |
const XML_PATH_EMAIL_THRESHOLD = 'bronto_reminder/settings/threshold';
|
19 |
|
20 |
/**
|
27 |
return 'Bronto_Reminder';
|
28 |
}
|
29 |
|
30 |
+
/**
|
31 |
+
* Get link to transactional email configuration
|
32 |
+
* @return type
|
33 |
+
*/
|
34 |
+
public function getConfigLink()
|
35 |
+
{
|
36 |
+
$url = $this->getScopeUrl('/system_config/edit/section/bronto_reminder');
|
37 |
+
return '<strong>System › Configuration » Bronto › <a href="' . $url . '" title="Reminder Emails">Reminder Emails</a></strong>';
|
38 |
+
}
|
39 |
+
|
40 |
/**
|
41 |
* @return bool
|
42 |
*/
|
43 |
+
public function isEnabled($store = null)
|
44 |
+
{
|
45 |
+
if (!$this->getApiToken($store)) {
|
46 |
+
return false;
|
47 |
+
}
|
48 |
+
|
49 |
+
return (bool)$this->getAdminScopedConfig(self::XML_PATH_ENABLED, $store);
|
50 |
+
}
|
51 |
+
|
52 |
+
/*
|
53 |
+
* Get Text to display in notice when enabling module
|
54 |
+
*
|
55 |
+
* @return string
|
56 |
+
*/
|
57 |
+
public function getModuleEnabledText()
|
58 |
{
|
59 |
+
$message = parent::getModuleEnabledText();
|
60 |
+
$scopeData = $this->getScopeParams();
|
61 |
+
if ($scopeData['scope'] != 'default') {
|
62 |
+
$url = Mage::helper('adminhtml')->getUrl('/reminders');
|
63 |
+
|
64 |
+
$message = $this->__(
|
65 |
+
'If the API token being used for this configuration scope is different from that of the Default Config scope, ' .
|
66 |
+
'you should update any existing rules in <a href="' . $url . '">Bronto Reminder Emails</a> ' .
|
67 |
+
'to use a message from the corresponding Bronto account.'
|
68 |
+
);
|
69 |
+
}
|
70 |
+
return $message;
|
71 |
}
|
72 |
+
|
73 |
+
/**
|
74 |
+
* Determine if any stores have module enabled
|
75 |
+
*
|
76 |
+
* @return bool
|
77 |
+
*/
|
78 |
+
public function isEnabledForAny()
|
79 |
+
{
|
80 |
+
$stores = Mage::app()->getStores();
|
81 |
+
if (is_array($stores) && count($stores) >= 1) {
|
82 |
+
foreach ($stores as $store) {
|
83 |
+
if ($this->isEnabled($store->getId())) {
|
84 |
+
return true;
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
return false;
|
89 |
+
}
|
90 |
+
|
91 |
/**
|
92 |
* @param null|string|bool|int|Mage_Core_Model_Store $store
|
93 |
* @return bool
|
94 |
*/
|
95 |
public function isAllowSend($store = null)
|
96 |
{
|
97 |
+
return (bool)$this->getAdminScopedConfig(self::XML_PATH_ALLOW_SEND, $store);
|
98 |
}
|
99 |
+
|
100 |
+
/**
|
101 |
+
* Determine if any stores are allowed to send
|
102 |
+
* @return bool
|
103 |
+
*/
|
104 |
+
public function isAllowSendForAny()
|
105 |
+
{
|
106 |
+
$stores = Mage::app()->getStores();
|
107 |
+
if (is_array($stores) && count($stores) >= 1) {
|
108 |
+
foreach ($stores as $store) {
|
109 |
+
if ($this->isAllowSend($store->getId())) {
|
110 |
+
return true;
|
111 |
+
}
|
112 |
+
}
|
113 |
+
}
|
114 |
+
}
|
115 |
+
|
116 |
+
/**
|
117 |
+
* Determine if email can be sent through bronto
|
118 |
+
*
|
119 |
+
* @param Mage_Core_Model_Email_Template $template
|
120 |
+
* @return boolean
|
121 |
+
*/
|
122 |
+
public function canSendBronto(Mage_Core_Model_Email_Template $template, $storeId = null)
|
123 |
+
{
|
124 |
+
if ($this->isEnabled($storeId)) {
|
125 |
+
return true;
|
126 |
+
}
|
127 |
+
|
128 |
+
return false;
|
129 |
+
}
|
130 |
+
|
131 |
/**
|
132 |
* Text to display when reminder module not allowed to send emails
|
133 |
* @return type
|
134 |
*/
|
135 |
public function getNotAllowedText()
|
136 |
{
|
137 |
+
$url = $this->getScopeUrl('/system_config/edit/section/bronto_reminder');
|
138 |
$messageText = $this->__('Rules are currently unable to send emails.
|
139 |
You can enable this function in the System Configuration <a href="' . $url . '">Reminder Emails</a>');
|
140 |
+
|
141 |
return $messageText;
|
142 |
}
|
143 |
|
158 |
{
|
159 |
switch ($this->getCronFrequency()) {
|
160 |
case 'I':
|
161 |
+
return (int)$this->getAdminScopedConfig(self::XML_PATH_INTERVAL);
|
162 |
break;
|
163 |
case 'H':
|
164 |
return 60;
|
169 |
default:
|
170 |
return 5;
|
171 |
break;
|
172 |
+
}
|
173 |
}
|
174 |
+
|
175 |
/**
|
176 |
* @return string
|
177 |
*/
|
178 |
public function getCronFrequency()
|
179 |
{
|
180 |
+
return $this->getAdminScopedConfig(self::XML_PATH_FREQUENCY);
|
181 |
}
|
182 |
|
183 |
/**
|
185 |
*/
|
186 |
public function getOneRunLimit()
|
187 |
{
|
188 |
+
return (int)$this->getAdminScopedConfig(self::XML_PATH_SEND_LIMIT);
|
189 |
}
|
190 |
|
191 |
/**
|
193 |
*/
|
194 |
public function getEmailIdentity()
|
195 |
{
|
196 |
+
return (string)$this->getAdminScopedConfig(self::XML_PATH_EMAIL_IDENTITY);
|
197 |
}
|
198 |
|
199 |
/**
|
205 |
return 0;
|
206 |
}
|
207 |
|
208 |
+
return (int)$this->getAdminScopedConfig(self::XML_PATH_EMAIL_THRESHOLD);
|
209 |
+
}
|
210 |
+
|
211 |
+
/**
|
212 |
+
* @see parent
|
213 |
+
* @return boolean
|
214 |
+
*/
|
215 |
+
public function hasCustomConfig() {
|
216 |
+
return true;
|
217 |
+
}
|
218 |
+
|
219 |
+
/**
|
220 |
+
* Returns any reminder email rules with their conditions
|
221 |
+
*
|
222 |
+
* @return array
|
223 |
+
*/
|
224 |
+
public function getCustomConfig() {
|
225 |
+
$ruleMeta = Mage::getModel('bronto_reminder/rule');
|
226 |
+
$rules = $ruleMeta->getCollection()->getItems();
|
227 |
+
|
228 |
+
$data = array();
|
229 |
+
if (empty($rules)) {
|
230 |
+
return $data;
|
231 |
+
}
|
232 |
+
|
233 |
+
$reminders = array();
|
234 |
+
foreach ($rules as $rule) {
|
235 |
+
$root = $rule->getConditions();
|
236 |
+
|
237 |
+
$reminders[] = array(
|
238 |
+
'name' => $rule->getName(),
|
239 |
+
'active' => $rule->getIsActive(),
|
240 |
+
'from' => $rule->getFromDate(),
|
241 |
+
'to' => $rule->getToDate(),
|
242 |
+
'conditions' => array(
|
243 |
+
'label' => $root->asString(),
|
244 |
+
'conditions' => $this->_recursiveConditionLog($root),
|
245 |
+
),
|
246 |
+
);
|
247 |
+
}
|
248 |
+
$data['reminders'] = $reminders;
|
249 |
+
|
250 |
+
return $data;
|
251 |
+
}
|
252 |
+
|
253 |
+
/**
|
254 |
+
* Formats the conditions for the root condition
|
255 |
+
*
|
256 |
+
* @param mixed $condition
|
257 |
+
* @return string
|
258 |
+
*/
|
259 |
+
protected function _recursiveConditionLog($condition) {
|
260 |
+
$conditions = array();
|
261 |
+
|
262 |
+
foreach ($condition->getConditions() as $childCondition) {
|
263 |
+
$html = str_replace(' ', '', $childCondition->asHtml());
|
264 |
+
$html = preg_replace('|<select[^>]*>.*?</select>|s', '', $html);
|
265 |
+
$html = preg_replace('|\s+|s', ' ', strip_tags($html));
|
266 |
+
|
267 |
+
$conditions[] = array(
|
268 |
+
'label' => trim($html),
|
269 |
+
'conditions' => $this->_recursiveConditionLog($childCondition),
|
270 |
+
);
|
271 |
+
}
|
272 |
+
|
273 |
+
return $conditions;
|
274 |
}
|
275 |
}
|
app/code/community/Bronto/Reminder/Model/Condition/Abstract.php
CHANGED
@@ -35,7 +35,7 @@ class Bronto_Reminder_Model_Condition_Abstract extends Mage_Rule_Model_Condition
|
|
35 |
* Generate customer condition string
|
36 |
*
|
37 |
* @param $customer
|
38 |
-
* @param string
|
39 |
* @return string
|
40 |
*/
|
41 |
protected function _createCustomerFilter($fieldName)
|
@@ -46,9 +46,9 @@ class Bronto_Reminder_Model_Condition_Abstract extends Mage_Rule_Model_Condition
|
|
46 |
/**
|
47 |
* Limit select by website with joining to store table
|
48 |
*
|
49 |
-
* @param Zend_Db_Select
|
50 |
* @param int | Zend_Db_Expr $website
|
51 |
-
* @param string
|
52 |
* @return Bronto_Reminder_Model_Condition_Abstract
|
53 |
*/
|
54 |
protected function _limitByStoreWebsite(Zend_Db_Select $select, $website, $storeIdField)
|
35 |
* Generate customer condition string
|
36 |
*
|
37 |
* @param $customer
|
38 |
+
* @param string $fieldName
|
39 |
* @return string
|
40 |
*/
|
41 |
protected function _createCustomerFilter($fieldName)
|
46 |
/**
|
47 |
* Limit select by website with joining to store table
|
48 |
*
|
49 |
+
* @param Zend_Db_Select $select
|
50 |
* @param int | Zend_Db_Expr $website
|
51 |
+
* @param string $storeIdField
|
52 |
* @return Bronto_Reminder_Model_Condition_Abstract
|
53 |
*/
|
54 |
protected function _limitByStoreWebsite(Zend_Db_Select $select, $website, $storeIdField)
|
app/code/community/Bronto/Reminder/Model/Condition/Combine/Abstract.php
CHANGED
@@ -55,7 +55,7 @@ abstract class Bronto_Reminder_Model_Condition_Combine_Abstract extends Mage_Rul
|
|
55 |
/**
|
56 |
* Get filter by customer condition for rule matching sql
|
57 |
*
|
58 |
-
* @param string
|
59 |
* @return string
|
60 |
*/
|
61 |
protected function _createCustomerFilter($fieldName)
|
@@ -101,10 +101,10 @@ abstract class Bronto_Reminder_Model_Condition_Combine_Abstract extends Mage_Rul
|
|
101 |
/**
|
102 |
* Build base SQL
|
103 |
*/
|
104 |
-
$select
|
105 |
-
$required
|
106 |
-
$whereFunction
|
107 |
-
$operator
|
108 |
//$operator = '=';
|
109 |
|
110 |
$gotConditions = false;
|
@@ -161,9 +161,9 @@ abstract class Bronto_Reminder_Model_Condition_Combine_Abstract extends Mage_Rul
|
|
161 |
/**
|
162 |
* Limit select by website with joining to store table
|
163 |
*
|
164 |
-
* @param Zend_Db_Select
|
165 |
-
* @param int|Zend_Db_Expr
|
166 |
-
* @param string
|
167 |
* @return Bronto_Reminder_Model_Condition_Abstract
|
168 |
*/
|
169 |
protected function _limitByStoreWebsite(Zend_Db_Select $select, $website, $storeIdField)
|
55 |
/**
|
56 |
* Get filter by customer condition for rule matching sql
|
57 |
*
|
58 |
+
* @param string $fieldName
|
59 |
* @return string
|
60 |
*/
|
61 |
protected function _createCustomerFilter($fieldName)
|
101 |
/**
|
102 |
* Build base SQL
|
103 |
*/
|
104 |
+
$select = $this->_prepareConditionsSql($rule, $website);
|
105 |
+
$required = $this->_getRequiredValidation();
|
106 |
+
$whereFunction = ($this->getAggregator() == 'all') ? 'where' : 'orWhere';
|
107 |
+
$operator = $required ? '=' : '<>';
|
108 |
//$operator = '=';
|
109 |
|
110 |
$gotConditions = false;
|
161 |
/**
|
162 |
* Limit select by website with joining to store table
|
163 |
*
|
164 |
+
* @param Zend_Db_Select $select
|
165 |
+
* @param int|Zend_Db_Expr $website
|
166 |
+
* @param string $storeIdField
|
167 |
* @return Bronto_Reminder_Model_Condition_Abstract
|
168 |
*/
|
169 |
protected function _limitByStoreWebsite(Zend_Db_Select $select, $website, $storeIdField)
|
app/code/community/Bronto/Reminder/Model/Email/Message.php
CHANGED
@@ -5,10 +5,34 @@
|
|
5 |
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
* @version 1.5.0
|
7 |
*/
|
8 |
-
class Bronto_Reminder_Model_Email_Message extends
|
9 |
{
|
10 |
/**
|
11 |
* @var string
|
12 |
*/
|
13 |
protected $_helper = 'bronto_reminder';
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
}
|
5 |
* @copyright 2011-2012 Bronto Software, Inc.
|
6 |
* @version 1.5.0
|
7 |
*/
|
8 |
+
class Bronto_Reminder_Model_Email_Message extends Bronto_Common_Model_Email_Template
|
9 |
{
|
10 |
/**
|
11 |
* @var string
|
12 |
*/
|
13 |
protected $_helper = 'bronto_reminder';
|
14 |
+
|
15 |
+
/**
|
16 |
+
* @var string
|
17 |
+
*/
|
18 |
+
protected $_apiLogFile = 'bronto_reminder_api.log';
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Log the Delivery API call
|
22 |
+
*
|
23 |
+
* @param boolean $success
|
24 |
+
* @param string $error (Optional)
|
25 |
+
* @param Bronto_Api_Delivery_Row $delivery (Optional)
|
26 |
+
*/
|
27 |
+
protected function _afterSend($success, $error = null, Bronto_Api_Delivery_Row $delivery = null)
|
28 |
+
{
|
29 |
+
if (!is_null($delivery)) {
|
30 |
+
$helper = Mage::helper($this->_helper);
|
31 |
+
$status = $success ? "Successful" : "Failed";
|
32 |
+
|
33 |
+
$helper->writeVerboseDebug("===== $status Reminder Delivery =====", $this->_apiLogFile);
|
34 |
+
$helper->writeVerboseDebug(var_export($delivery->getApi()->getLastRequest(), true), $this->_apiLogFile);
|
35 |
+
$helper->writeVerboseDebug(var_export($delivery->getApi()->getLastResponse(), true), $this->_apiLogFile);
|
36 |
+
}
|
37 |
+
}
|
38 |
}
|
app/code/community/Bronto/Reminder/Model/Mysql4/Customer/Collection.php
CHANGED
@@ -43,13 +43,13 @@ class Bronto_Reminder_Model_Mysql4_Customer_Collection extends Mage_Customer_Mod
|
|
43 |
array('lq' => $logQuoteTable),
|
44 |
'q.entity_id = lq.quote_id',
|
45 |
array()
|
46 |
-
);
|
47 |
-
|
48 |
$select->joinLeft(
|
49 |
array('e' => $customerTable),
|
50 |
'e.entity_id = c.customer_id',
|
51 |
array(
|
52 |
-
'entity_id',
|
53 |
'email' => new Zend_Db_Expr("IF(e.email IS NULL, ($guestSelect), e.email)")
|
54 |
)
|
55 |
);
|
@@ -79,18 +79,18 @@ class Bronto_Reminder_Model_Mysql4_Customer_Collection extends Mage_Customer_Mod
|
|
79 |
);
|
80 |
}
|
81 |
|
82 |
-
$this->_joinFields['associated_at'] = array('table'=>'c', 'field' => 'associated_at');
|
83 |
-
$this->_joinFields['emails_failed'] = array('table'=>'c', 'field' => 'emails_failed');
|
84 |
-
$this->_joinFields['is_active'] = array('table'=>'c', 'field' => 'is_active');
|
85 |
|
86 |
if ($salesRuleCouponTable) {
|
87 |
-
$this->_joinFields['code'] = array('table'=>'sc', 'field' => 'code');
|
88 |
-
$this->_joinFields['usage_limit'] = array('table'=>'sc', 'field' => 'usage_limit');
|
89 |
-
$this->_joinFields['usage_per_customer'] = array('table'=>'sc', 'field' => 'usage_per_customer');
|
90 |
}
|
91 |
|
92 |
-
$this->_joinFields['emails_sent'] = array('table'=>'l', 'field' => 'emails_sent');
|
93 |
-
$this->_joinFields['last_sent'] = array('table'=>'l', 'field' => 'last_sent');
|
94 |
|
95 |
return $this;
|
96 |
}
|
43 |
array('lq' => $logQuoteTable),
|
44 |
'q.entity_id = lq.quote_id',
|
45 |
array()
|
46 |
+
);
|
47 |
+
|
48 |
$select->joinLeft(
|
49 |
array('e' => $customerTable),
|
50 |
'e.entity_id = c.customer_id',
|
51 |
array(
|
52 |
+
'entity_id',
|
53 |
'email' => new Zend_Db_Expr("IF(e.email IS NULL, ($guestSelect), e.email)")
|
54 |
)
|
55 |
);
|
79 |
);
|
80 |
}
|
81 |
|
82 |
+
$this->_joinFields['associated_at'] = array('table' => 'c', 'field' => 'associated_at');
|
83 |
+
$this->_joinFields['emails_failed'] = array('table' => 'c', 'field' => 'emails_failed');
|
84 |
+
$this->_joinFields['is_active'] = array('table' => 'c', 'field' => 'is_active');
|
85 |
|
86 |
if ($salesRuleCouponTable) {
|
87 |
+
$this->_joinFields['code'] = array('table' => 'sc', 'field' => 'code');
|
88 |
+
$this->_joinFields['usage_limit'] = array('table' => 'sc', 'field' => 'usage_limit');
|
89 |
+
$this->_joinFields['usage_per_customer'] = array('table' => 'sc', 'field' => 'usage_per_customer');
|
90 |
}
|
91 |
|
92 |
+
$this->_joinFields['emails_sent'] = array('table' => 'l', 'field' => 'emails_sent');
|
93 |
+
$this->_joinFields['last_sent'] = array('table' => 'l', 'field' => 'last_sent');
|
94 |
|
95 |
return $this;
|
96 |
}
|
app/code/community/Bronto/Reminder/Model/Mysql4/Rule.php
CHANGED
@@ -51,8 +51,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
51 |
{
|
52 |
if (!$object->getActiveFrom()) {
|
53 |
$object->setActiveFrom(new Zend_Db_Expr('NULL'));
|
54 |
-
}
|
55 |
-
else {
|
56 |
if ($object->getActiveFrom() instanceof Zend_Date) {
|
57 |
$object->setActiveFrom($object->getActiveFrom()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
|
58 |
}
|
@@ -60,8 +59,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
60 |
|
61 |
if (!$object->getActiveTo()) {
|
62 |
$object->setActiveTo(new Zend_Db_Expr('NULL'));
|
63 |
-
}
|
64 |
-
else {
|
65 |
if ($object->getActiveTo() instanceof Zend_Date) {
|
66 |
$object->setActiveTo($object->getActiveTo()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
|
67 |
}
|
@@ -100,6 +98,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
100 |
if (!is_array($websiteIds)) {
|
101 |
$websiteIds = array($websiteIds);
|
102 |
}
|
|
|
103 |
foreach ($websiteIds as $websiteId) {
|
104 |
$adapter->insert($this->_websiteTable, array(
|
105 |
'website_id' => $websiteId,
|
@@ -112,7 +111,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
112 |
/**
|
113 |
* Get website ids associated to the rule id
|
114 |
*
|
115 |
-
* @param int
|
116 |
* @return array
|
117 |
*/
|
118 |
public function getWebsiteIds($ruleId)
|
@@ -120,7 +119,10 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
120 |
$select = $this->_getReadAdapter()->select()
|
121 |
->from($this->_websiteTable, 'website_id')
|
122 |
->where('rule_id=?', $ruleId);
|
123 |
-
|
|
|
|
|
|
|
124 |
}
|
125 |
|
126 |
/**
|
@@ -131,11 +133,11 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
131 |
*/
|
132 |
protected function _saveMessageData($rule)
|
133 |
{
|
134 |
-
$adapter
|
135 |
$messageTable = $this->getTable('bronto_reminder/message');
|
136 |
$adapter->delete($messageTable, array('rule_id = ?' => $rule->getId()));
|
137 |
|
138 |
-
$labels
|
139 |
$descriptions = $rule->getStoreDescriptions();
|
140 |
|
141 |
foreach ($rule->getStoreMessages() as $storeId => $messageId) {
|
@@ -143,10 +145,10 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
143 |
continue;
|
144 |
}
|
145 |
$adapter->insert($messageTable, array(
|
146 |
-
'rule_id'
|
147 |
-
'store_id'
|
148 |
-
'message_id'
|
149 |
-
'label'
|
150 |
'description' => $descriptions[$storeId]
|
151 |
));
|
152 |
}
|
@@ -156,7 +158,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
156 |
/**
|
157 |
* Get Message data assigned to reminder rule
|
158 |
*
|
159 |
-
* @param int
|
160 |
* @return array
|
161 |
*/
|
162 |
public function getMessageData($ruleId)
|
@@ -172,14 +174,14 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
172 |
* Get store data (labels and descriptions) assigned to reminder rule.
|
173 |
* If labels and descriptions are not specified it will be replaced with default values.
|
174 |
*
|
175 |
-
* @param int
|
176 |
-
* @param int
|
177 |
* @return array
|
178 |
*/
|
179 |
public function getStoreMessageData($ruleId, $storeId)
|
180 |
{
|
181 |
$messageTable = $this->getTable('bronto_reminder/message');
|
182 |
-
$ruleTable
|
183 |
|
184 |
$select = $this->createSelect()->from(array('m' => $messageTable),
|
185 |
'm.message_id,
|
@@ -200,9 +202,9 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
200 |
}
|
201 |
|
202 |
/**
|
203 |
-
* @param int
|
204 |
-
* @param int
|
205 |
-
* @param int
|
206 |
* @param string $messageId
|
207 |
* @return array
|
208 |
*/
|
@@ -261,7 +263,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
261 |
*
|
262 |
* @param string $field
|
263 |
* @param string $operator
|
264 |
-
* @param mixed
|
265 |
* @return string
|
266 |
*/
|
267 |
public function createConditionSql($field, $operator, $value)
|
@@ -277,7 +279,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
277 |
$condition = $this->quoteInto($field . ' ' . $sqlOperator . ' (?)', $value);
|
278 |
}
|
279 |
} else {
|
280 |
-
$condition = $this->quoteInto($field. ' ' . $sqlOperator . ' ?', '%' . $value . '%');
|
281 |
}
|
282 |
break;
|
283 |
case 'between':
|
@@ -293,7 +295,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
293 |
/**
|
294 |
* Deactivate already matched customers before new matching process
|
295 |
*
|
296 |
-
* @param int
|
297 |
* @return Bronto_Reminder_Model_Mysql4_Rule
|
298 |
*/
|
299 |
public function deactivateMatchedCustomers($ruleId)
|
@@ -306,38 +308,74 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
306 |
return $this;
|
307 |
}
|
308 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
309 |
/**
|
310 |
* Try to associate reminder rule with matched customers.
|
311 |
* If customer was added earlier, update is_active column.
|
312 |
*
|
313 |
-
* @param Bronto_Reminder_Model_Rule
|
314 |
-
* @param Mage_SalesRule_Model_Rule
|
315 |
-
* @param int
|
316 |
* @return Bronto_Reminder_Model_Mysql4_Rule
|
317 |
*/
|
318 |
-
public function saveMatchedCustomers($rule, $salesRule, $websiteId, $threshold=null)
|
319 |
{
|
320 |
$select = $rule->getConditions()->getConditionsSql($rule, $websiteId);
|
|
|
321 |
|
322 |
if (!$rule->getConditionSql()) {
|
323 |
return $this;
|
324 |
}
|
325 |
-
|
326 |
if ($threshold) {
|
327 |
$select->where('c.emails_failed IS NULL OR c.emails_failed < ? ', $threshold);
|
328 |
}
|
329 |
|
|
|
|
|
|
|
330 |
$i = 0;
|
331 |
-
$ruleId
|
332 |
-
$adapter
|
333 |
-
$currentDate
|
334 |
$dataToInsert = array();
|
335 |
Mage::helper('bronto_reminder')->writeDebug('ruleId: ' . $rule->getId() . ' website: ' . $websiteId, 'bronto_reminder_sql.log');
|
336 |
-
|
|
|
|
|
|
|
|
|
337 |
|
338 |
/* @var $stmt Varien_Db_Statement_Pdo_Mysql */
|
339 |
-
$stmt = $adapter->query($select, array('rule_id' => $ruleId));
|
340 |
-
|
341 |
Mage::helper('bronto_reminder')->writeDebug('saveMatchedCustomers():', 'bronto_reminder_sql.log');
|
342 |
|
343 |
try {
|
@@ -346,22 +384,21 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
346 |
if (empty($row['coupon_id']) && $salesRule) {
|
347 |
$coupon = $salesRule->acquireCoupon();
|
348 |
$couponId = ($coupon !== null) ? $coupon->getId() : null;
|
349 |
-
}
|
350 |
-
else {
|
351 |
$couponId = $row['coupon_id'];
|
352 |
}
|
353 |
|
354 |
$dataToInsert[] = array(
|
355 |
-
'rule_id'
|
356 |
-
'coupon_id'
|
357 |
-
'unique_id'
|
358 |
-
'store_id'
|
359 |
-
'customer_id'
|
360 |
-
'quote_id'
|
361 |
-
'wishlist_id'
|
362 |
-
'visitor_id'
|
363 |
'associated_at' => $currentDate,
|
364 |
-
'is_active'
|
365 |
);
|
366 |
$i++;
|
367 |
|
@@ -372,9 +409,11 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
372 |
$dataToInsert = array();
|
373 |
}
|
374 |
}
|
375 |
-
|
376 |
$this->_saveMatchedCustomerData($dataToInsert);
|
377 |
$adapter->commit();
|
|
|
|
|
378 |
} catch (Exception $e) {
|
379 |
$adapter->rollBack();
|
380 |
throw $e;
|
@@ -383,7 +422,7 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
383 |
return $this;
|
384 |
}
|
385 |
|
386 |
-
|
387 |
* Save data by matched customer coupons
|
388 |
*
|
389 |
* @param array $data
|
@@ -404,11 +443,11 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
404 |
* @param int|null $ruleId
|
405 |
* @return array
|
406 |
*/
|
407 |
-
public function getCustomersForNotification($limit=null, $ruleId=null)
|
408 |
{
|
409 |
$couponTable = $this->getTable('bronto_reminder/coupon');
|
410 |
-
$ruleTable
|
411 |
-
$logTable
|
412 |
$currentDate = $this->formatDate(time());
|
413 |
|
414 |
$select = $this->createSelect()->from(
|
@@ -416,11 +455,6 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
416 |
array('rule_id', 'coupon_id', 'unique_id', 'store_id', 'customer_id', 'quote_id', 'wishlist_id', 'visitor_id')
|
417 |
);
|
418 |
|
419 |
-
$select->join(
|
420 |
-
array('r' => $ruleTable),
|
421 |
-
'c.rule_id = r.rule_id AND r.is_active = 1',
|
422 |
-
array('schedule')
|
423 |
-
);
|
424 |
|
425 |
$select->joinLeft(
|
426 |
array('l' => $logTable),
|
@@ -428,6 +462,12 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
428 |
array()
|
429 |
);
|
430 |
|
|
|
|
|
|
|
|
|
|
|
|
|
431 |
if ($ruleId) {
|
432 |
$select->where('c.rule_id = ?', $ruleId);
|
433 |
}
|
@@ -441,16 +481,16 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
441 |
}
|
442 |
|
443 |
/**
|
444 |
-
|
445 |
-
|
446 |
-
|
447 |
-
|
448 |
-
|
449 |
-
|
450 |
-
|
451 |
-
|
452 |
-
|
453 |
-
|
454 |
*/
|
455 |
|
456 |
return $this->_getReadAdapter()->fetchAll($select);
|
@@ -459,18 +499,18 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
459 |
/**
|
460 |
* Add notification log row after letter was successfully sent.
|
461 |
*
|
462 |
-
* @param int
|
463 |
-
* @param int
|
464 |
* @return Bronto_Reminder_Model_Mysql4_Rule
|
465 |
*/
|
466 |
public function addNotificationLog($ruleId, $uniqueId, $deliveryId = null, $messageId = null)
|
467 |
{
|
468 |
$data = array(
|
469 |
-
'rule_id'
|
470 |
-
'unique_id'
|
471 |
-
'sent_at'
|
472 |
'bronto_delivery_id' => $deliveryId,
|
473 |
-
'bronto_message_id'
|
474 |
);
|
475 |
|
476 |
$this->_getWriteAdapter()->insert($this->getTable('bronto_reminder/log'), $data);
|
@@ -480,16 +520,17 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
480 |
/**
|
481 |
* Update failed email counter.
|
482 |
*
|
483 |
-
* @param int
|
484 |
-
* @param int
|
485 |
* @return Bronto_Reminder_Model_Mysql4_Rule
|
486 |
*/
|
487 |
-
public function updateFailedEmailsCounter($ruleId, $
|
488 |
{
|
489 |
$this->_getWriteAdapter()->update($this->getTable('bronto_reminder/coupon'),
|
490 |
array('emails_failed' => new Zend_Db_Expr('emails_failed + 1')),
|
491 |
-
array('rule_id = ?'
|
492 |
);
|
|
|
493 |
return $this;
|
494 |
}
|
495 |
|
@@ -508,20 +549,19 @@ class Bronto_Reminder_Model_Mysql4_Rule extends Mage_Core_Model_Mysql4_Abstract
|
|
508 |
$select->where('r.salesrule_id = ?', $salesruleId);
|
509 |
return $this->_getReadAdapter()->fetchOne($select);
|
510 |
}
|
511 |
-
|
512 |
/**
|
513 |
* Remove row from coupon table by column, value and store_id
|
514 |
-
*
|
515 |
* @param type $column
|
516 |
* @param type $value
|
517 |
-
* @param type $storeId
|
518 |
* @return Bronto_Reminder_Model_Mysql4_Rule
|
519 |
*/
|
520 |
-
public function removeFromReminders($column, $value
|
521 |
{
|
522 |
-
$where = "$column = $value
|
523 |
$this->_getWriteAdapter()->delete($this->getTable('bronto_reminder/coupon'), $where);
|
524 |
-
|
525 |
return $this;
|
526 |
}
|
527 |
}
|
51 |
{
|
52 |
if (!$object->getActiveFrom()) {
|
53 |
$object->setActiveFrom(new Zend_Db_Expr('NULL'));
|
54 |
+
} else {
|
|
|
55 |
if ($object->getActiveFrom() instanceof Zend_Date) {
|
56 |
$object->setActiveFrom($object->getActiveFrom()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
|
57 |
}
|
59 |
|
60 |
if (!$object->getActiveTo()) {
|
61 |
$object->setActiveTo(new Zend_Db_Expr('NULL'));
|
62 |
+
} else {
|
|
|
63 |
if ($object->getActiveTo() instanceof Zend_Date) {
|
64 |
$object->setActiveTo($object->getActiveTo()->toString(Varien_Date::DATETIME_INTERNAL_FORMAT));
|
65 |
}
|
98 |
if (!is_array($websiteIds)) {
|
99 |
$websiteIds = array($websiteIds);
|
100 |
}
|
101 |
+
|
102 |
foreach ($websiteIds as $websiteId) {
|
103 |
$adapter->insert($this->_websiteTable, array(
|
104 |
'website_id' => $websiteId,
|
111 |
/**
|
112 |
* Get website ids associated to the rule id
|
113 |
*
|
114 |
+
* @param int $ruleId
|
115 |
* @return array
|
116 |
*/
|
117 |
public function getWebsiteIds($ruleId)
|
119 |
$select = $this->_getReadAdapter()->select()
|
120 |
->from($this->_websiteTable, 'website_id')
|
121 |
->where('rule_id=?', $ruleId);
|
122 |
+
|
123 |
+
$websiteIds = $this->_getReadAdapter()->fetchCol($select);
|
124 |
+
array_unshift($websiteIds, "0");
|
125 |
+
return $websiteIds;
|
126 |
}
|
127 |
|
128 |
/**
|
133 |
*/
|
134 |
protected function _saveMessageData($rule)
|
135 |
{
|
136 |
+
$adapter = $this->_getWriteAdapter();
|
137 |
$messageTable = $this->getTable('bronto_reminder/message');
|
138 |
$adapter->delete($messageTable, array('rule_id = ?' => $rule->getId()));
|
139 |
|
140 |
+
$labels = $rule->getStoreLabels();
|
141 |
$descriptions = $rule->getStoreDescriptions();
|
142 |
|
143 |
foreach ($rule->getStoreMessages() as $storeId => $messageId) {
|
145 |
continue;
|
146 |
}
|
147 |
$adapter->insert($messageTable, array(
|
148 |
+
'rule_id' => $rule->getId(),
|
149 |
+
'store_id' => $storeId,
|
150 |
+
'message_id' => $messageId,
|
151 |
+
'label' => $labels[$storeId],
|
152 |
'description' => $descriptions[$storeId]
|
153 |
));
|
154 |
}
|
158 |
/**
|
159 |
* Get Message data assigned to reminder rule
|
160 |
*
|
161 |
+
* @param int $ruleId
|
162 |
* @return array
|
163 |
*/
|
164 |
public function getMessageData($ruleId)
|
174 |
* Get store data (labels and descriptions) assigned to reminder rule.
|
175 |
* If labels and descriptions are not specified it will be replaced with default values.
|
176 |
*
|
177 |
+
* @param int $ruleId
|
178 |
+
* @param int $storeId
|
179 |
* @return array
|
180 |
*/
|
181 |
public function getStoreMessageData($ruleId, $storeId)
|
182 |
{
|
183 |
$messageTable = $this->getTable('bronto_reminder/message');
|
184 |
+
$ruleTable = $this->getTable('bronto_reminder/rule');
|
185 |
|
186 |
$select = $this->createSelect()->from(array('m' => $messageTable),
|
187 |
'm.message_id,
|
202 |
}
|
203 |
|
204 |
/**
|
205 |
+
* @param int $ruleId
|
206 |
+
* @param int $storeId
|
207 |
+
* @param int $customerId
|
208 |
* @param string $messageId
|
209 |
* @return array
|
210 |
*/
|
263 |
*
|
264 |
* @param string $field
|
265 |
* @param string $operator
|
266 |
+
* @param mixed $value
|
267 |
* @return string
|
268 |
*/
|
269 |
public function createConditionSql($field, $operator, $value)
|
279 |
$condition = $this->quoteInto($field . ' ' . $sqlOperator . ' (?)', $value);
|
280 |
}
|
281 |
} else {
|
282 |
+
$condition = $this->quoteInto($field . ' ' . $sqlOperator . ' ?', '%' . $value . '%');
|
283 |
}
|
284 |
break;
|
285 |
case 'between':
|
295 |
/**
|
296 |
* Deactivate already matched customers before new matching process
|
297 |
*
|
298 |
+
* @param int $ruleId
|
299 |
* @return Bronto_Reminder_Model_Mysql4_Rule
|
300 |
*/
|
301 |
public function deactivateMatchedCustomers($ruleId)
|
308 |
return $this;
|
309 |
}
|
310 |
|
311 |
+
/**
|
312 |
+
* Deactivate customers that have been matched and emailed
|
313 |
+
*
|
314 |
+
* @param string $uniqueId
|
315 |
+
* @return Bronto_Reminder_Model_Mysql4_Rule
|
316 |
+
*/
|
317 |
+
public function deactivateMatchedCustomer($uniqueId)
|
318 |
+
{
|
319 |
+
$this->_getWriteAdapter()->update(
|
320 |
+
$this->getTable('bronto_reminder/coupon'),
|
321 |
+
array('is_active' => '0'),
|
322 |
+
array('unique_id = ?' => $uniqueId)
|
323 |
+
);
|
324 |
+
return $this;
|
325 |
+
}
|
326 |
+
|
327 |
+
/**
|
328 |
+
* Additional debugging that shows query and parameter values
|
329 |
+
* @param string $sql
|
330 |
+
* @param array $bind
|
331 |
+
*/
|
332 |
+
public function logFullQuery($sql, $bind)
|
333 |
+
{
|
334 |
+
foreach ($bind as $var => $val) {
|
335 |
+
$sql = str_replace(':' . $var, $val, $sql);
|
336 |
+
}
|
337 |
+
Mage::helper('bronto_reminder')->writeDebug('Full Query: ' . $sql, 'bronto_reminder_sql.log');
|
338 |
+
}
|
339 |
+
|
340 |
/**
|
341 |
* Try to associate reminder rule with matched customers.
|
342 |
* If customer was added earlier, update is_active column.
|
343 |
*
|
344 |
+
* @param Bronto_Reminder_Model_Rule $rule
|
345 |
+
* @param Mage_SalesRule_Model_Rule $salesRule
|
346 |
+
* @param int $websiteId
|
347 |
* @return Bronto_Reminder_Model_Mysql4_Rule
|
348 |
*/
|
349 |
+
public function saveMatchedCustomers($rule, $salesRule, $websiteId, $threshold = null)
|
350 |
{
|
351 |
$select = $rule->getConditions()->getConditionsSql($rule, $websiteId);
|
352 |
+
$interval = Mage::helper('bronto_reminder')->getCronInterval();
|
353 |
|
354 |
if (!$rule->getConditionSql()) {
|
355 |
return $this;
|
356 |
}
|
357 |
+
|
358 |
if ($threshold) {
|
359 |
$select->where('c.emails_failed IS NULL OR c.emails_failed < ? ', $threshold);
|
360 |
}
|
361 |
|
362 |
+
// Only pull for reminders not already attached to an active record
|
363 |
+
$select->where('c.is_active IS NULL OR c.is_active <> 1');
|
364 |
+
|
365 |
$i = 0;
|
366 |
+
$ruleId = $rule->getId();
|
367 |
+
$adapter = $this->_getWriteAdapter();
|
368 |
+
$currentDate = $this->formatDate(time());
|
369 |
$dataToInsert = array();
|
370 |
Mage::helper('bronto_reminder')->writeDebug('ruleId: ' . $rule->getId() . ' website: ' . $websiteId, 'bronto_reminder_sql.log');
|
371 |
+
# Replaced by logFullQuery below
|
372 |
+
#Mage::helper('bronto_reminder')->writeDebug($select->__toString(), 'bronto_reminder_sql.log');
|
373 |
+
|
374 |
+
// Log the query with binds replaced
|
375 |
+
$this->logFullQuery($select, array('rule_id' => $ruleId, 'interval' => $interval));
|
376 |
|
377 |
/* @var $stmt Varien_Db_Statement_Pdo_Mysql */
|
378 |
+
$stmt = $adapter->query($select, array('rule_id' => $ruleId, 'interval' => $interval));
|
|
|
379 |
Mage::helper('bronto_reminder')->writeDebug('saveMatchedCustomers():', 'bronto_reminder_sql.log');
|
380 |
|
381 |
try {
|
384 |
if (empty($row['coupon_id']) && $salesRule) {
|
385 |
$coupon = $salesRule->acquireCoupon();
|
386 |
$couponId = ($coupon !== null) ? $coupon->getId() : null;
|
387 |
+
} else {
|
|
|
388 |
$couponId = $row['coupon_id'];
|
389 |
}
|
390 |
|
391 |
$dataToInsert[] = array(
|
392 |
+
'rule_id' => $ruleId,
|
393 |
+
'coupon_id' => $couponId,
|
394 |
+
'unique_id' => $row['unique_id'],
|
395 |
+
'store_id' => $row['store_id'],
|
396 |
+
'customer_id' => $row['customer_id'],
|
397 |
+
'quote_id' => $row['quote_id'],
|
398 |
+
'wishlist_id' => $row['wishlist_id'],
|
399 |
+
'visitor_id' => $row['visitor_id'],
|
400 |
'associated_at' => $currentDate,
|
401 |
+
'is_active' => '1'
|
402 |
);
|
403 |
$i++;
|
404 |
|
409 |
$dataToInsert = array();
|
410 |
}
|
411 |
}
|
412 |
+
|
413 |
$this->_saveMatchedCustomerData($dataToInsert);
|
414 |
$adapter->commit();
|
415 |
+
|
416 |
+
Mage::helper('bronto_reminder')->writeDebug(" Query Matched {$i} customers", 'bronto_reminder_sql.log');
|
417 |
} catch (Exception $e) {
|
418 |
$adapter->rollBack();
|
419 |
throw $e;
|
422 |
return $this;
|
423 |
}
|
424 |
|
425 |
+
/**
|
426 |
* Save data by matched customer coupons
|
427 |
*
|
428 |
* @param array $data
|
443 |
* @param int|null $ruleId
|
444 |
* @return array
|
445 |
*/
|
446 |
+
public function getCustomersForNotification($limit = null, $ruleId = null)
|
447 |
{
|
448 |
$couponTable = $this->getTable('bronto_reminder/coupon');
|
449 |
+
$ruleTable = $this->getTable('bronto_reminder/rule');
|
450 |
+
$logTable = $this->getTable('bronto_reminder/log');
|
451 |
$currentDate = $this->formatDate(time());
|
452 |
|
453 |
$select = $this->createSelect()->from(
|
455 |
array('rule_id', 'coupon_id', 'unique_id', 'store_id', 'customer_id', 'quote_id', 'wishlist_id', 'visitor_id')
|
456 |
);
|
457 |
|
|
|
|
|
|
|
|
|
|
|
458 |
|
459 |
$select->joinLeft(
|
460 |
array('l' => $logTable),
|
462 |
array()
|
463 |
);
|
464 |
|
465 |
+
$select->join(
|
466 |
+
array('r' => $ruleTable),
|
467 |
+
'c.rule_id = r.rule_id AND r.is_active = 1',
|
468 |
+
array('schedule')
|
469 |
+
);
|
470 |
+
|
471 |
if ($ruleId) {
|
472 |
$select->where('c.rule_id = ?', $ruleId);
|
473 |
}
|
481 |
}
|
482 |
|
483 |
/**
|
484 |
+
SELECT `c`.`customer_id`, `c`.`coupon_id`, `c`.`rule_id`, `r`.`schedule`
|
485 |
+
FROM `bronto_reminder_rule_coupon` AS `c`
|
486 |
+
INNER JOIN `bronto_reminder_rule` AS `r` ON c.rule_id = r.rule_id AND r.is_active = 1
|
487 |
+
LEFT JOIN `bronto_reminder_rule_log` AS `l` ON c.rule_id=l.rule_id AND c.customer_id=l.customer_id
|
488 |
+
WHERE (c.rule_id = '1') AND (c.is_active = 1)
|
489 |
+
GROUP BY `c`.`customer_id`, `c`.`rule_id`
|
490 |
+
HAVING ((MAX(l.sent_at) IS NULL)
|
491 |
+
OR (FIND_IN_SET(TO_DAYS('2012-05-11 09:21:27') - TO_DAYS(MIN(l.sent_at)), r.schedule)
|
492 |
+
AND TO_DAYS('2012-05-11 09:21:27') != TO_DAYS(MAX(l.sent_at))))
|
493 |
+
LIMIT 100
|
494 |
*/
|
495 |
|
496 |
return $this->_getReadAdapter()->fetchAll($select);
|
499 |
/**
|
500 |
* Add notification log row after letter was successfully sent.
|
501 |
*
|
502 |
+
* @param int $ruleId
|
503 |
+
* @param int $customerId
|
504 |
* @return Bronto_Reminder_Model_Mysql4_Rule
|
505 |
*/
|
506 |
public function addNotificationLog($ruleId, $uniqueId, $deliveryId = null, $messageId = null)
|
507 |
{
|
508 |
$data = array(
|
509 |
+
'rule_id' => $ruleId,
|
510 |
+
'unique_id' => $uniqueId,
|
511 |
+
'sent_at' => $this->formatDate(time()),
|
512 |
'bronto_delivery_id' => $deliveryId,
|
513 |
+
'bronto_message_id' => $messageId,
|
514 |
);
|
515 |
|
516 |
$this->_getWriteAdapter()->insert($this->getTable('bronto_reminder/log'), $data);
|
520 |
/**
|
521 |
* Update failed email counter.
|
522 |
*
|
523 |
+
* @param int $ruleId
|
524 |
+
* @param int $uniqueId
|
525 |
* @return Bronto_Reminder_Model_Mysql4_Rule
|
526 |
*/
|
527 |
+
public function updateFailedEmailsCounter($ruleId, $uniqueId)
|
528 |
{
|
529 |
$this->_getWriteAdapter()->update($this->getTable('bronto_reminder/coupon'),
|
530 |
array('emails_failed' => new Zend_Db_Expr('emails_failed + 1')),
|
531 |
+
array('rule_id = ?' => $ruleId, 'unique_id = ?' => $uniqueId)
|
532 |
);
|
533 |
+
|
534 |
return $this;
|
535 |
}
|
536 |
|
549 |
$select->where('r.salesrule_id = ?', $salesruleId);
|
550 |
return $this->_getReadAdapter()->fetchOne($select);
|
551 |
}
|
552 |
+
|
553 |
/**
|
554 |
* Remove row from coupon table by column, value and store_id
|
555 |
+
*
|
556 |
* @param type $column
|
557 |
* @param type $value
|
|
|
558 |
* @return Bronto_Reminder_Model_Mysql4_Rule
|
559 |
*/
|
560 |
+
public function removeFromReminders($column, $value)
|
561 |
{
|
562 |
+
$where = "$column = $value";
|
563 |
$this->_getWriteAdapter()->delete($this->getTable('bronto_reminder/coupon'), $where);
|
564 |
+
|
565 |
return $this;
|
566 |
}
|
567 |
}
|
app/code/community/Bronto/Reminder/Model/Mysql4/Rule/Collection.php
CHANGED
@@ -7,7 +7,7 @@
|
|
7 |
*/
|
8 |
class Bronto_Reminder_Model_Mysql4_Rule_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
9 |
{
|
10 |
-
|
11 |
* Intialize collection
|
12 |
*
|
13 |
* @return void
|
@@ -20,7 +20,7 @@ class Bronto_Reminder_Model_Mysql4_Rule_Collection extends Mage_Core_Model_Mysql
|
|
20 |
/**
|
21 |
* Limit rules collection by is_active column
|
22 |
*
|
23 |
-
* @param int
|
24 |
* @return Bronto_Reminder_Model_Mysql4_Rule_Collection
|
25 |
*/
|
26 |
public function addIsActiveFilter($value)
|
@@ -32,7 +32,7 @@ class Bronto_Reminder_Model_Mysql4_Rule_Collection extends Mage_Core_Model_Mysql
|
|
32 |
/**
|
33 |
* Limit rules collection by date columns
|
34 |
*
|
35 |
-
* @param int
|
36 |
* @return Bronto_Reminder_Model_Mysql4_Rule_Collection
|
37 |
*/
|
38 |
public function addDateFilter($date)
|
@@ -47,7 +47,7 @@ class Bronto_Reminder_Model_Mysql4_Rule_Collection extends Mage_Core_Model_Mysql
|
|
47 |
/**
|
48 |
* Limit rules collection by separate rule
|
49 |
*
|
50 |
-
* @param int
|
51 |
* @return Bronto_Reminder_Model_Mysql4_Rule_Collection
|
52 |
*/
|
53 |
public function addRuleFilter($value)
|
@@ -124,11 +124,11 @@ class Bronto_Reminder_Model_Mysql4_Rule_Collection extends Mage_Core_Model_Mysql
|
|
124 |
/**
|
125 |
* Redeclared for support website id filter
|
126 |
*
|
127 |
-
* @param string
|
128 |
-
* @param mixed
|
129 |
* @return Bronto_Reminder_Model_Mysql4_Rule_Collection
|
130 |
*/
|
131 |
-
public function addFieldToFilter($field, $condition=null)
|
132 |
{
|
133 |
if ($field == 'website_ids') {
|
134 |
return $this->addWebsiteFilter($condition);
|
7 |
*/
|
8 |
class Bronto_Reminder_Model_Mysql4_Rule_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
|
9 |
{
|
10 |
+
/**
|
11 |
* Intialize collection
|
12 |
*
|
13 |
* @return void
|
20 |
/**
|
21 |
* Limit rules collection by is_active column
|
22 |
*
|
23 |
+
* @param int $value
|
24 |
* @return Bronto_Reminder_Model_Mysql4_Rule_Collection
|
25 |
*/
|
26 |
public function addIsActiveFilter($value)
|
32 |
/**
|
33 |
* Limit rules collection by date columns
|
34 |
*
|
35 |
+
* @param int $value
|
36 |
* @return Bronto_Reminder_Model_Mysql4_Rule_Collection
|
37 |
*/
|
38 |
public function addDateFilter($date)
|
47 |
/**
|
48 |
* Limit rules collection by separate rule
|
49 |
*
|
50 |
+
* @param int $value
|
51 |
* @return Bronto_Reminder_Model_Mysql4_Rule_Collection
|
52 |
*/
|
53 |
public function addRuleFilter($value)
|
124 |
/**
|
125 |
* Redeclared for support website id filter
|
126 |
*
|
127 |
+
* @param string $field
|
128 |
+
* @param mixed $condition
|
129 |
* @return Bronto_Reminder_Model_Mysql4_Rule_Collection
|
130 |
*/
|
131 |
+
public function addFieldToFilter($field, $condition = null)
|
132 |
{
|
133 |
if ($field == 'website_ids') {
|
134 |
return $this->addWebsiteFilter($condition);
|
app/code/community/Bronto/Reminder/Model/Observer.php
CHANGED
@@ -26,6 +26,15 @@ class Bronto_Reminder_Model_Observer
|
|
26 |
}
|
27 |
}
|
28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
29 |
/**
|
30 |
* Include auto coupon type
|
31 |
*
|
@@ -78,43 +87,43 @@ class Bronto_Reminder_Model_Observer
|
|
78 |
}
|
79 |
Mage::helper('bronto_reminder')->writeDebug('Done!');
|
80 |
}
|
81 |
-
|
82 |
/**
|
83 |
* If a Quote/Wishlist becomes inactive/deleted/checked-out/converted,
|
84 |
* remove from bronto_reminder_rule_coupon
|
85 |
-
*
|
86 |
* @param Varien_Event_Observer $observer
|
87 |
* @return Varien_Event_Observer
|
88 |
*/
|
89 |
public function updateReminderQueue(Varien_Event_Observer $observer)
|
90 |
{
|
91 |
-
$object
|
92 |
$filterField = false;
|
93 |
$filterValue = false;
|
94 |
-
|
95 |
if ($object instanceof Mage_Wishlist_Model_Wishlist) {
|
96 |
$wishlist = $object;
|
97 |
$collection = $wishlist->getItemCollection();
|
98 |
-
|
99 |
if (0 === $collection->count()) {
|
100 |
$filterField = 'wishlist_id';
|
101 |
$filterValue = $wishlist->getId();
|
102 |
}
|
103 |
} elseif ($object instanceof Mage_Sales_Model_Quote) {
|
104 |
$quote = $object;
|
105 |
-
|
106 |
if (0 === $quote->getIsActive() || 0 === $quote->getItemsCount()) {
|
107 |
$filterField = 'quote_id';
|
108 |
$filterValue = $quote->getId();
|
109 |
}
|
110 |
}
|
111 |
-
|
112 |
if ($filterField && $filterValue) {
|
113 |
// Quote is not active, so remove from queue if exists
|
114 |
Mage::getModel('bronto_reminder/rule')
|
115 |
-
->removeFromReminders($filterField, $filterValue
|
116 |
}
|
117 |
-
|
118 |
return $observer;
|
119 |
}
|
120 |
}
|
26 |
}
|
27 |
}
|
28 |
|
29 |
+
/**
|
30 |
+
* Observes module becoming enabled and displays message warning user to configure settings
|
31 |
+
* @param Varien_Event_Observer $observer
|
32 |
+
*/
|
33 |
+
public function watchEnableAction(Varien_Event_Observer $observer)
|
34 |
+
{
|
35 |
+
Mage::getSingleton('adminhtml/session')->addNotice(Mage::helper('bronto_reminder')->__(Mage::helper('bronto_reminder')->getModuleEnabledText()));
|
36 |
+
}
|
37 |
+
|
38 |
/**
|
39 |
* Include auto coupon type
|
40 |
*
|
87 |
}
|
88 |
Mage::helper('bronto_reminder')->writeDebug('Done!');
|
89 |
}
|
90 |
+
|
91 |
/**
|
92 |
* If a Quote/Wishlist becomes inactive/deleted/checked-out/converted,
|
93 |
* remove from bronto_reminder_rule_coupon
|
94 |
+
*
|
95 |
* @param Varien_Event_Observer $observer
|
96 |
* @return Varien_Event_Observer
|
97 |
*/
|
98 |
public function updateReminderQueue(Varien_Event_Observer $observer)
|
99 |
{
|
100 |
+
$object = $observer->getEvent()->getDataObject();
|
101 |
$filterField = false;
|
102 |
$filterValue = false;
|
103 |
+
|
104 |
if ($object instanceof Mage_Wishlist_Model_Wishlist) {
|
105 |
$wishlist = $object;
|
106 |
$collection = $wishlist->getItemCollection();
|
107 |
+
|
108 |
if (0 === $collection->count()) {
|
109 |
$filterField = 'wishlist_id';
|
110 |
$filterValue = $wishlist->getId();
|
111 |
}
|
112 |
} elseif ($object instanceof Mage_Sales_Model_Quote) {
|
113 |
$quote = $object;
|
114 |
+
|
115 |
if (0 === $quote->getIsActive() || 0 === $quote->getItemsCount()) {
|
116 |
$filterField = 'quote_id';
|
117 |
$filterValue = $quote->getId();
|
118 |
}
|
119 |
}
|
120 |
+
|
121 |
if ($filterField && $filterValue) {
|
122 |
// Quote is not active, so remove from queue if exists
|
123 |
Mage::getModel('bronto_reminder/rule')
|
124 |
+
->removeFromReminders($filterField, $filterValue);
|
125 |
}
|
126 |
+
|
127 |
return $observer;
|
128 |
}
|
129 |
}
|
app/code/community/Bronto/Reminder/Model/Rule.php
CHANGED
@@ -29,13 +29,10 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
|
|
29 |
{
|
30 |
Mage_Core_Model_Abstract::_afterLoad();
|
31 |
|
32 |
-
|
33 |
-
if (1 == $version['major']
|
34 |
-
&& (6 >= $version['minor'] || 9 == $version['minor'] || 10 == $version['minor'] || 11 == $version['minor'])
|
35 |
-
) {
|
36 |
$conditionsArr = unserialize($this->getConditionsSerialized());
|
37 |
if (!empty($conditionsArr) && is_array($conditionsArr)) {
|
38 |
-
|
39 |
}
|
40 |
}
|
41 |
|
@@ -96,7 +93,7 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
|
|
96 |
}
|
97 |
return $this->_getData('website_ids');
|
98 |
}
|
99 |
-
|
100 |
/**
|
101 |
* Get array of Registered User abandons and then Guest abandons
|
102 |
* @param int $limit
|
@@ -105,9 +102,9 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
|
|
105 |
protected function _getRecipients($limit)
|
106 |
{
|
107 |
// Pull in array of customers who abandoned their cart
|
108 |
-
return (array)
|
109 |
}
|
110 |
-
|
111 |
/**
|
112 |
* Get customer object for recipient
|
113 |
* @param array $recipient
|
@@ -116,12 +113,12 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
|
|
116 |
*/
|
117 |
protected function _getRecipientCustomer(array $recipient, $quote)
|
118 |
{
|
119 |
-
if($recipient['customer_id'] != 0) {
|
120 |
/* @var $customer Mage_Customer_Model_Customer */
|
121 |
$customer = Mage::getModel('customer/customer')->load($recipient['customer_id']);
|
122 |
} elseif ($quote) {
|
123 |
// Guest Abandon. Create Customer on the fly
|
124 |
-
$storeId
|
125 |
$customer = Mage::getModel('customer/customer')
|
126 |
->setFirstName($quote->getCustomerFirstname())
|
127 |
->setLastName($quote->getCustomerLastname())
|
@@ -130,11 +127,11 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
|
|
130 |
->setId($recipient['customer_id'])
|
131 |
->setWebsiteId(Mage::getModel('core/store')->load($storeId)->getWebsiteId());
|
132 |
}
|
133 |
-
|
134 |
if (!$customer || false === $customer->getId()) {
|
135 |
return false;
|
136 |
}
|
137 |
-
|
138 |
return $customer;
|
139 |
}
|
140 |
|
@@ -147,17 +144,18 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
|
|
147 |
public function sendReminderEmails($dontSend = false)
|
148 |
{
|
149 |
// If we aren't matching and we aren't allow to send emails, say so
|
150 |
-
if (!$dontSend && !Mage::helper('bronto_reminder')->
|
151 |
Mage::helper('bronto_reminder')->writeInfo(Mage::helper('bronto_reminder')->getNotAllowedText());
|
152 |
return $this;
|
153 |
}
|
154 |
-
|
155 |
/* @var $mail Bronto_Reminder_Model_Email_Message */
|
156 |
-
$mail
|
157 |
-
$limit
|
158 |
-
$identity
|
|
|
159 |
$this->_matchCustomers();
|
160 |
-
|
161 |
if ($dontSend) {
|
162 |
return $this;
|
163 |
}
|
@@ -165,45 +163,45 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
|
|
165 |
// Get Array of Recipients
|
166 |
$recipients = $this->_getRecipients($limit);
|
167 |
|
168 |
-
$total
|
169 |
$success = 0;
|
170 |
-
$error
|
171 |
foreach ($recipients as $recipient) {
|
172 |
$total++;
|
173 |
|
174 |
-
$quote
|
175 |
$wishlist = false;
|
176 |
-
|
177 |
// Load Store
|
178 |
/* @var $store Mage_Core_Model_Store */
|
179 |
$store = Mage::getModel('core/store')->load($recipient['store_id']);
|
180 |
-
|
181 |
// If Sending not allowed for this store
|
182 |
if (!Mage::helper('bronto_reminder')->isAllowSend($store)) {
|
183 |
$error++;
|
184 |
continue;
|
185 |
}
|
186 |
-
|
187 |
// Load Quote
|
188 |
if ($recipient['quote_id'] > 0) {
|
189 |
/* @var $quote Mage_Sales_Model_Quote */
|
190 |
$quote = Mage::getModel('sales/quote')
|
191 |
->setStoreId($store->getId())
|
192 |
-
->
|
193 |
}
|
194 |
-
|
195 |
// Load Wishlist
|
196 |
if ($recipient['wishlist_id'] > 0) {
|
197 |
/* @var $wishlist Mage_Wishlist_Model_Wishlist */
|
198 |
$wishlist = Mage::getModel('wishlist/wishlist')->load($recipient['wishlist_id']);
|
199 |
}
|
200 |
-
|
201 |
// If quote and wishlist are empty, move on to next recipient
|
202 |
if (false === $quote && false === $wishlist) {
|
203 |
$error++;
|
204 |
continue;
|
205 |
}
|
206 |
-
|
207 |
// Load Customer
|
208 |
/* @var $customer Mage_Customer_Model_Customer */
|
209 |
if (!$customer = $this->_getRecipientCustomer($recipient, $quote)) {
|
@@ -222,30 +220,30 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
|
|
222 |
if (class_exists('Mage_SalesRule_Model_Coupon', false)) {
|
223 |
/* @var $coupon Mage_SalesRule_Model_Coupon */
|
224 |
$coupon = Mage::getModel('salesrule/coupon')->load($recipient['coupon_id']);
|
225 |
-
}
|
226 |
-
|
227 |
$templateVars = array(
|
228 |
-
'store'
|
229 |
-
'customer'
|
230 |
-
'promotion_name'
|
231 |
'promotion_description' => $messageData['description'],
|
232 |
-
'coupon'
|
233 |
-
'rule'
|
234 |
-
);
|
235 |
-
|
236 |
-
|
237 |
if ($quote) {
|
238 |
$templateVars['quote'] = $quote;
|
239 |
}
|
240 |
if ($wishlist) {
|
241 |
$templateVars['wishlist'] = $wishlist;
|
242 |
}
|
243 |
-
|
244 |
Mage::helper('bronto_reminder')->writeDebug('Sending message to: ' . $customer->getEmail());
|
245 |
|
246 |
try {
|
247 |
$message = Mage::helper('bronto_reminder/message')->getMessageById($messageData['message_id'], $store->getId(), $store->getWebsiteId());
|
248 |
-
|
249 |
$mail->sendTransactional(
|
250 |
$message,
|
251 |
$identity,
|
@@ -262,22 +260,24 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
|
|
262 |
if ($mail->getSentSuccess()) {
|
263 |
Mage::helper('bronto_reminder')->writeDebug(' Success');
|
264 |
|
265 |
-
$this->_getResource()
|
266 |
-
$recipient['
|
267 |
-
|
|
|
|
|
268 |
|
269 |
$success++;
|
270 |
} else {
|
271 |
Mage::helper('bronto_reminder')->writeDebug(' Failed');
|
272 |
-
$this->_getResource()->updateFailedEmailsCounter($recipient['rule_id'], $
|
273 |
$error++;
|
274 |
}
|
275 |
}
|
276 |
|
277 |
return array(
|
278 |
-
'total'
|
279 |
'success' => $success,
|
280 |
-
'error'
|
281 |
);
|
282 |
}
|
283 |
|
@@ -288,10 +288,10 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
|
|
288 |
*/
|
289 |
protected function _matchCustomers()
|
290 |
{
|
291 |
-
$threshold
|
292 |
-
|
293 |
$currentDate = Mage::getModel('core/date')->date('Y-m-d');
|
294 |
-
$rules = $this->getCollection()
|
|
|
295 |
->addIsActiveFilter(1);
|
296 |
|
297 |
if ($ruleId = $this->getRuleId()) {
|
@@ -299,7 +299,7 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
|
|
299 |
}
|
300 |
|
301 |
foreach ($rules as $rule) {
|
302 |
-
$this->_getResource()->deactivateMatchedCustomers($rule->getId());
|
303 |
|
304 |
if ($rule->getSalesruleId()) {
|
305 |
/* @var $salesRule Mage_SalesRule_Model_Rule */
|
@@ -344,9 +344,9 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
|
|
344 |
}
|
345 |
|
346 |
/**
|
347 |
-
* @param int
|
348 |
-
* @param int
|
349 |
-
* @param int
|
350 |
* @param string $messageId
|
351 |
* @return boolean|array
|
352 |
*/
|
@@ -357,17 +357,17 @@ class Bronto_Reminder_Model_Rule extends Mage_Rule_Model_Rule
|
|
357 |
}
|
358 |
return false;
|
359 |
}
|
360 |
-
|
361 |
/**
|
362 |
* Remove row from coupon table by column, value and store_id
|
363 |
-
*
|
364 |
* @param type $column
|
365 |
* @param type $value
|
366 |
* @param type $storeId
|
367 |
* @return Bronto_Reminder_Model_Mysql4_Rule
|
368 |
*/
|
369 |
-
public function removeFromReminders($column, $value
|
370 |
{
|
371 |
-
$this->_getResource()->removeFromReminders($column, $value
|
372 |
}
|
373 |
}
|
29 |
{
|
30 |
Mage_Core_Model_Abstract::_afterLoad();
|
31 |
|
32 |
+
if (Mage::helper('bronto_verify')->isVersionMatch(Mage::getVersionInfo(), 1, array(array('<=', 6), 9, 10, 11))) {
|
|
|
|
|
|
|
33 |
$conditionsArr = unserialize($this->getConditionsSerialized());
|
34 |
if (!empty($conditionsArr) && is_array($conditionsArr)) {
|
35 |
+
$this->getConditions()->loadArray($conditionsArr);
|
36 |
}
|
37 |
}
|
38 |
|
93 |
}
|
94 |
return $this->_getData('website_ids');
|
95 |
}
|
96 |
+
|
97 |
/**
|
98 |
* Get array of Registered User abandons and then Guest abandons
|
99 |
* @param int $limit
|
102 |
protected function _getRecipients($limit)
|
103 |
{
|
104 |
// Pull in array of customers who abandoned their cart
|
105 |
+
return (array)$this->_getResource()->getCustomersForNotification($limit, $this->getRuleId());
|
106 |
}
|
107 |
+
|
108 |
/**
|
109 |
* Get customer object for recipient
|
110 |
* @param array $recipient
|
113 |
*/
|
114 |
protected function _getRecipientCustomer(array $recipient, $quote)
|
115 |
{
|
116 |
+
if ($recipient['customer_id'] != 0) {
|
117 |
/* @var $customer Mage_Customer_Model_Customer */
|
118 |
$customer = Mage::getModel('customer/customer')->load($recipient['customer_id']);
|
119 |
} elseif ($quote) {
|
120 |
// Guest Abandon. Create Customer on the fly
|
121 |
+
$storeId = $recipient['store_id'];
|
122 |
$customer = Mage::getModel('customer/customer')
|
123 |
->setFirstName($quote->getCustomerFirstname())
|
124 |
->setLastName($quote->getCustomerLastname())
|
127 |
->setId($recipient['customer_id'])
|
128 |
->setWebsiteId(Mage::getModel('core/store')->load($storeId)->getWebsiteId());
|
129 |
}
|
130 |
+
|
131 |
if (!$customer || false === $customer->getId()) {
|
132 |
return false;
|
133 |
}
|
134 |
+
|
135 |
return $customer;
|
136 |
}
|
137 |
|
144 |
public function sendReminderEmails($dontSend = false)
|
145 |
{
|
146 |
// If we aren't matching and we aren't allow to send emails, say so
|
147 |
+
if (!$dontSend && !Mage::helper('bronto_reminder')->isAllowSendForAny() || !Mage::helper('bronto_reminder')->isEnabledForAny()) {
|
148 |
Mage::helper('bronto_reminder')->writeInfo(Mage::helper('bronto_reminder')->getNotAllowedText());
|
149 |
return $this;
|
150 |
}
|
151 |
+
|
152 |
/* @var $mail Bronto_Reminder_Model_Email_Message */
|
153 |
+
$mail = Mage::getModel('bronto_reminder/email_message');
|
154 |
+
$limit = Mage::helper('bronto_reminder')->getOneRunLimit();
|
155 |
+
$identity = Mage::helper('bronto_reminder')->getEmailIdentity();
|
156 |
+
|
157 |
$this->_matchCustomers();
|
158 |
+
|
159 |
if ($dontSend) {
|
160 |
return $this;
|
161 |
}
|
163 |
// Get Array of Recipients
|
164 |
$recipients = $this->_getRecipients($limit);
|
165 |
|
166 |
+
$total = 0;
|
167 |
$success = 0;
|
168 |
+
$error = 0;
|
169 |
foreach ($recipients as $recipient) {
|
170 |
$total++;
|
171 |
|
172 |
+
$quote = false;
|
173 |
$wishlist = false;
|
174 |
+
|
175 |
// Load Store
|
176 |
/* @var $store Mage_Core_Model_Store */
|
177 |
$store = Mage::getModel('core/store')->load($recipient['store_id']);
|
178 |
+
|
179 |
// If Sending not allowed for this store
|
180 |
if (!Mage::helper('bronto_reminder')->isAllowSend($store)) {
|
181 |
$error++;
|
182 |
continue;
|
183 |
}
|
184 |
+
|
185 |
// Load Quote
|
186 |
if ($recipient['quote_id'] > 0) {
|
187 |
/* @var $quote Mage_Sales_Model_Quote */
|
188 |
$quote = Mage::getModel('sales/quote')
|
189 |
->setStoreId($store->getId())
|
190 |
+
->loadActive($recipient['quote_id']);
|
191 |
}
|
192 |
+
|
193 |
// Load Wishlist
|
194 |
if ($recipient['wishlist_id'] > 0) {
|
195 |
/* @var $wishlist Mage_Wishlist_Model_Wishlist */
|
196 |
$wishlist = Mage::getModel('wishlist/wishlist')->load($recipient['wishlist_id']);
|
197 |
}
|
198 |
+
|
199 |
// If quote and wishlist are empty, move on to next recipient
|
200 |
if (false === $quote && false === $wishlist) {
|
201 |
$error++;
|
202 |
continue;
|
203 |
}
|
204 |
+
|
205 |
// Load Customer
|
206 |
/* @var $customer Mage_Customer_Model_Customer */
|
207 |
if (!$customer = $this->_getRecipientCustomer($recipient, $quote)) {
|
220 |
if (class_exists('Mage_SalesRule_Model_Coupon', false)) {
|
221 |
/* @var $coupon Mage_SalesRule_Model_Coupon */
|
222 |
$coupon = Mage::getModel('salesrule/coupon')->load($recipient['coupon_id']);
|
223 |
+
}
|
224 |
+
|
225 |
$templateVars = array(
|
226 |
+
'store' => $store,
|
227 |
+
'customer' => $customer,
|
228 |
+
'promotion_name' => $messageData['label'],
|
229 |
'promotion_description' => $messageData['description'],
|
230 |
+
'coupon' => $coupon,
|
231 |
+
'rule' => $this,
|
232 |
+
);
|
233 |
+
|
234 |
+
|
235 |
if ($quote) {
|
236 |
$templateVars['quote'] = $quote;
|
237 |
}
|
238 |
if ($wishlist) {
|
239 |
$templateVars['wishlist'] = $wishlist;
|
240 |
}
|
241 |
+
|
242 |
Mage::helper('bronto_reminder')->writeDebug('Sending message to: ' . $customer->getEmail());
|
243 |
|
244 |
try {
|
245 |
$message = Mage::helper('bronto_reminder/message')->getMessageById($messageData['message_id'], $store->getId(), $store->getWebsiteId());
|
246 |
+
$mail->setTemplateSendType('transactional');
|
247 |
$mail->sendTransactional(
|
248 |
$message,
|
249 |
$identity,
|
260 |
if ($mail->getSentSuccess()) {
|
261 |
Mage::helper('bronto_reminder')->writeDebug(' Success');
|
262 |
|
263 |
+
$this->_getResource()
|
264 |
+
->deactivateMatchedCustomer($recipient['unique_id'])
|
265 |
+
->addNotificationLog(
|
266 |
+
$recipient['rule_id'], $recipient['unique_id'], $mail->getLastDeliveryId(), $messageData['message_id']
|
267 |
+
);
|
268 |
|
269 |
$success++;
|
270 |
} else {
|
271 |
Mage::helper('bronto_reminder')->writeDebug(' Failed');
|
272 |
+
$this->_getResource()->updateFailedEmailsCounter($recipient['rule_id'], $recipient['unique_id']);
|
273 |
$error++;
|
274 |
}
|
275 |
}
|
276 |
|
277 |
return array(
|
278 |
+
'total' => $total,
|
279 |
'success' => $success,
|
280 |
+
'error' => $error,
|
281 |
);
|
282 |
}
|
283 |
|
288 |
*/
|
289 |
protected function _matchCustomers()
|
290 |
{
|
291 |
+
$threshold = Mage::helper('bronto_reminder')->getSendFailureThreshold();
|
|
|
292 |
$currentDate = Mage::getModel('core/date')->date('Y-m-d');
|
293 |
+
$rules = $this->getCollection()
|
294 |
+
->addDateFilter($currentDate)
|
295 |
->addIsActiveFilter(1);
|
296 |
|
297 |
if ($ruleId = $this->getRuleId()) {
|
299 |
}
|
300 |
|
301 |
foreach ($rules as $rule) {
|
302 |
+
// $this->_getResource()->deactivateMatchedCustomers($rule->getId());
|
303 |
|
304 |
if ($rule->getSalesruleId()) {
|
305 |
/* @var $salesRule Mage_SalesRule_Model_Rule */
|
344 |
}
|
345 |
|
346 |
/**
|
347 |
+
* @param int $ruleId
|
348 |
+
* @param int $storeId
|
349 |
+
* @param int $customerId
|
350 |
* @param string $messageId
|
351 |
* @return boolean|array
|
352 |
*/
|
357 |
}
|
358 |
return false;
|
359 |
}
|
360 |
+
|
361 |
/**
|
362 |
* Remove row from coupon table by column, value and store_id
|
363 |
+
*
|
364 |
* @param type $column
|
365 |
* @param type $value
|
366 |
* @param type $storeId
|
367 |
* @return Bronto_Reminder_Model_Mysql4_Rule
|
368 |
*/
|
369 |
+
public function removeFromReminders($column, $value)
|
370 |
{
|
371 |
+
$this->_getResource()->removeFromReminders($column, $value);
|
372 |
}
|
373 |
}
|
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart.php
CHANGED
@@ -80,8 +80,8 @@ class Bronto_Reminder_Model_Rule_Condition_Cart extends Bronto_Reminder_Model_Co
|
|
80 |
public function loadAttributeOptions()
|
81 |
{
|
82 |
$this->setAttributeOption(array(
|
83 |
-
'days'
|
84 |
-
'hours'
|
85 |
'minutes' => Mage::helper('bronto_reminder')->__('minutes')
|
86 |
));
|
87 |
return $this;
|
@@ -95,12 +95,12 @@ class Bronto_Reminder_Model_Rule_Condition_Cart extends Bronto_Reminder_Model_Co
|
|
95 |
public function asHtml()
|
96 |
{
|
97 |
return $this->getTypeElementHtml()
|
98 |
-
|
99 |
// $this->getOperatorElementHtml(),
|
100 |
-
|
101 |
-
|
102 |
-
|
103 |
-
|
104 |
}
|
105 |
|
106 |
/**
|
@@ -112,89 +112,40 @@ class Bronto_Reminder_Model_Rule_Condition_Cart extends Bronto_Reminder_Model_Co
|
|
112 |
*/
|
113 |
protected function _prepareConditionsSql($rule, $website)
|
114 |
{
|
115 |
-
$interval = Mage::helper('bronto_reminder')->getCronInterval();
|
116 |
$attributeValue = strtolower($this->getAttribute());
|
117 |
-
|
118 |
-
|
119 |
-
case 'hours':
|
120 |
-
$currentDateStart = now(false);
|
121 |
-
$durationSql = 'HOUR';
|
122 |
-
$conditionValue = (int) $this->getValue();
|
123 |
-
if ($conditionValue < 1) {
|
124 |
-
Mage::throwException(Mage::helper('bronto_reminder')->__('Root shopping cart condition should have %s value at least 1.', $attributeValue));
|
125 |
-
}
|
126 |
-
break;
|
127 |
-
case 'minutes':
|
128 |
-
$currentDateStart = now(false);
|
129 |
-
$durationSql = 'MINUTE';
|
130 |
-
$conditionValue = (int) $this->getValue();
|
131 |
-
if (!Mage::helper('bronto_common')->isTestModeEnabled()) {
|
132 |
-
if ($conditionValue < 30) {
|
133 |
-
Mage::throwException(Mage::helper('bronto_reminder')->__('Root shopping cart condition should have %s value at least 30.', $attributeValue));
|
134 |
-
}
|
135 |
-
}
|
136 |
-
break;
|
137 |
-
case 'days':
|
138 |
-
default:
|
139 |
-
$currentDateStart = now(false);
|
140 |
-
$durationSql = 'DAY';
|
141 |
-
$conditionValue = (int) $this->getValue();
|
142 |
-
if ($conditionValue < 1) {
|
143 |
-
Mage::throwException(Mage::helper('bronto_reminder')->__('Root shopping cart condition should have %s value at least 1.', $attributeValue));
|
144 |
-
}
|
145 |
-
break;
|
146 |
-
}
|
147 |
|
148 |
if ($conditionValue <= 0) {
|
149 |
Mage::throwException(Mage::helper('bronto_reminder')->__('Root shopping cart condition should have %s value greater than 0.', $attributeValue));
|
150 |
}
|
151 |
|
152 |
$table = $this->getResource()->getTable('sales/quote');
|
153 |
-
$operator = '='; //$this->getResource()->getSqlOperator($this->getOperator());
|
154 |
|
155 |
$select = $this->getResource()->createSelect();
|
156 |
$select->from(array('quote' => $table), array(new Zend_Db_Expr(1)));
|
157 |
|
158 |
$this->_limitByStoreWebsite($select, $website, 'quote.store_id');
|
159 |
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
|
165 |
-
|
166 |
-
$select->where("STR_TO_DATE('{$currentDateStart}',GET_FORMAT(DATETIME,'ISO')) >= DATE_ADD(quote.updated_at, INTERVAL ? HOUR)", $conditionValue);
|
167 |
-
$select->where("STR_TO_DATE('{$currentDateStart}',GET_FORMAT(DATETIME,'ISO')) <= DATE_ADD(quote.updated_at, INTERVAL ? MINUTE)", $conditionValueInMinutes + $interval);
|
168 |
-
break;
|
169 |
-
case 'minutes':
|
170 |
-
// cart + X minute(s) <= [now] <= cart + X minute(s) + interval minute(s)
|
171 |
-
// 60 minutes: cart + 60 minutes <= [now] <= cart + 75 minutes
|
172 |
-
$select->where("STR_TO_DATE('{$currentDateStart}',GET_FORMAT(DATETIME,'ISO')) >= DATE_ADD(quote.updated_at, INTERVAL ? MINUTE)", $conditionValue);
|
173 |
-
$select->where("STR_TO_DATE('{$currentDateStart}',GET_FORMAT(DATETIME,'ISO')) <= DATE_ADD(quote.updated_at, INTERVAL ? MINUTE)", $conditionValue + $interval);
|
174 |
-
break;
|
175 |
-
case 'days':
|
176 |
-
default:
|
177 |
-
// cart + X day(s) <= [now] <= cart + (X day(s) * 1440) + interval minute(s)
|
178 |
-
// 1 day: cart + 1 day <= [now] <= cart + 1455 minutes
|
179 |
-
$conditionValueInMinutes = $conditionValue * 1440;
|
180 |
-
$select->where("STR_TO_DATE('{$currentDateStart}',GET_FORMAT(DATETIME,'ISO')) >= DATE_ADD(quote.updated_at, INTERVAL ? DAY)", $conditionValue);
|
181 |
-
$select->where("STR_TO_DATE('{$currentDateStart}',GET_FORMAT(DATETIME,'ISO')) <= DATE_ADD(quote.updated_at, INTERVAL ? MINUTE)", $conditionValueInMinutes + $interval);
|
182 |
-
break;
|
183 |
-
}
|
184 |
} else {
|
185 |
-
if (
|
186 |
-
|
187 |
-
$currentDateStart = now();
|
188 |
-
}
|
189 |
-
} elseif ($operator == '<=') {
|
190 |
-
if (!$conditionValue > 0) {
|
191 |
-
$currentDateStart = now();
|
192 |
-
}
|
193 |
}
|
194 |
-
|
195 |
-
|
|
|
196 |
}
|
197 |
|
|
|
|
|
|
|
|
|
198 |
$select->where('quote.is_active = 1');
|
199 |
$select->where('quote.items_count > 0');
|
200 |
$select->where('quote.entity_id = root.quote_id');
|
@@ -212,10 +163,10 @@ class Bronto_Reminder_Model_Rule_Condition_Cart extends Bronto_Reminder_Model_Co
|
|
212 |
*/
|
213 |
public function getConditionsSql($rule, $website)
|
214 |
{
|
215 |
-
$select
|
216 |
-
$required
|
217 |
$aggregator = ($this->getAggregator() == 'all') ? ' AND ' : ' OR ';
|
218 |
-
$operator
|
219 |
$conditions = array();
|
220 |
|
221 |
foreach ($this->getConditions() as $condition) {
|
@@ -227,7 +178,7 @@ class Bronto_Reminder_Model_Rule_Condition_Cart extends Bronto_Reminder_Model_Co
|
|
227 |
if (!empty($conditions)) {
|
228 |
$select->where(implode($aggregator, $conditions));
|
229 |
}
|
230 |
-
|
231 |
return $select;
|
232 |
}
|
233 |
}
|
80 |
public function loadAttributeOptions()
|
81 |
{
|
82 |
$this->setAttributeOption(array(
|
83 |
+
'days' => Mage::helper('bronto_reminder')->__('days'),
|
84 |
+
'hours' => Mage::helper('bronto_reminder')->__('hours'),
|
85 |
'minutes' => Mage::helper('bronto_reminder')->__('minutes')
|
86 |
));
|
87 |
return $this;
|
95 |
public function asHtml()
|
96 |
{
|
97 |
return $this->getTypeElementHtml()
|
98 |
+
. Mage::helper('bronto_reminder')->__('Shopping cart is not empty and abandoned for %s %s and %s of these conditions match:',
|
99 |
// $this->getOperatorElementHtml(),
|
100 |
+
$this->getValueElementHtml(),
|
101 |
+
$this->getAttributeElementHtml(),
|
102 |
+
$this->getAggregatorElement()->getHtml())
|
103 |
+
. $this->getRemoveLinkHtml();
|
104 |
}
|
105 |
|
106 |
/**
|
112 |
*/
|
113 |
protected function _prepareConditionsSql($rule, $website)
|
114 |
{
|
|
|
115 |
$attributeValue = strtolower($this->getAttribute());
|
116 |
+
$conditionValue = (int)$this->getValue();
|
117 |
+
$requiredValue = 1;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
118 |
|
119 |
if ($conditionValue <= 0) {
|
120 |
Mage::throwException(Mage::helper('bronto_reminder')->__('Root shopping cart condition should have %s value greater than 0.', $attributeValue));
|
121 |
}
|
122 |
|
123 |
$table = $this->getResource()->getTable('sales/quote');
|
|
|
124 |
|
125 |
$select = $this->getResource()->createSelect();
|
126 |
$select->from(array('quote' => $table), array(new Zend_Db_Expr(1)));
|
127 |
|
128 |
$this->_limitByStoreWebsite($select, $website, 'quote.store_id');
|
129 |
|
130 |
+
|
131 |
+
// Handle date and interval conditions
|
132 |
+
if ('hours' == $attributeValue) {
|
133 |
+
$conditionValue *= 60;
|
134 |
+
} elseif ('days' == $attributeValue) {
|
135 |
+
$conditionValue *= 1440;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
136 |
} else {
|
137 |
+
if (!Mage::helper('bronto_common')->isTestModeEnabled()) {
|
138 |
+
$requiredValue = 30;
|
|
|
|
|
|
|
|
|
|
|
|
|
139 |
}
|
140 |
+
}
|
141 |
+
if ($conditionValue < $requiredValue) {
|
142 |
+
Mage::throwException(Mage::helper('bronto_reminder')->__('Root shopping cart condition should have %s value at least %d.', $attributeValue, $requiredValue));
|
143 |
}
|
144 |
|
145 |
+
$curDate = now();
|
146 |
+
$select->where("quote.updated_at BETWEEN DATE_SUB('$curDate', INTERVAL (?+:interval) MINUTE) AND DATE_SUB('$curDate', INTERVAL ? MINUTE)", $conditionValue);
|
147 |
+
|
148 |
+
// Handle standard
|
149 |
$select->where('quote.is_active = 1');
|
150 |
$select->where('quote.items_count > 0');
|
151 |
$select->where('quote.entity_id = root.quote_id');
|
163 |
*/
|
164 |
public function getConditionsSql($rule, $website)
|
165 |
{
|
166 |
+
$select = $this->_prepareConditionsSql($rule, $website);
|
167 |
+
$required = $this->_getRequiredValidation();
|
168 |
$aggregator = ($this->getAggregator() == 'all') ? ' AND ' : ' OR ';
|
169 |
+
$operator = $required ? '=' : '<>';
|
170 |
$conditions = array();
|
171 |
|
172 |
foreach ($this->getConditions() as $condition) {
|
178 |
if (!empty($conditions)) {
|
179 |
$select->where(implode($aggregator, $conditions));
|
180 |
}
|
181 |
+
|
182 |
return $select;
|
183 |
}
|
184 |
}
|
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Amount.php
CHANGED
@@ -53,9 +53,9 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Amount extends Bronto_Reminder_M
|
|
53 |
public function asHtml()
|
54 |
{
|
55 |
return $this->getTypeElementHtml()
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
}
|
60 |
|
61 |
/**
|
53 |
public function asHtml()
|
54 |
{
|
55 |
return $this->getTypeElementHtml()
|
56 |
+
. Mage::helper('bronto_reminder')->__('Shopping cart %s amount %s %s:',
|
57 |
+
$this->getAttributeElementHtml(), $this->getOperatorElementHtml(), $this->getValueElementHtml())
|
58 |
+
. $this->getRemoveLinkHtml();
|
59 |
}
|
60 |
|
61 |
/**
|
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Attributes.php
CHANGED
@@ -55,9 +55,9 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Attributes extends Bronto_Remind
|
|
55 |
public function asHtml()
|
56 |
{
|
57 |
return $this->getTypeElementHtml()
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
}
|
62 |
|
63 |
/**
|
55 |
public function asHtml()
|
56 |
{
|
57 |
return $this->getTypeElementHtml()
|
58 |
+
. Mage::helper('bronto_reminder')->__('Item %s %s %s:',
|
59 |
+
$this->getAttributeElementHtml(), $this->getOperatorElementHtml(), $this->getValueElementHtml())
|
60 |
+
. $this->getRemoveLinkHtml();
|
61 |
}
|
62 |
|
63 |
/**
|
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Couponcode.php
CHANGED
@@ -33,9 +33,9 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Couponcode extends Bronto_Remind
|
|
33 |
public function asHtml()
|
34 |
{
|
35 |
return $this->getTypeElementHtml()
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
}
|
40 |
|
41 |
/**
|
33 |
public function asHtml()
|
34 |
{
|
35 |
return $this->getTypeElementHtml()
|
36 |
+
. Mage::helper('bronto_reminder')->__('Shopping cart %s a coupon applied',
|
37 |
+
$this->getValueElementHtml())
|
38 |
+
. $this->getRemoveLinkHtml();
|
39 |
}
|
40 |
|
41 |
/**
|
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Itemsquantity.php
CHANGED
@@ -38,9 +38,9 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Itemsquantity extends Bronto_Rem
|
|
38 |
public function asHtml()
|
39 |
{
|
40 |
return $this->getTypeElementHtml()
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
}
|
45 |
|
46 |
/**
|
38 |
public function asHtml()
|
39 |
{
|
40 |
return $this->getTypeElementHtml()
|
41 |
+
. Mage::helper('bronto_reminder')->__('Number of shopping cart line items %s %s:',
|
42 |
+
$this->getOperatorElementHtml(), $this->getValueElementHtml())
|
43 |
+
. $this->getRemoveLinkHtml();
|
44 |
}
|
45 |
|
46 |
/**
|
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Sku.php
CHANGED
@@ -33,9 +33,9 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Sku extends Bronto_Reminder_Mode
|
|
33 |
public function asHtml()
|
34 |
{
|
35 |
return $this->getTypeElementHtml()
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
}
|
40 |
|
41 |
/**
|
33 |
public function asHtml()
|
34 |
{
|
35 |
return $this->getTypeElementHtml()
|
36 |
+
. Mage::helper('bronto_reminder')->__('Item SKU %s %s ',
|
37 |
+
$this->getOperatorElementHtml(), $this->getValueElementHtml())
|
38 |
+
. $this->getRemoveLinkHtml();
|
39 |
}
|
40 |
|
41 |
/**
|
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Storeview.php
CHANGED
@@ -33,9 +33,9 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Storeview extends Bronto_Reminde
|
|
33 |
public function asHtml()
|
34 |
{
|
35 |
return $this->getTypeElementHtml()
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
}
|
40 |
|
41 |
/**
|
33 |
public function asHtml()
|
34 |
{
|
35 |
return $this->getTypeElementHtml()
|
36 |
+
. Mage::helper('bronto_reminder')->__('Item was added to shopping cart %s store view %s',
|
37 |
+
$this->getOperatorElementHtml(), $this->getValueElementHtml())
|
38 |
+
. $this->getRemoveLinkHtml();
|
39 |
}
|
40 |
|
41 |
/**
|
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Subselection.php
CHANGED
@@ -56,10 +56,10 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Subselection extends Bronto_Remi
|
|
56 |
public function asHtml()
|
57 |
{
|
58 |
return $this->getTypeElementHtml()
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
}
|
64 |
|
65 |
/**
|
56 |
public function asHtml()
|
57 |
{
|
58 |
return $this->getTypeElementHtml()
|
59 |
+
. Mage::helper('bronto_reminder')->__('If an item is %s in the shopping cart with %s of these conditions match:',
|
60 |
+
$this->getOperatorElementHtml(),
|
61 |
+
$this->getAggregatorElement()->getHtml())
|
62 |
+
. $this->getRemoveLinkHtml();
|
63 |
}
|
64 |
|
65 |
/**
|
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Totalquantity.php
CHANGED
@@ -38,9 +38,9 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Totalquantity extends Bronto_Rem
|
|
38 |
public function asHtml()
|
39 |
{
|
40 |
return $this->getTypeElementHtml()
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
}
|
45 |
|
46 |
/**
|
38 |
public function asHtml()
|
39 |
{
|
40 |
return $this->getTypeElementHtml()
|
41 |
+
. Mage::helper('bronto_reminder')->__('Total shopping cart items quantity %s %s:',
|
42 |
+
$this->getOperatorElementHtml(), $this->getValueElementHtml())
|
43 |
+
. $this->getRemoveLinkHtml();
|
44 |
}
|
45 |
|
46 |
/**
|
app/code/community/Bronto/Reminder/Model/Rule/Condition/Cart/Virtual.php
CHANGED
@@ -33,9 +33,9 @@ class Bronto_Reminder_Model_Rule_Condition_Cart_Virtual extends Bronto_Reminder_
|
|
33 |
public function asHtml()
|
34 |
{
|
35 |
return $this->getTypeElementHtml()
|
36 |
-
|
37 |
-
|
38 |
-
|
39 |
}
|
40 |
|
41 |
/**
|
33 |
public function asHtml()
|
34 |
{
|
35 |
return $this->getTypeElementHtml()
|
36 |
+
. Mage::helper('bronto_reminder')->__('Shopping cart %s only virtual items',
|
37 |
+
$this->getValueElementHtml())
|
38 |
+
. $this->getRemoveLinkHtml();
|
39 |
}
|
40 |
|
41 |
/**
|
app/code/community/Bronto/Reminder/Model/Rule/Condition/Combine/Root.php
CHANGED
@@ -16,160 +16,161 @@ class Bronto_Reminder_Model_Rule_Condition_Combine_Root extends Bronto_Reminder_
|
|
16 |
/**
|
17 |
* Prepare base select with limitation by customer
|
18 |
*
|
19 |
-
* @param null|Bronto_Reminder_Model_Rule
|
20 |
* @param int | Zend_Db_Expr $website
|
21 |
* @return Varien_Db_Select
|
22 |
*/
|
23 |
protected function _prepareConditionsSql($rule, $website)
|
24 |
{
|
25 |
$select = $this->getResource()->createSelect();
|
26 |
-
|
27 |
$conditionTypes = array();
|
28 |
foreach ($this->getConditions() as $condition) {
|
29 |
-
$type = explode('_', $condition->getType());
|
30 |
$conditionTypes[] = array_pop($type);
|
31 |
}
|
32 |
-
|
33 |
// Define Tables
|
34 |
-
$customerTable
|
35 |
-
$quoteTable
|
36 |
-
$storeTable
|
37 |
-
$logQuoteTable
|
38 |
-
$logCustomerTable
|
39 |
-
$wishlistTable
|
40 |
$wishlistItemTable = $this->getResource()->getTable('wishlist/item');
|
41 |
|
42 |
// If conditions are based on Cart or Wishlist
|
43 |
-
if (in_array('cart', $conditionTypes) || in_array('wishlist', $conditionTypes)) {
|
44 |
$subselect = $this->getResource()->createSelect();
|
45 |
-
|
46 |
// If conditions are based on Cart and Wishlist
|
47 |
if (in_array('cart', $conditionTypes) && in_array('wishlist', $conditionTypes)) {
|
48 |
$groupby = array('quote_id', 'wishlist_id');
|
49 |
-
|
|
|
50 |
$subselect->from(
|
51 |
-
array('quote' => $quoteTable),
|
52 |
array(
|
53 |
'quote_id' => 'entity_id',
|
54 |
'customer_id' => new Zend_Db_Expr('IF(quote.customer_id IS NULL, IF(wishlist.customer_id IS NULL, 0, wishlist.customer_id), quote.customer_id)')
|
55 |
)
|
56 |
)
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
$subselect->joinLeft(
|
62 |
array('log' => $logQuoteTable),
|
63 |
'log.quote_id=quote.entity_id',
|
64 |
array('visitor_id' => 'log.visitor_id')
|
65 |
);
|
66 |
-
|
67 |
$subselect->joinInner(
|
68 |
-
array('store' => $storeTable),
|
69 |
-
'quote.store_id=store.store_id',
|
70 |
array('store_id' => 'store.store_id')
|
71 |
)->where('store.website_id=?', $website);
|
72 |
-
|
73 |
$subselect->joinLeft(
|
74 |
-
array('wishlist' => $wishlistTable),
|
75 |
-
'wishlist.customer_id=quote.customer_id',
|
76 |
array('wishlist_id' => 'wishlist.wishlist_id')
|
77 |
);
|
78 |
-
|
79 |
$subselect->joinLeft(
|
80 |
-
array('wishlist_item' => $wishlistItemTable),
|
81 |
-
'wishlist_item.wishlist_id=wishlist.wishlist_id',
|
82 |
array()
|
83 |
);
|
84 |
-
|
85 |
-
}
|
86 |
-
// If conditions are based on Cart Only
|
87 |
elseif (in_array('cart', $conditionTypes)) {
|
88 |
$groupby = 'quote_id';
|
89 |
-
|
|
|
90 |
$subselect->from(
|
91 |
-
array('quote' => $quoteTable),
|
92 |
array(
|
93 |
'quote_id' => 'entity_id',
|
94 |
'customer_id' => new Zend_Db_Expr('IF(quote.customer_id IS NULL, 0, quote.customer_id)'),
|
95 |
'wishlist_id' => new Zend_Db_Expr('0'),
|
96 |
)
|
97 |
)
|
98 |
-
|
99 |
-
|
100 |
-
|
101 |
-
|
102 |
$subselect->joinLeft(
|
103 |
array('log' => $logQuoteTable),
|
104 |
'log.quote_id=quote.entity_id',
|
105 |
array('visitor_id' => 'log.visitor_id')
|
106 |
);
|
107 |
-
|
108 |
$subselect->joinInner(
|
109 |
-
array('store' => $storeTable),
|
110 |
-
'quote.store_id=store.store_id',
|
111 |
array('store_id' => 'store.store_id')
|
112 |
)->where('store.website_id=?', $website);
|
113 |
-
}
|
114 |
-
// If conditions are based on Wishlist Only
|
115 |
elseif (in_array('wishlist', $conditionTypes)) {
|
116 |
$groupby = 'wishlist_id';
|
117 |
-
|
|
|
118 |
$subselect->from(
|
119 |
-
array('customer' => $customerTable),
|
120 |
array(
|
121 |
'quote_id' => new Zend_Db_Expr('0'),
|
122 |
'customer_id' => 'entity_id',
|
123 |
)
|
124 |
);
|
125 |
-
|
126 |
$subselect->joinLeft(
|
127 |
-
array('wishlist' => $wishlistTable),
|
128 |
-
'wishlist.customer_id=customer.entity_id',
|
129 |
array('wishlist_id' => 'wishlist.wishlist_id')
|
130 |
);
|
131 |
-
|
132 |
$subselect->joinLeft(
|
133 |
-
array('wishlist_item' => $wishlistItemTable),
|
134 |
-
'wishlist_item.wishlist_id=wishlist.wishlist_id',
|
135 |
array()
|
136 |
);
|
137 |
-
|
138 |
$subselect->joinLeft(
|
139 |
array('log' => $logCustomerTable),
|
140 |
'log.customer_id=customer.entity_id',
|
141 |
array('visitor_id' => 'log.visitor_id')
|
142 |
);
|
143 |
-
|
144 |
$subselect->joinInner(
|
145 |
-
array('store' => $storeTable),
|
146 |
-
'wishlist_item.store_id=store.store_id',
|
147 |
array('store_id' => 'store.store_id')
|
148 |
)->where('store.website_id=?', $website);
|
149 |
}
|
150 |
-
|
151 |
// Set main select to pull use subselect as root and pull required fields
|
152 |
$select->from(array('root' => $subselect), array(
|
153 |
'unique_id' => new Zend_Db_Expr(
|
154 |
"CONCAT(:rule_id, '-', `root`.`store_id`, '-', IF(`root`.`customer_id` IS NULL, 0, `root`.`customer_id`), '-', IF(`root`.`visitor_id` IS NULL, 0, `root`.`visitor_id`))"
|
155 |
),
|
156 |
-
'store_id',
|
157 |
-
'customer_id' => new Zend_Db_Expr("IF(`root`.`customer_id` IS NULL, 0, `root`.`customer_id`)"),
|
158 |
-
'quote_id'
|
159 |
-
'wishlist_id' => new Zend_Db_Expr("IF(`root`.`wishlist_id` IS NULL, 0, `root`.`wishlist_id`)"),
|
160 |
-
'visitor_id'
|
161 |
))
|
162 |
-
|
163 |
}
|
164 |
-
|
165 |
$couponTable = $this->getResource()->getTable('bronto_reminder/coupon');
|
166 |
-
|
167 |
$select->joinLeft(
|
168 |
array('c' => $couponTable),
|
169 |
-
|
170 |
array('c.coupon_id')
|
171 |
);
|
172 |
-
|
173 |
return $select;
|
174 |
}
|
175 |
|
@@ -177,31 +178,30 @@ class Bronto_Reminder_Model_Rule_Condition_Combine_Root extends Bronto_Reminder_
|
|
177 |
* Get SQL select.
|
178 |
* Rewrited for cover root conditions combination with additional condition by customer
|
179 |
*
|
180 |
-
* @param null|Bronto_Reminder_Model_Rule
|
181 |
-
* @param int
|
182 |
* @return Varien_Db_Select
|
183 |
*/
|
184 |
public function getConditionsSql($rule, $website)
|
185 |
{
|
186 |
-
$select
|
187 |
-
$required
|
188 |
$aggregator = ($this->getAggregator() == 'all') ? ' AND ' : ' OR ';
|
189 |
-
$operator
|
190 |
$conditions = array();
|
191 |
-
|
192 |
foreach ($this->getConditions() as $condition) {
|
193 |
if ($sql = $condition->getConditionsSql($rule, $website)) {
|
194 |
$conditions[] = "(IFNULL(($sql), 0) {$operator} 1)";
|
195 |
}
|
196 |
}
|
197 |
-
|
198 |
if (!empty($conditions)) {
|
199 |
$select->where(implode($aggregator, $conditions));
|
200 |
-
}
|
201 |
-
else {
|
202 |
$select->reset();
|
203 |
}
|
204 |
-
|
205 |
return $select;
|
206 |
}
|
207 |
}
|
16 |
/**
|
17 |
* Prepare base select with limitation by customer
|
18 |
*
|
19 |
+
* @param null|Bronto_Reminder_Model_Rule $rule
|
20 |
* @param int | Zend_Db_Expr $website
|
21 |
* @return Varien_Db_Select
|
22 |
*/
|
23 |
protected function _prepareConditionsSql($rule, $website)
|
24 |
{
|
25 |
$select = $this->getResource()->createSelect();
|
26 |
+
|
27 |
$conditionTypes = array();
|
28 |
foreach ($this->getConditions() as $condition) {
|
29 |
+
$type = explode('_', $condition->getType());
|
30 |
$conditionTypes[] = array_pop($type);
|
31 |
}
|
32 |
+
|
33 |
// Define Tables
|
34 |
+
$customerTable = $this->getResource()->getTable('customer/entity');
|
35 |
+
$quoteTable = $this->getResource()->getTable('sales/quote');
|
36 |
+
$storeTable = $this->getResource()->getTable('core/store');
|
37 |
+
$logQuoteTable = Mage::getResourceSingleton('log/log')->getTable('log/quote_table');
|
38 |
+
$logCustomerTable = Mage::getResourceSingleton('log/log')->getTable('log/customer');
|
39 |
+
$wishlistTable = $this->getResource()->getTable('wishlist/wishlist');
|
40 |
$wishlistItemTable = $this->getResource()->getTable('wishlist/item');
|
41 |
|
42 |
// If conditions are based on Cart or Wishlist
|
43 |
+
if (in_array('cart', $conditionTypes) || in_array('wishlist', $conditionTypes)) {
|
44 |
$subselect = $this->getResource()->createSelect();
|
45 |
+
|
46 |
// If conditions are based on Cart and Wishlist
|
47 |
if (in_array('cart', $conditionTypes) && in_array('wishlist', $conditionTypes)) {
|
48 |
$groupby = array('quote_id', 'wishlist_id');
|
49 |
+
$cMatch = 'c.quote_id=root.quote_id AND c.wishlist_id=root.wishlist_id';
|
50 |
+
|
51 |
$subselect->from(
|
52 |
+
array('quote' => $quoteTable),
|
53 |
array(
|
54 |
'quote_id' => 'entity_id',
|
55 |
'customer_id' => new Zend_Db_Expr('IF(quote.customer_id IS NULL, IF(wishlist.customer_id IS NULL, 0, wishlist.customer_id), quote.customer_id)')
|
56 |
)
|
57 |
)
|
58 |
+
->where('quote.is_active = ?', 1)
|
59 |
+
->where('quote.items_count > ?', 0)
|
60 |
+
->where('quote.customer_email IS NOT NULL');
|
61 |
+
|
62 |
$subselect->joinLeft(
|
63 |
array('log' => $logQuoteTable),
|
64 |
'log.quote_id=quote.entity_id',
|
65 |
array('visitor_id' => 'log.visitor_id')
|
66 |
);
|
67 |
+
|
68 |
$subselect->joinInner(
|
69 |
+
array('store' => $storeTable),
|
70 |
+
'quote.store_id=store.store_id',
|
71 |
array('store_id' => 'store.store_id')
|
72 |
)->where('store.website_id=?', $website);
|
73 |
+
|
74 |
$subselect->joinLeft(
|
75 |
+
array('wishlist' => $wishlistTable),
|
76 |
+
'wishlist.customer_id=quote.customer_id',
|
77 |
array('wishlist_id' => 'wishlist.wishlist_id')
|
78 |
);
|
79 |
+
|
80 |
$subselect->joinLeft(
|
81 |
+
array('wishlist_item' => $wishlistItemTable),
|
82 |
+
'wishlist_item.wishlist_id=wishlist.wishlist_id',
|
83 |
array()
|
84 |
);
|
85 |
+
|
86 |
+
} // If conditions are based on Cart Only
|
|
|
87 |
elseif (in_array('cart', $conditionTypes)) {
|
88 |
$groupby = 'quote_id';
|
89 |
+
$cMatch = 'c.quote_id=root.quote_id';
|
90 |
+
|
91 |
$subselect->from(
|
92 |
+
array('quote' => $quoteTable),
|
93 |
array(
|
94 |
'quote_id' => 'entity_id',
|
95 |
'customer_id' => new Zend_Db_Expr('IF(quote.customer_id IS NULL, 0, quote.customer_id)'),
|
96 |
'wishlist_id' => new Zend_Db_Expr('0'),
|
97 |
)
|
98 |
)
|
99 |
+
->where('quote.is_active = ?', 1)
|
100 |
+
->where('quote.items_count > ?', 0)
|
101 |
+
->where('quote.customer_email IS NOT NULL');
|
102 |
+
|
103 |
$subselect->joinLeft(
|
104 |
array('log' => $logQuoteTable),
|
105 |
'log.quote_id=quote.entity_id',
|
106 |
array('visitor_id' => 'log.visitor_id')
|
107 |
);
|
108 |
+
|
109 |
$subselect->joinInner(
|
110 |
+
array('store' => $storeTable),
|
111 |
+
'quote.store_id=store.store_id',
|
112 |
array('store_id' => 'store.store_id')
|
113 |
)->where('store.website_id=?', $website);
|
114 |
+
} // If conditions are based on Wishlist Only
|
|
|
115 |
elseif (in_array('wishlist', $conditionTypes)) {
|
116 |
$groupby = 'wishlist_id';
|
117 |
+
$cMatch = 'c.wishlist_id = root.wishlist_id';
|
118 |
+
|
119 |
$subselect->from(
|
120 |
+
array('customer' => $customerTable),
|
121 |
array(
|
122 |
'quote_id' => new Zend_Db_Expr('0'),
|
123 |
'customer_id' => 'entity_id',
|
124 |
)
|
125 |
);
|
126 |
+
|
127 |
$subselect->joinLeft(
|
128 |
+
array('wishlist' => $wishlistTable),
|
129 |
+
'wishlist.customer_id=customer.entity_id',
|
130 |
array('wishlist_id' => 'wishlist.wishlist_id')
|
131 |
);
|
132 |
+
|
133 |
$subselect->joinLeft(
|
134 |
+
array('wishlist_item' => $wishlistItemTable),
|
135 |
+
'wishlist_item.wishlist_id=wishlist.wishlist_id',
|
136 |
array()
|
137 |
);
|
138 |
+
|
139 |
$subselect->joinLeft(
|
140 |
array('log' => $logCustomerTable),
|
141 |
'log.customer_id=customer.entity_id',
|
142 |
array('visitor_id' => 'log.visitor_id')
|
143 |
);
|
144 |
+
|
145 |
$subselect->joinInner(
|
146 |
+
array('store' => $storeTable),
|
147 |
+
'wishlist_item.store_id=store.store_id',
|
148 |
array('store_id' => 'store.store_id')
|
149 |
)->where('store.website_id=?', $website);
|
150 |
}
|
151 |
+
|
152 |
// Set main select to pull use subselect as root and pull required fields
|
153 |
$select->from(array('root' => $subselect), array(
|
154 |
'unique_id' => new Zend_Db_Expr(
|
155 |
"CONCAT(:rule_id, '-', `root`.`store_id`, '-', IF(`root`.`customer_id` IS NULL, 0, `root`.`customer_id`), '-', IF(`root`.`visitor_id` IS NULL, 0, `root`.`visitor_id`))"
|
156 |
),
|
157 |
+
'store_id',
|
158 |
+
'customer_id' => new Zend_Db_Expr("IF(`root`.`customer_id` IS NULL, 0, `root`.`customer_id`)"),
|
159 |
+
'quote_id' => new Zend_Db_Expr("IF(`root`.`quote_id` IS NULL, 0, `root`.`quote_id`)"),
|
160 |
+
'wishlist_id' => new Zend_Db_Expr("IF(`root`.`wishlist_id` IS NULL, 0, `root`.`wishlist_id`)"),
|
161 |
+
'visitor_id' => new Zend_Db_Expr("IF(`root`.`visitor_id` IS NULL, 0, `root`.`visitor_id`)")
|
162 |
))
|
163 |
+
->group($groupby);
|
164 |
}
|
165 |
+
|
166 |
$couponTable = $this->getResource()->getTable('bronto_reminder/coupon');
|
167 |
+
|
168 |
$select->joinLeft(
|
169 |
array('c' => $couponTable),
|
170 |
+
"c.unique_id=unique_id AND $cMatch AND c.store_id=root.store_id AND c.rule_id=:rule_id",
|
171 |
array('c.coupon_id')
|
172 |
);
|
173 |
+
|
174 |
return $select;
|
175 |
}
|
176 |
|
178 |
* Get SQL select.
|
179 |
* Rewrited for cover root conditions combination with additional condition by customer
|
180 |
*
|
181 |
+
* @param null|Bronto_Reminder_Model_Rule $rule
|
182 |
+
* @param int | Zend_Db_Expr $website
|
183 |
* @return Varien_Db_Select
|
184 |
*/
|
185 |
public function getConditionsSql($rule, $website)
|
186 |
{
|
187 |
+
$select = $this->_prepareConditionsSql($rule, $website);
|
188 |
+
$required = $this->_getRequiredValidation();
|
189 |
$aggregator = ($this->getAggregator() == 'all') ? ' AND ' : ' OR ';
|
190 |
+
$operator = $required ? '=' : '<>';
|
191 |
$conditions = array();
|
192 |
+
|
193 |
foreach ($this->getConditions() as $condition) {
|
194 |
if ($sql = $condition->getConditionsSql($rule, $website)) {
|
195 |
$conditions[] = "(IFNULL(($sql), 0) {$operator} 1)";
|
196 |
}
|
197 |
}
|
198 |
+
|
199 |
if (!empty($conditions)) {
|
200 |
$select->where(implode($aggregator, $conditions));
|
201 |
+
} else {
|
|
|
202 |
$select->reset();
|
203 |
}
|
204 |
+
|
205 |
return $select;
|
206 |
}
|
207 |
}
|
app/code/community/Bronto/Reminder/Model/Rule/Condition/Wishlist.php
CHANGED
@@ -78,14 +78,14 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist extends Bronto_Reminder_Mode
|
|
78 |
public function asHtml()
|
79 |
{
|
80 |
return $this->getTypeElementHtml()
|
81 |
-
|
82 |
// $this->getOperatorElementHtml(),
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
}
|
87 |
|
88 |
-
|
89 |
* Get condition SQL select
|
90 |
*
|
91 |
* @param $rule
|
@@ -94,15 +94,15 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist extends Bronto_Reminder_Mode
|
|
94 |
*/
|
95 |
protected function _prepareConditionsSql($rule, $website)
|
96 |
{
|
97 |
-
$interval = Mage::helper('bronto_reminder')->getCronInterval();
|
98 |
$conditionValue = (int)$this->getValue();
|
99 |
if ($conditionValue < 1) {
|
100 |
Mage::throwException(Mage::helper('bronto_reminder')->__('Root wishlist condition should have days value at least 1.'));
|
101 |
}
|
|
|
|
|
102 |
|
103 |
-
$wishlistTable
|
104 |
$wishlistItemTable = $this->getResource()->getTable('wishlist/item');
|
105 |
-
$operator = '='; //$this->getResource()->getSqlOperator($this->getOperator());
|
106 |
|
107 |
$select = $this->getResource()->createSelect();
|
108 |
$select->from(array('item' => $wishlistItemTable), array(new Zend_Db_Expr(1)));
|
@@ -112,14 +112,13 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist extends Bronto_Reminder_Mode
|
|
112 |
'item.wishlist_id = list.wishlist_id',
|
113 |
array()
|
114 |
);
|
115 |
-
|
116 |
$this->_limitByStoreWebsite($select, $website, 'item.store_id');
|
117 |
-
$
|
118 |
-
$select->where("
|
119 |
-
$select->where("STR_TO_DATE('".now()."',GET_FORMAT(DATETIME,'ISO')) <= DATE_ADD(list.updated_at, INTERVAL ? MINUTE)", $conditionValueInMinutes + $interval);
|
120 |
$select->where($this->_createCustomerFilter('list.customer_id'));
|
121 |
$select->limit(1);
|
122 |
-
|
123 |
return $select;
|
124 |
}
|
125 |
|
@@ -132,10 +131,10 @@ class Bronto_Reminder_Model_Rule_Condition_Wishlist extends Bronto_Reminder_Mode
|
|
132 |
*/
|
133 |
public function getConditionsSql($rule, $website)
|
134 |
{
|
135 |
-
$select
|
136 |
-
$required
|
78 |
public function asHtml()
|
79 |
{
|
80 |
return $this->getTypeElementHtml()
|
81 |
+
. Mage::helper('bronto_reminder')->__('Wishlist is not empty and abandoned for %s day(s) and %s of these conditions match:',
|
82 |
// $this->getOperatorElementHtml(),
|
83 |
+
$this->getValueElementHtml(),
|
84 |
+
$this->getAggregatorElement()->getHtml())
|
85 |
+
. $this->getRemoveLinkHtml();
|
86 |
}
|
87 |
|
88 |
+
/**
|
89 |
* Get condition SQL select
|
90 |
*
|
91 |
* @param $rule
|
94 |
*/
|
95 |
protected function _prepareConditionsSql($rule, $website)
|
96 |
{
|
|
|
97 |
$conditionValue = (int)$this->getValue();
|
98 |
if ($conditionValue < 1) {
|
99 |
Mage::throwException(Mage::helper('bronto_reminder')->__('Root wishlist condition should have days value at least 1.'));
|
100 |
}
|
101 |
+
// Convert to minutes
|
102 |
+
$conditionValue *= 1440;
|
103 |
|
104 |
+
$wishlistTable = $this->getResource()->getTable('wishlist/wishlist');
|
105 |
$wishlistItemTable = $this->getResource()->getTable('wishlist/item');
|
|
|
106 |
|
107 |
$select = $this->getResource()->createSelect();
|
108 |
$select->from(array('item' => $wishlistItemTable), array(new Zend_Db_Expr(1)));
|
112 |
'item.wishlist_id = list.wishlist_id',
|
113 |
array()
|
114 |
);
|
115 |
+
|
116 |
$this->_limitByStoreWebsite($select, $website, 'item.store_id');
|
117 |
+
$curDate = now();
|
118 |
+
$select->where("list.updated_at BETWEEN DATE_SUB('$curDate', INTERVAL (?+:interval) MINUTE) AND DATE_SUB('$curDate', INTERVAL ? MINUTE)", $conditionValue);
|
|
|
119 |
$select->where($this->_createCustomerFilter('list.customer_id'));
|
120 |
$select->limit(1);
|
121 |
+
|
122 |
return $select;
|
123 |
}
|
124 |
|
131 |
*/
|
132 |
public function getConditionsSql($rule, $website)
|
133 |
{
|
134 |
+
$select = $this->_prepareConditionsSql($rule, $website);
|
135 |
+
$required = $this->_getR
|