advance-product-newsleter - Version 1.3.0

Version Notes

Customer can subscribe for product price cut and stock available notification which they very interested

Download this release

Release Info

Developer iifire
Extension advance-product-newsleter
Version 1.3.0
Comparing to
See all releases


Version 1.3.0

Files changed (123) hide show
  1. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Manage.php +25 -0
  2. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Manage/Grid.php +193 -0
  3. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Problem.php +43 -0
  4. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Problem/Grid.php +94 -0
  5. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Queue.php +20 -0
  6. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Queue/Grid.php +138 -0
  7. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Queue/Grid/Renderer/Action.php +27 -0
  8. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Queue/Grid/Renderer/Name.php +17 -0
  9. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Queue/Grid/Renderer/Type.php +25 -0
  10. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Queue/Preview.php +38 -0
  11. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Queue/Preview/Form.php +43 -0
  12. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Report.php +18 -0
  13. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Report/Categories.php +19 -0
  14. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Report/Categories/Grid.php +42 -0
  15. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Report/Category.php +19 -0
  16. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Report/Category/Grid.php +44 -0
  17. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Report/Grid.php +42 -0
  18. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Report/Type.php +19 -0
  19. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Report/Type/Grid.php +44 -0
  20. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Subscriber.php +25 -0
  21. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Subscriber/Grid.php +204 -0
  22. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Subscriber/Grid/Filter/Checkbox.php +18 -0
  23. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Subscriber/Grid/Filter/Website.php +44 -0
  24. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Subscriber/Grid/Renderer/Type.php +27 -0
  25. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template.php +36 -0
  26. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Edit.php +376 -0
  27. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Edit/Category.php +62 -0
  28. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Edit/Form.php +177 -0
  29. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Edit/Product.php +203 -0
  30. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Grid.php +174 -0
  31. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Grid/Renderer/Action.php +27 -0
  32. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Grid/Renderer/Category.php +14 -0
  33. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Grid/Renderer/Product.php +14 -0
  34. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Grid/Renderer/Sender.php +23 -0
  35. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Grid/Renderer/Type.php +24 -0
  36. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Preview.php +67 -0
  37. app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Preview/Form.php +43 -0
  38. app/code/community/Magentokey/Newsletter/Block/Link.php +244 -0
  39. app/code/community/Magentokey/Newsletter/Block/Widget/Product.php +15 -0
  40. app/code/community/Magentokey/Newsletter/Helper/Data.php +149 -0
  41. app/code/community/Magentokey/Newsletter/Model/Mysql4/Problem.php +17 -0
  42. app/code/community/Magentokey/Newsletter/Model/Mysql4/Problem/Collection.php +111 -0
  43. app/code/community/Magentokey/Newsletter/Model/Mysql4/Queue.php +133 -0
  44. app/code/community/Magentokey/Newsletter/Model/Mysql4/Queue/Collection.php +210 -0
  45. app/code/community/Magentokey/Newsletter/Model/Mysql4/Report/Categories.php +55 -0
  46. app/code/community/Magentokey/Newsletter/Model/Mysql4/Report/Category.php +55 -0
  47. app/code/community/Magentokey/Newsletter/Model/Mysql4/Report/Collection.php +55 -0
  48. app/code/community/Magentokey/Newsletter/Model/Mysql4/Report/Type.php +54 -0
  49. app/code/community/Magentokey/Newsletter/Model/Mysql4/Subscriber.php +115 -0
  50. app/code/community/Magentokey/Newsletter/Model/Mysql4/Subscriber/Collection.php +231 -0
  51. app/code/community/Magentokey/Newsletter/Model/Mysql4/Template.php +117 -0
  52. app/code/community/Magentokey/Newsletter/Model/Mysql4/Template/Collection.php +54 -0
  53. app/code/community/Magentokey/Newsletter/Model/Observer.php +179 -0
  54. app/code/community/Magentokey/Newsletter/Model/Problem.php +95 -0
  55. app/code/community/Magentokey/Newsletter/Model/Queue.php +146 -0
  56. app/code/community/Magentokey/Newsletter/Model/Session.php +39 -0
  57. app/code/community/Magentokey/Newsletter/Model/Subscriber.php +474 -0
  58. app/code/community/Magentokey/Newsletter/Model/Template.php +349 -0
  59. app/code/community/Magentokey/Newsletter/controllers/Adminhtml/Productnewsletter/ManageController.php +61 -0
  60. app/code/community/Magentokey/Newsletter/controllers/Adminhtml/Productnewsletter/ProblemController.php +52 -0
  61. app/code/community/Magentokey/Newsletter/controllers/Adminhtml/Productnewsletter/QueueController.php +178 -0
  62. app/code/community/Magentokey/Newsletter/controllers/Adminhtml/Productnewsletter/ReportController.php +121 -0
  63. app/code/community/Magentokey/Newsletter/controllers/Adminhtml/Productnewsletter/SubscriberController.php +117 -0
  64. app/code/community/Magentokey/Newsletter/controllers/Adminhtml/Productnewsletter/TemplateController.php +340 -0
  65. app/code/community/Magentokey/Newsletter/controllers/SubscribeController.php +202 -0
  66. app/code/community/Magentokey/Newsletter/etc/adminhtml.xml +108 -0
  67. app/code/community/Magentokey/Newsletter/etc/config.xml +197 -0
  68. app/code/community/Magentokey/Newsletter/etc/system.xml +466 -0
  69. app/code/community/Magentokey/Newsletter/etc/widget.xml +48 -0
  70. app/code/community/Magentokey/Newsletter/sql/magentokey_newsletter_setup/mysql4-install-1.0.0.php +119 -0
  71. app/design/adminhtml/default/default/layout/magentokey_newsletter.xml +40 -0
  72. app/design/adminhtml/default/default/template/magentokey/newsletter/manage/index.phtml +17 -0
  73. app/design/adminhtml/default/default/template/magentokey/newsletter/preview/iframeswitcher.phtml +70 -0
  74. app/design/adminhtml/default/default/template/magentokey/newsletter/preview/store.phtml +40 -0
  75. app/design/adminhtml/default/default/template/magentokey/newsletter/problem/list.phtml +26 -0
  76. app/design/adminhtml/default/default/template/magentokey/newsletter/queue/edit.phtml +79 -0
  77. app/design/adminhtml/default/default/template/magentokey/newsletter/queue/list.phtml +20 -0
  78. app/design/adminhtml/default/default/template/magentokey/newsletter/queue/preview.phtml +24 -0
  79. app/design/adminhtml/default/default/template/magentokey/newsletter/report/grid.phtml +206 -0
  80. app/design/adminhtml/default/default/template/magentokey/newsletter/subscriber/index.phtml +17 -0
  81. app/design/adminhtml/default/default/template/magentokey/newsletter/template/edit.phtml +201 -0
  82. app/design/adminhtml/default/default/template/magentokey/newsletter/template/list.phtml +21 -0
  83. app/design/adminhtml/default/default/template/magentokey/newsletter/template/preview.phtml +24 -0
  84. app/design/adminhtml/default/default/template/magentokey/newsletter/widget/grid.phtml +201 -0
  85. app/design/adminhtml/default/default/template/magentokey/newsletter/widget/grid/massaction.phtml +63 -0
  86. app/design/frontend/default/default/layout/magentokey_newsletter.xml +62 -0
  87. app/design/frontend/default/default/template/magentokey/newsletter/category_new.phtml +15 -0
  88. app/design/frontend/default/default/template/magentokey/newsletter/category_price.phtml +15 -0
  89. app/design/frontend/default/default/template/magentokey/newsletter/form.phtml +135 -0
  90. app/design/frontend/default/default/template/magentokey/newsletter/form_clone.phtml +177 -0
  91. app/design/frontend/default/default/template/magentokey/newsletter/js.phtml +14 -0
  92. app/design/frontend/default/default/template/magentokey/newsletter/js_clone.phtml +12 -0
  93. app/design/frontend/default/default/template/magentokey/newsletter/page.phtml +37 -0
  94. app/design/frontend/default/default/template/magentokey/newsletter/popup.phtml +10 -0
  95. app/design/frontend/default/default/template/magentokey/newsletter/price.phtml +17 -0
  96. app/design/frontend/default/default/template/magentokey/newsletter/stock.phtml +17 -0
  97. app/design/frontend/default/default/template/magentokey/newsletter/update.phtml +17 -0
  98. app/design/frontend/default/default/template/magentokey/newsletter/widget/default.phtml +21 -0
  99. app/design/frontend/default/default/template/magentokey/newsletter/widget/new.phtml +21 -0
  100. app/design/frontend/default/default/template/magentokey/newsletter/widget/price.phtml +21 -0
  101. app/design/frontend/default/default/template/magentokey/newsletter/widget/stock.phtml +21 -0
  102. app/design/frontend/default/default/template/magentokey/newsletter/widget/update.phtml +21 -0
  103. app/etc/modules/Magentokey_Newsletter.xml +12 -0
  104. package.xml +32 -0
  105. skin/frontend/default/default/css/magentokey/newsletter.css +161 -0
  106. skin/frontend/default/default/css/magentokey/newsletter/arrow-1.png +0 -0
  107. skin/frontend/default/default/css/magentokey/newsletter/bg.png +0 -0
  108. skin/frontend/default/default/css/magentokey/newsletter/bg2.png +0 -0
  109. skin/frontend/default/default/css/magentokey/newsletter/body_bg.jpg +0 -0
  110. skin/frontend/default/default/css/magentokey/newsletter/delete.png +0 -0
  111. skin/frontend/default/default/css/magentokey/newsletter/line_bg.png +0 -0
  112. skin/frontend/default/default/css/magentokey/newsletter/logo.png +0 -0
  113. skin/frontend/default/default/css/magentokey/newsletter/sprites.png +0 -0
  114. skin/frontend/default/default/css/magentokey/popup/magento.css +197 -0
  115. skin/frontend/default/default/css/magentokey/popup/magento/btn_bg.gif +0 -0
  116. skin/frontend/default/default/css/magentokey/popup/magento/content_bg.gif +0 -0
  117. skin/frontend/default/default/css/magentokey/popup/magento/loading.gif +0 -0
  118. skin/frontend/default/default/css/magentokey/popup/magento/title.gif +0 -0
  119. skin/frontend/default/default/css/magentokey/popup/magento/window_close.png +0 -0
  120. skin/frontend/default/default/css/magentokey/popup/newsletter.css +83 -0
  121. skin/frontend/default/default/css/magentokey/review.css +0 -0
  122. skin/frontend/default/default/css/magentokey/widgets.css +96 -0
  123. skin/frontend/default/default/js/magentokey/MagentokeyUtility.js +47 -0
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Manage.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Manage extends Mage_Adminhtml_Block_Template
8
+ {
9
+ public function __construct()
10
+ {
11
+ parent::__construct();
12
+ $this->setTemplate('magentokey/newsletter/manage/index.phtml');
13
+ }
14
+
15
+ protected function _prepareLayout()
16
+ {
17
+ $this->setChild('grid', $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_manage_grid', 'newsletter.product.manage.grid'));
18
+ return parent::_prepareLayout();
19
+ }
20
+
21
+ public function getHeaderText()
22
+ {
23
+ return Mage::helper('magentokey_newsletter')->__('Add Product(s) To New Products Queue');
24
+ }
25
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Manage/Grid.php ADDED
@@ -0,0 +1,193 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Manage_Grid extends Mage_Adminhtml_Block_Widget_Grid
8
+ {
9
+ protected function _getStore()
10
+ {
11
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
12
+ return Mage::app()->getStore($storeId);
13
+ }
14
+ protected function _construct()
15
+ {
16
+ $this->setEmptyText(Mage::helper('magentokey_newsletter')->__('No Product Found'));
17
+ $this->setUseAjax(true);
18
+ $this->setId('productGrid');
19
+ $this->setDefaultSort('entity_id');
20
+ $this->setSaveParametersInSession(true);
21
+ }
22
+
23
+ protected function _prepareCollection()
24
+ {
25
+ //$this->setTemplate('magentokey/newsletter/widget/grid.phtml');
26
+ $store = $this->_getStore();
27
+ $collection = Mage::getModel('catalog/product')->getCollection()
28
+ ->addAttributeToSelect('sku')
29
+ ->addAttributeToSelect('name')
30
+ ->addAttributeToSelect('attribute_set_id')
31
+ ->addAttributeToSelect('type_id');
32
+
33
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
34
+ $collection->joinField('qty',
35
+ 'cataloginventory/stock_item',
36
+ 'qty',
37
+ 'product_id=entity_id',
38
+ '{{table}}.stock_id=1',
39
+ 'left');
40
+ }
41
+ if ($store->getId()) {
42
+ //$collection->setStoreId($store->getId());
43
+ $adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
44
+ $collection->addStoreFilter($store);
45
+ $collection->joinAttribute('name', 'catalog_product/name', 'entity_id', null, 'inner', $adminStore);
46
+ $collection->joinAttribute('custom_name', 'catalog_product/name', 'entity_id', null, 'inner', $store->getId());
47
+ $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner', $store->getId());
48
+ $collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner', $store->getId());
49
+ $collection->joinAttribute('price', 'catalog_product/price', 'entity_id', null, 'left', $store->getId());
50
+ }
51
+ else {
52
+ $collection->addAttributeToSelect('price');
53
+ $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
54
+ $collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
55
+ }
56
+
57
+ $this->setCollection($collection);
58
+
59
+ parent::_prepareCollection();
60
+ $this->getCollection()->addWebsiteNamesToResult();
61
+ return $this;
62
+ }
63
+ protected function _addColumnFilterToCollection($column)
64
+ {
65
+ if ($this->getCollection()) {
66
+ if ($column->getId() == 'websites') {
67
+ $this->getCollection()->joinField('websites',
68
+ 'catalog/product_website',
69
+ 'website_id',
70
+ 'product_id=entity_id',
71
+ null,
72
+ 'left');
73
+ }
74
+ }
75
+ return parent::_addColumnFilterToCollection($column);
76
+ }
77
+ protected function _prepareColumns()
78
+ {
79
+ $this->addColumn('entity_id',
80
+ array(
81
+ 'header'=> Mage::helper('catalog')->__('ID'),
82
+ 'width' => '50px',
83
+ 'type' => 'number',
84
+ 'index' => 'entity_id',
85
+ ));
86
+ $this->addColumn('name',
87
+ array(
88
+ 'header'=> Mage::helper('catalog')->__('Name'),
89
+ 'index' => 'name',
90
+ ));
91
+
92
+ $store = $this->_getStore();
93
+ if ($store->getId()) {
94
+ $this->addColumn('custom_name',
95
+ array(
96
+ 'header'=> Mage::helper('catalog')->__('Name in %s', $store->getName()),
97
+ 'index' => 'custom_name',
98
+ ));
99
+ }
100
+
101
+ $this->addColumn('type',
102
+ array(
103
+ 'header'=> Mage::helper('catalog')->__('Type'),
104
+ 'width' => '60px',
105
+ 'index' => 'type_id',
106
+ 'type' => 'options',
107
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
108
+ ));
109
+
110
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
111
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
112
+ ->load()
113
+ ->toOptionHash();
114
+
115
+ $this->addColumn('set_name',
116
+ array(
117
+ 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
118
+ 'width' => '100px',
119
+ 'index' => 'attribute_set_id',
120
+ 'type' => 'options',
121
+ 'options' => $sets,
122
+ ));
123
+
124
+ $this->addColumn('sku',
125
+ array(
126
+ 'header'=> Mage::helper('catalog')->__('SKU'),
127
+ 'width' => '80px',
128
+ 'index' => 'sku',
129
+ ));
130
+
131
+ $store = $this->_getStore();
132
+ $this->addColumn('price',
133
+ array(
134
+ 'header'=> Mage::helper('catalog')->__('Price'),
135
+ 'type' => 'price',
136
+ 'currency_code' => $store->getBaseCurrency()->getCode(),
137
+ 'index' => 'price',
138
+ ));
139
+
140
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
141
+ $this->addColumn('qty',
142
+ array(
143
+ 'header'=> Mage::helper('catalog')->__('Qty'),
144
+ 'width' => '100px',
145
+ 'type' => 'number',
146
+ 'index' => 'qty',
147
+ ));
148
+ }
149
+
150
+ $this->addColumn('visibility',
151
+ array(
152
+ 'header'=> Mage::helper('catalog')->__('Visibility'),
153
+ 'width' => '70px',
154
+ 'index' => 'visibility',
155
+ 'type' => 'options',
156
+ 'options' => Mage::getModel('catalog/product_visibility')->getOptionArray(),
157
+ ));
158
+
159
+ $this->addColumn('status',
160
+ array(
161
+ 'header'=> Mage::helper('catalog')->__('Status'),
162
+ 'width' => '70px',
163
+ 'index' => 'status',
164
+ 'type' => 'options',
165
+ 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
166
+ ));
167
+
168
+ if (!Mage::app()->isSingleStoreMode()) {
169
+ $this->addColumn('websites',
170
+ array(
171
+ 'header'=> Mage::helper('catalog')->__('Websites'),
172
+ 'width' => '100px',
173
+ 'sortable' => false,
174
+ 'index' => 'websites',
175
+ 'type' => 'options',
176
+ 'options' => Mage::getModel('core/website')->getCollection()->toOptionHash(),
177
+ ));
178
+ }
179
+
180
+ return parent::_prepareColumns();
181
+ }
182
+ protected function _prepareMassaction()
183
+ {
184
+ $this->setMassactionIdField('product_id');
185
+ $this->getMassactionBlock()->setFormFieldName('product');
186
+ $this->getMassactionBlock()->addItem('massAddNews', array(
187
+ 'label' => Mage::helper('magentokey_newsletter')->__('Add To Queue'),
188
+ 'url' => $this->getUrl('*/*/massAddNews'),
189
+ 'confirm' => Mage::helper('magentokey_newsletter')->__('Are you sure?')
190
+ ));
191
+ return $this;
192
+ }
193
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Problem.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Problem extends Mage_Adminhtml_Block_Template
8
+ {
9
+
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+ $this->setTemplate('magentokey/newsletter/problem/list.phtml');
14
+ $collection = Mage::getResourceSingleton('magentokey_newsletter/problem_collection')
15
+ ->addSubscriberInfo()
16
+ ->addQueueInfo();
17
+
18
+ }
19
+
20
+ protected function _prepareLayout()
21
+ {
22
+ $this->setChild('grid',
23
+ $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_problem_grid','newsletter.problem.grid')
24
+ );
25
+ return parent::_prepareLayout();
26
+ }
27
+
28
+ public function getUnsubscribeButtonHtml()
29
+ {
30
+ return $this->getChildHtml('unsubscribeButton');
31
+ }
32
+
33
+ public function getDeleteButtonHtml()
34
+ {
35
+ return $this->getChildHtml('deleteButton');
36
+ }
37
+
38
+ public function getShowButtons()
39
+ {
40
+ return Mage::getResourceSingleton('magentokey_newsletter/problem_collection')->getSize() > 0;
41
+ }
42
+
43
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Problem/Grid.php ADDED
@@ -0,0 +1,94 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Problem_Grid extends Mage_Adminhtml_Block_Widget_Grid
8
+ {
9
+ public function __construct()
10
+ {
11
+ parent::__construct();
12
+ $this->setId('problemGrid');
13
+ $this->setSaveParametersInSession(true);
14
+ $this->setMessageBlockVisibility(true);
15
+ $this->setUseAjax(true);
16
+ $this->setEmptyText(Mage::helper('magentokey_newsletter')->__('No problem found.'));
17
+ }
18
+
19
+ protected function _prepareCollection()
20
+ {
21
+ $collection = Mage::getResourceModel('magentokey_newsletter/problem_collection')
22
+ ->addSubscriberInfo()
23
+ ->addQueueInfo();
24
+
25
+ $this->setCollection($collection);
26
+
27
+ return parent::_prepareCollection();
28
+ }
29
+
30
+ protected function _prepareColumns()
31
+ {
32
+ $this->addColumn('checkbox', array(
33
+ 'sortable' => false,
34
+ 'filter' => 'adminhtml/newsletter_problem_grid_filter_checkbox',
35
+ 'renderer' => 'adminhtml/newsletter_problem_grid_renderer_checkbox',
36
+ 'width' => '20px'
37
+ ));
38
+
39
+ $this->addColumn('problem_id', array(
40
+ 'header' => Mage::helper('magentokey_newsletter')->__('ID'),
41
+ 'index' => 'problem_id',
42
+ 'width' => '50px'
43
+ ));
44
+
45
+ $this->addColumn('subscriber', array(
46
+ 'header' => Mage::helper('magentokey_newsletter')->__('Subscriber'),
47
+ 'index' => 'subscriber_id',
48
+ 'format' => '#$subscriber_id $customer_name ($subscriber_email)',
49
+ 'width' => '230px',
50
+ ));
51
+ $this->addColumn('queue_id', array(
52
+ 'header' => Mage::helper('magentokey_newsletter')->__('Queue ID'),
53
+ 'index' => 'queue_id',
54
+ 'width' => '50px',
55
+ ));
56
+ $this->addColumn('added_at', array(
57
+ 'header' => Mage::helper('magentokey_newsletter')->__('Queue Added At'),
58
+ 'index' => 'added_at',
59
+ 'gmtoffset' => true,
60
+ 'type' => 'datetime',
61
+ 'width' => '160px',
62
+ ));
63
+
64
+ $this->addColumn('newsletter_subject', array(
65
+ 'header' => Mage::helper('magentokey_newsletter')->__('Queue Subject'),
66
+ 'index' => 'newsletter_subject',
67
+ 'width' => '200px',
68
+ ));
69
+
70
+ $this->addColumn('problem_code', array(
71
+ 'header' => Mage::helper('magentokey_newsletter')->__('Error Code'),
72
+ 'index' => 'problem_error_code',
73
+ 'type' => 'number'
74
+ ));
75
+
76
+ $this->addColumn('problem_text', array(
77
+ 'header' => Mage::helper('magentokey_newsletter')->__('Error Text'),
78
+ 'index' => 'problem_error_text'
79
+ ));
80
+ return parent::_prepareColumns();
81
+ }
82
+
83
+ protected function _prepareMassaction()
84
+ {
85
+ $this->setMassactionIdField('problem_id');
86
+ $this->getMassactionBlock()->setFormFieldName('problem_id');
87
+ $this->getMassactionBlock()->addItem('delete', array(
88
+ 'label' => Mage::helper('magentokey_newsletter')->__('Delete Selected Problems'),
89
+ 'url' => $this->getUrl('*/*/massDelete'),
90
+ 'confirm' => Mage::helper('magentokey_newsletter')->__('Are you sure?')
91
+ ));
92
+ return $this;
93
+ }
94
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Queue.php ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Queue extends Mage_Adminhtml_Block_Template
8
+ {
9
+ public function __construct()
10
+ {
11
+ $this->setTemplate('magentokey/newsletter/queue/list.phtml');
12
+ }
13
+
14
+ protected function _beforeToHtml()
15
+ {
16
+ $this->setChild('grid', $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_queue_grid', 'newsletter.queue.grid'));
17
+ return parent::_beforeToHtml();
18
+ }
19
+
20
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Queue/Grid.php ADDED
@@ -0,0 +1,138 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Queue_Grid extends Mage_Adminhtml_Block_Widget_Grid
8
+ {
9
+
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+ $this->setId('queueGrid');
14
+ $this->setDefaultSort('queue_id');
15
+ $this->setDefaultDir('desc');
16
+ $this->setSaveParametersInSession(true);
17
+ $this->setUseAjax(true);
18
+ }
19
+
20
+ protected function _prepareCollection()
21
+ {
22
+ $collection = Mage::getResourceModel('magentokey_newsletter/queue_collection')
23
+ ->addTemplateInfo();
24
+ $this->setCollection($collection);
25
+ return parent::_prepareCollection();
26
+ }
27
+
28
+ protected function _prepareColumns()
29
+ {
30
+ $this->addColumn('queue_id', array(
31
+ 'header' => Mage::helper('magentokey_newsletter')->__('ID'),
32
+ 'index' => 'queue_id',
33
+ 'width' => 10
34
+ ));
35
+
36
+ $this->addColumn('subscriber_type', array(
37
+ 'header' => Mage::helper('magentokey_newsletter')->__('Type'),
38
+ 'index' => 'subscriber_type',
39
+ 'type' => 'options',
40
+ 'renderer' => 'magentokey_newsletter/adminhtml_newsletter_queue_grid_renderer_type',
41
+ 'options' => array(
42
+ Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE => Mage::helper('magentokey_newsletter')->__('Product Update'),
43
+ Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION => Mage::helper('magentokey_newsletter')->__('Price Reduction'),
44
+ Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE => Mage::helper('magentokey_newsletter')->__('Stock Available'),
45
+ Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_NEW => Mage::helper('magentokey_newsletter')->__('New Products'),
46
+ ),
47
+ ));
48
+ $this->addColumn('product_id', array(
49
+ 'header' => Mage::helper('magentokey_newsletter')->__('Product ID'),
50
+ 'index' => 'product_id',
51
+ 'width' => 10
52
+ ));
53
+ $this->addColumn('product_name', array(
54
+ 'header' => Mage::helper('magentokey_newsletter')->__('Product Name'),
55
+ 'index' => 'product_id',
56
+ 'renderer' => 'magentokey_newsletter/adminhtml_newsletter_queue_grid_renderer_name',
57
+ ));
58
+ $this->addColumn('template_code', array(
59
+ 'header' => Mage::helper('magentokey_newsletter')->__('Template Name'),
60
+ 'index' => 'template_code'
61
+ ));
62
+ $this->addColumn('template_subject', array(
63
+ 'header' => Mage::helper('magentokey_newsletter')->__('Template Subject'),
64
+ 'index' => 'newsletter_subject'
65
+ ));
66
+
67
+ $this->addColumn('status', array(
68
+ 'header' => Mage::helper('magentokey_newsletter')->__('Status'),
69
+ 'index' => 'queue_status',
70
+ 'type' => 'options',
71
+ 'options' => array(
72
+ Mage_Newsletter_Model_Queue::STATUS_SENT => Mage::helper('magentokey_newsletter')->__('Sent'),
73
+ Mage_Newsletter_Model_Queue::STATUS_CANCEL => Mage::helper('magentokey_newsletter')->__('Cancelled'),
74
+ Mage_Newsletter_Model_Queue::STATUS_NEVER => Mage::helper('magentokey_newsletter')->__('Not Sent'),
75
+ Mage_Newsletter_Model_Queue::STATUS_SENDING => Mage::helper('magentokey_newsletter')->__('Sending'),
76
+ Mage_Newsletter_Model_Queue::STATUS_PAUSE => Mage::helper('magentokey_newsletter')->__('Paused'),
77
+ ),
78
+ 'width' => '100px',
79
+ ));
80
+ $this->addColumn('queue_num', array(
81
+ 'header' => Mage::helper('magentokey_newsletter')->__('Recipients'),
82
+ 'type' => 'number',
83
+ 'index' => 'queue_num'
84
+ ));
85
+ $this->addColumn('added_at', array(
86
+ 'header' => Mage::helper('magentokey_newsletter')->__('Added At'),
87
+ 'index' => 'added_at',
88
+ 'type' => 'datetime',
89
+ 'gmtoffset' => true,
90
+ 'default' => ' ---- '
91
+ ));
92
+ $this->addColumn('sent_at', array(
93
+ 'header' => Mage::helper('magentokey_newsletter')->__('Sent At'),
94
+ 'index' => 'sent_at',
95
+ 'type' => 'datetime',
96
+ 'gmtoffset' => true,
97
+ 'default' => ' ---- '
98
+ ));
99
+ $this->addColumn('action', array(
100
+ 'header' => Mage::helper('magentokey_newsletter')->__('Action'),
101
+ 'filter' => false,
102
+ 'sortable' => false,
103
+ 'no_link' => true,
104
+ 'width' => '100px',
105
+ 'renderer' => 'magentokey_newsletter/adminhtml_newsletter_queue_grid_renderer_action'
106
+ ));
107
+
108
+ return parent::_prepareColumns();
109
+ }
110
+ protected function _prepareMassaction()
111
+ {
112
+ $this->setMassactionIdField('queue_id');
113
+ $this->getMassactionBlock()->setFormFieldName('queue');
114
+ $this->getMassactionBlock()->addItem('send', array(
115
+ 'label' => Mage::helper('magentokey_newsletter')->__('Send Newsletter'),
116
+ 'url' => $this->getUrl('*/*/massSend'),
117
+ 'confirm' => Mage::helper('magentokey_newsletter')->__('Are you sure?')
118
+ ));
119
+ $this->getMassactionBlock()->addItem('cancel', array(
120
+ 'label' => Mage::helper('magentokey_newsletter')->__('Cancel Newsletter'),
121
+ 'url' => $this->getUrl('*/*/massCancel'),
122
+ 'confirm' => Mage::helper('magentokey_newsletter')->__('Are you sure?')
123
+ ));
124
+ $this->getMassactionBlock()->addItem('delete', array(
125
+ 'label' => Mage::helper('magentokey_newsletter')->__('Delete Newsletter'),
126
+ 'url' => $this->getUrl('*/*/massDelete'),
127
+ 'confirm' => Mage::helper('magentokey_newsletter')->__('Are you sure?')
128
+ ));
129
+ $this->getMassactionBlock()->addItem('pause', array(
130
+ 'label' => Mage::helper('magentokey_newsletter')->__('Pause Newsletter'),
131
+ 'url' => $this->getUrl('*/*/massPause'),
132
+ 'confirm' => Mage::helper('magentokey_newsletter')->__('Are you sure?')
133
+ ));
134
+ return $this;
135
+ }
136
+
137
+ }
138
+
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Queue/Grid/Renderer/Action.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com>
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Queue_Grid_Renderer_Action extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
8
+ {
9
+ /**
10
+ * Renderer for "Action" column in Newsletter templates grid
11
+ *
12
+ * @var Magentokey_Newsletter_Model_Queue $row
13
+ * @return string
14
+ */
15
+ public function render(Varien_Object $row)
16
+ {
17
+ $actions[] = array(
18
+ 'url' => $this->getUrl('*/*/preview', array('id'=>$row->getId())),
19
+ 'popup' => true,
20
+ 'caption' => Mage::helper('magentokey_newsletter')->__('Preview')
21
+ );
22
+
23
+ $this->getColumn()->setActions($actions);
24
+
25
+ return parent::render($row);
26
+ }
27
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Queue/Grid/Renderer/Name.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Queue_Grid_Renderer_Name extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
8
+ {
9
+ public function render(Varien_Object $row)
10
+ {
11
+ $str = '';
12
+ $productId = $row->getProductId();
13
+ $productModel = Mage::getModel('catalog/product')->load($productId);
14
+ $str = $productModel->getName();
15
+ return $str;
16
+ }
17
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Queue/Grid/Renderer/Type.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_queue_Grid_Renderer_Type extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
8
+ {
9
+ public function render(Varien_Object $row)
10
+ {
11
+ $str = '';
12
+ $type = $row->getSubscriberType();
13
+
14
+ if ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE) {
15
+ $str = Mage::helper('magentokey_newsletter')->__('Product Update');
16
+ } elseif($type == Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION) {
17
+ $str = Mage::helper('magentokey_newsletter')->__('Price Reduction');
18
+ } elseif($type == Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE) {
19
+ $str = Mage::helper('magentokey_newsletter')->__('Stock Available');
20
+ } elseif($type == Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_NEW) {
21
+ $str = Mage::helper('magentokey_newsletter')->__('New Products');
22
+ }
23
+ return $str;
24
+ }
25
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Queue/Preview.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Queue_Preview extends Mage_Adminhtml_Block_Widget
8
+ {
9
+
10
+ protected function _toHtml()
11
+ {
12
+ /* @var $template Magentokey_Newsletter_Model_Queue */
13
+ $queue = Mage::getModel('magentokey_newsletter/queue')->load((int)$this->getRequest()->getParam('id'));
14
+ /* @var $template Magentokey_Newsletter_Model_Template */
15
+ $template = Mage::getModel('magentokey_newsletter/template');
16
+ $template->load($queue->getTemplateId());
17
+ Mage::register('_magentokey_newsletter_product', $queue->getProductId());
18
+ $storeId = (int)$this->getRequest()->getParam('store_id');
19
+ if(!$storeId) {
20
+ $storeId = Mage::app()->getDefaultStoreView()->getId();
21
+ }
22
+
23
+ Varien_Profiler::start("newsletter_template_proccessing");
24
+ $vars = array();
25
+
26
+ $vars['subscriber'] = Mage::getModel('magentokey_newsletter/subscriber');
27
+ $template->emulateDesign($storeId);
28
+ $templateProcessed = $template->getProcessedTemplate($vars, true);
29
+ $template->revertDesign();
30
+
31
+ if($template->isPlain()) {
32
+ $templateProcessed = "<pre>" . htmlspecialchars($templateProcessed) . "</pre>";
33
+ }
34
+ Varien_Profiler::stop("newsletter_template_proccessing");
35
+ return $templateProcessed;
36
+ }
37
+
38
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Queue/Preview/Form.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Queue_Preview_Form extends Mage_Adminhtml_Block_Widget_Form
8
+ {
9
+
10
+ /**
11
+ * Preparing from for revision page
12
+ *
13
+ * @return Mage_Adminhtml_Block_Widget_Form
14
+ */
15
+ protected function _prepareForm()
16
+ {
17
+ $form = new Varien_Data_Form(array(
18
+ 'id' => 'preview_form',
19
+ 'action' => $this->getUrl('*/*/drop', array('_current' => true)),
20
+ 'method' => 'post'
21
+ ));
22
+
23
+ if ($data = $this->getFormData()) {
24
+
25
+ $mapper = array('preview_store_id' => 'store_id');
26
+
27
+ foreach ($data as $key => $value) {
28
+ if(array_key_exists($key, $mapper)) {
29
+ $name = $mapper[$key];
30
+ } else {
31
+ $name = $key;
32
+ }
33
+ $form->addField($key, 'hidden', array('name' => $name));
34
+ }
35
+ $form->setValues($data);
36
+ }
37
+
38
+ $form->setUseContainer(true);
39
+ $this->setForm($form);
40
+ return parent::_prepareForm();
41
+ }
42
+ }
43
+
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Report.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Report extends Mage_Adminhtml_Block_Widget_Grid_Container
8
+ {
9
+ public function __construct()
10
+ {
11
+ $this->_blockGroup = 'magentokey_newsletter';
12
+ $this->_controller = 'adminhtml_newsletter_report';
13
+ $this->_headerText = Mage::helper('magentokey_newsletter')->__('Magentokey Newsletter Reports');
14
+ parent::__construct();
15
+ $this->_removeButton('add');
16
+ }
17
+
18
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Report/Categories.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Report_Categories extends Mage_Adminhtml_Block_Widget_Grid_Container
8
+ {
9
+ public function __construct()
10
+ {
11
+ $this->_blockGroup = 'magentokey_newsletter';
12
+ $this->_controller = 'adminhtml_newsletter_report_categories';
13
+ $this->_headerText = Mage::helper('magentokey_newsletter')->__('Magentokey Newsletter Advance Report');
14
+ parent::__construct();
15
+ $this->_removeButton('add');
16
+
17
+ }
18
+
19
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Report/Categories/Grid.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Report_Categories_Grid extends Mage_Adminhtml_Block_Report_Grid
8
+ {
9
+
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+ $this->setTemplate('magentokey/newsletter/report/grid.phtml');
14
+ $this->setId('gridNewsletterReport');
15
+ }
16
+
17
+ protected function _prepareCollection()
18
+ {
19
+ parent::_prepareCollection();
20
+ $this->getCollection()->initReport('magentokey_newsletter/report_categories');
21
+ }
22
+
23
+ protected function _prepareColumns()
24
+ {
25
+ $this->addColumn('product_id', array(
26
+ 'header' =>Mage::helper('magentokey_newsletter')->__('Product ID'),
27
+ 'index' =>'product_id',
28
+ ));
29
+
30
+ $this->addColumn('num', array(
31
+ 'header' =>Mage::helper('magentokey_newsletter')->__('Total'),
32
+ 'index' =>'num',
33
+ 'total' => 'sum',
34
+ ));
35
+
36
+ $this->addExportType('*/*/exportCsvCategories', Mage::helper('reports')->__('CSV'));
37
+ $this->addExportType('*/*/exportExcelCategories', Mage::helper('reports')->__('Excel XML'));
38
+
39
+ return parent::_prepareColumns();
40
+ }
41
+
42
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Report/Category.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Report_Category extends Mage_Adminhtml_Block_Widget_Grid_Container
8
+ {
9
+ public function __construct()
10
+ {
11
+ $this->_blockGroup = 'magentokey_newsletter';
12
+ $this->_controller = 'adminhtml_newsletter_report_category';
13
+ $this->_headerText = Mage::helper('magentokey_newsletter')->__('Magentokey Newsletter Category Reports');
14
+ parent::__construct();
15
+ $this->_removeButton('add');
16
+
17
+ }
18
+
19
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Report/Category/Grid.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Report_Category_Grid extends Mage_Adminhtml_Block_Report_Grid
8
+ {
9
+
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+ $this->setTemplate('magentokey/newsletter/report/grid.phtml');
14
+ $this->setId('gridNewsletterReport');
15
+ $this->setDefaultSort('added_at');
16
+ $this->setDefaultDir('asc');
17
+ }
18
+
19
+ protected function _prepareCollection()
20
+ {
21
+ parent::_prepareCollection();
22
+ $this->getCollection()->initReport('magentokey_newsletter/report_category');
23
+ }
24
+
25
+ protected function _prepareColumns()
26
+ {
27
+ $this->addColumn('category_id', array(
28
+ 'header' =>Mage::helper('magentokey_newsletter')->__('Category ID'),
29
+ 'index' =>'category_id',
30
+ ));
31
+
32
+ $this->addColumn('num', array(
33
+ 'header' =>Mage::helper('magentokey_newsletter')->__('Total'),
34
+ 'index' =>'num',
35
+ 'total' => 'sum',
36
+ ));
37
+
38
+ $this->addExportType('*/*/exportCsvCategory', Mage::helper('reports')->__('CSV'));
39
+ $this->addExportType('*/*/exportExcelCategory', Mage::helper('reports')->__('Excel XML'));
40
+
41
+ return parent::_prepareColumns();
42
+ }
43
+
44
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Report/Grid.php ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Report_Grid extends Mage_Adminhtml_Block_Report_Grid
8
+ {
9
+
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+ $this->setTemplate('magentokey/newsletter/report/grid.phtml');
14
+ $this->setId('gridNewsletterReportProduct');
15
+ }
16
+
17
+ protected function _prepareCollection()
18
+ {
19
+ parent::_prepareCollection();
20
+ $this->getCollection()->initReport('magentokey_newsletter/report_collection');
21
+ }
22
+
23
+ protected function _prepareColumns()
24
+ {
25
+ $this->addColumn('product_id', array(
26
+ 'header' =>Mage::helper('magentokey_newsletter')->__('Product Id'),
27
+ 'index' =>'product_id',
28
+ ));
29
+
30
+ $this->addColumn('num', array(
31
+ 'header' =>Mage::helper('magentokey_newsletter')->__('Total'),
32
+ 'index' =>'num',
33
+ 'total' => 'sum',
34
+ ));
35
+
36
+ $this->addExportType('*/*/exportCsv', Mage::helper('reports')->__('CSV'));
37
+ $this->addExportType('*/*/exportExcel', Mage::helper('reports')->__('Excel XML'));
38
+
39
+ return parent::_prepareColumns();
40
+ }
41
+
42
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Report/Type.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Report_Type extends Mage_Adminhtml_Block_Widget_Grid_Container
8
+ {
9
+ public function __construct()
10
+ {
11
+ $this->_blockGroup = 'magentokey_newsletter';
12
+ $this->_controller = 'adminhtml_newsletter_report_type';
13
+ $this->_headerText = Mage::helper('magentokey_newsletter')->__('Magentokey Newsletter Subscriber Type Reports');
14
+ parent::__construct();
15
+ $this->_removeButton('add');
16
+
17
+ }
18
+
19
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Report/Type/Grid.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Report_Type_Grid extends Mage_Adminhtml_Block_Report_Grid
8
+ {
9
+
10
+ public function __construct()
11
+ {
12
+ parent::__construct();
13
+ $this->setTemplate('magentokey/newsletter/report/grid.phtml');
14
+ $this->setId('gridNewsletterReport');
15
+ $this->setDefaultSort('added_at');
16
+ $this->setDefaultDir('asc');
17
+ }
18
+
19
+ protected function _prepareCollection()
20
+ {
21
+ parent::_prepareCollection();
22
+ $this->getCollection()->initReport('magentokey_newsletter/report_type');
23
+ }
24
+
25
+ protected function _prepareColumns()
26
+ {
27
+ $this->addColumn('subscriber_type', array(
28
+ 'header' =>Mage::helper('magentokey_newsletter')->__('Subscriber Type'),
29
+ 'index' =>'subscriber_type',
30
+ ));
31
+
32
+ $this->addColumn('num', array(
33
+ 'header' =>Mage::helper('magentokey_newsletter')->__('Total'),
34
+ 'index' =>'num',
35
+ 'total' => 'sum',
36
+ ));
37
+
38
+ $this->addExportType('*/*/exportCsvType', Mage::helper('reports')->__('CSV'));
39
+ $this->addExportType('*/*/exportExcelType', Mage::helper('reports')->__('Excel XML'));
40
+
41
+ return parent::_prepareColumns();
42
+ }
43
+
44
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Subscriber.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Subscriber extends Mage_Adminhtml_Block_Template
8
+ {
9
+ public function __construct()
10
+ {
11
+ parent::__construct();
12
+ $this->setTemplate('magentokey/newsletter/subscriber/index.phtml');
13
+ }
14
+
15
+ protected function _prepareLayout()
16
+ {
17
+ $this->setChild('grid', $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_subscriber_grid', 'newsletter.product.subscriber.grid'));
18
+ return parent::_prepareLayout();
19
+ }
20
+
21
+ public function getHeaderText()
22
+ {
23
+ return Mage::helper('magentokey_newsletter')->__('Magentokey Newsletter Subscribers');
24
+ }
25
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Subscriber/Grid.php ADDED
@@ -0,0 +1,204 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Subscriber_Grid extends Mage_Adminhtml_Block_Widget_Grid
8
+ {
9
+ /**
10
+ * Constructor
11
+ *
12
+ * Set main configuration of grid
13
+ */
14
+ public function __construct()
15
+ {
16
+ parent::__construct();
17
+ $this->setId('subscriberGrid');
18
+ $this->setUseAjax(true);
19
+ $this->setDefaultSort('subscriber_id', 'desc');
20
+ }
21
+
22
+ protected function _prepareCollection()
23
+ {
24
+ $collection = Mage::getResourceSingleton('magentokey_newsletter/subscriber_collection');
25
+ /* @var $collection Mage_Newsletter_Model_Mysql4_Subscriber_Collection */
26
+ $collection
27
+ ->showCustomerInfo(true)
28
+ ->addSubscriberTypeField()
29
+ ->showStoreInfo();
30
+ ;
31
+
32
+ if($this->getRequest()->getParam('queue', false)) {
33
+ $collection->useQueue(Mage::getModel('newsletter/queue')
34
+ ->load($this->getRequest()->getParam('queue')));
35
+ }
36
+
37
+ $this->setCollection($collection);
38
+
39
+ return parent::_prepareCollection();
40
+ }
41
+
42
+ protected function _prepareColumns()
43
+ {
44
+
45
+ $this->addColumn('subscriber_id', array(
46
+ 'header' => Mage::helper('magentokey_newsletter')->__('ID'),
47
+ 'index' => 'subscriber_id'
48
+ ));
49
+ $this->addColumn('category_id', array(
50
+ 'header' => Mage::helper('magentokey_newsletter')->__('Category ID'),
51
+ 'index' => 'category_id'
52
+ ));
53
+ $this->addColumn('product_id', array(
54
+ 'header' => Mage::helper('magentokey_newsletter')->__('Product ID'),
55
+ 'index' => 'product_id'
56
+ ));
57
+ $this->addColumn('subscriber_type', array(
58
+ 'header' => Mage::helper('magentokey_newsletter')->__('Newsletter Type'),
59
+ 'index' => 'subscriber_type',
60
+ 'type' => 'options',
61
+ 'renderer' => 'magentokey_newsletter/adminhtml_newsletter_subscriber_grid_renderer_type',
62
+ 'options' => array(
63
+ Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE => Mage::helper('magentokey_newsletter')->__('Product Update'),
64
+ Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION => Mage::helper('magentokey_newsletter')->__('Price Reduction'),
65
+ Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE => Mage::helper('magentokey_newsletter')->__('Stock Available'),
66
+ Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_NEW => Mage::helper('magentokey_newsletter')->__('New Products'),
67
+ Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_PRICE => Mage::helper('magentokey_newsletter')->__('Prices Reduction'),
68
+ ),
69
+ ));
70
+ $this->addColumn('email', array(
71
+ 'header' => Mage::helper('magentokey_newsletter')->__('Email'),
72
+ 'index' => 'subscriber_email'
73
+ ));
74
+
75
+ $this->addColumn('type', array(
76
+ 'header' => Mage::helper('magentokey_newsletter')->__('Type'),
77
+ 'index' => 'type',
78
+ 'type' => 'options',
79
+ 'options' => array(
80
+ 1 => Mage::helper('magentokey_newsletter')->__('Guest'),
81
+ 2 => Mage::helper('magentokey_newsletter')->__('Customer')
82
+ )
83
+ ));
84
+
85
+ $this->addColumn('firstname', array(
86
+ 'header' => Mage::helper('magentokey_newsletter')->__('Customer First Name'),
87
+ 'index' => 'customer_firstname',
88
+ 'default' => '----'
89
+ ));
90
+
91
+ $this->addColumn('lastname', array(
92
+ 'header' => Mage::helper('magentokey_newsletter')->__('Customer Last Name'),
93
+ 'index' => 'customer_lastname',
94
+ 'default' => '----'
95
+ ));
96
+
97
+ $this->addColumn('status', array(
98
+ 'header' => Mage::helper('magentokey_newsletter')->__('Status'),
99
+ 'index' => 'subscriber_status',
100
+ 'type' => 'options',
101
+ 'options' => array(
102
+ Mage_Newsletter_Model_Subscriber::STATUS_NOT_ACTIVE => Mage::helper('magentokey_newsletter')->__('Not Activated'),
103
+ Mage_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED => Mage::helper('magentokey_newsletter')->__('Subscribed'),
104
+ Mage_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED => Mage::helper('magentokey_newsletter')->__('Unsubscribed'),
105
+ Mage_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED => Mage::helper('magentokey_newsletter')->__('Unconfirmed'),
106
+ )
107
+ ));
108
+
109
+
110
+ /*$this->addColumn('website', array(
111
+ 'header' => Mage::helper('magentokey_newsletter')->__('Website'),
112
+ 'index' => 'website_id',
113
+ 'type' => 'options',
114
+ 'options' => $this->_getWebsiteOptions()
115
+ ));
116
+
117
+ $this->addColumn('group', array(
118
+ 'header' => Mage::helper('magentokey_newsletter')->__('Store'),
119
+ 'index' => 'group_id',
120
+ 'type' => 'options',
121
+ 'options' => $this->_getStoreGroupOptions()
122
+ ));*/
123
+
124
+ $this->addColumn('store', array(
125
+ 'header' => Mage::helper('magentokey_newsletter')->__('Store View'),
126
+ 'index' => 'store_id',
127
+ 'type' => 'options',
128
+ 'options' => $this->_getStoreOptions()
129
+ ));
130
+
131
+ $this->addExportType('*/*/exportCsv', Mage::helper('customer')->__('CSV'));
132
+ $this->addExportType('*/*/exportXml', Mage::helper('customer')->__('Excel XML'));
133
+ return parent::_prepareColumns();
134
+ }
135
+
136
+ /**
137
+ * Convert OptionsValue array to Options array
138
+ *
139
+ * @param array $optionsArray
140
+ * @return array
141
+ */
142
+ protected function _getOptions($optionsArray)
143
+ {
144
+ $options = array();
145
+ foreach ($optionsArray as $option) {
146
+ $options[$option['value']] = $option['label'];
147
+ }
148
+ return $options;
149
+ }
150
+
151
+ /**
152
+ * Retrieve Website Options array
153
+ *
154
+ * @return array
155
+ */
156
+ protected function _getWebsiteOptions()
157
+ {
158
+ return Mage::getModel('adminhtml/system_store')->getWebsiteOptionHash();
159
+ }
160
+
161
+ /**
162
+ * Retrieve Store Group Options array
163
+ *
164
+ * @return array
165
+ */
166
+ protected function _getStoreGroupOptions()
167
+ {
168
+ return Mage::getModel('adminhtml/system_store')->getStoreGroupOptionHash();
169
+ }
170
+
171
+ /**
172
+ * Retrieve Store Options array
173
+ *
174
+ * @return array
175
+ */
176
+ protected function _getStoreOptions()
177
+ {
178
+ return Mage::getModel('adminhtml/system_store')->getStoreOptionHash();
179
+ }
180
+
181
+ protected function _prepareMassaction()
182
+ {
183
+ $this->setMassactionIdField('subscriber_id');
184
+ $this->getMassactionBlock()->setFormFieldName('subscriber');
185
+
186
+ $this->getMassactionBlock()->addItem('unsubscribe', array(
187
+ 'label' => Mage::helper('magentokey_newsletter')->__('Unsubscribe'),
188
+ 'url' => $this->getUrl('*/*/massUnsubscribe'),
189
+ 'confirm' => Mage::helper('magentokey_newsletter')->__('Are you sure?')
190
+ ));
191
+
192
+ $this->getMassactionBlock()->addItem('delete', array(
193
+ 'label' => Mage::helper('magentokey_newsletter')->__('Delete'),
194
+ 'url' => $this->getUrl('*/*/massDelete'),
195
+ 'confirm' => Mage::helper('magentokey_newsletter')->__('Are you sure?')
196
+ ));
197
+ $this->getMassactionBlock()->addItem('active', array(
198
+ 'label' => Mage::helper('magentokey_newsletter')->__('Active'),
199
+ 'url' => $this->getUrl('*/*/massActive'),
200
+ 'confirm' => Mage::helper('magentokey_newsletter')->__('Are you sure?')
201
+ ));
202
+ return $this;
203
+ }
204
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Subscriber/Grid/Filter/Checkbox.php ADDED
@@ -0,0 +1,18 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Subscriber_Grid_Filter_Checkbox extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Abstract
8
+ {
9
+ public function getCondition()
10
+ {
11
+ return array();
12
+ }
13
+
14
+ public function getHtml()
15
+ {
16
+ return '<input type="checkbox" onclick="subscriberController.checkCheckboxes(this)"/>';
17
+ }
18
+ }// Class Mage_Adminhtml_Block_Newsletter_Subscriber_Grid_Filter_Checkbox END
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Subscriber/Grid/Filter/Website.php ADDED
@@ -0,0 +1,44 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Subscriber_Grid_Filter_Website extends Mage_Adminhtml_Block_Widget_Grid_Column_Filter_Select
8
+ {
9
+
10
+ protected $_websiteCollection = null;
11
+
12
+ protected function _getOptions()
13
+ {
14
+ $result = $this->getCollection()->toOptionArray();
15
+ array_unshift($result, array('label'=>null, 'value'=>null));
16
+ return $result;
17
+ }
18
+
19
+ public function getCollection()
20
+ {
21
+ if(is_null($this->_websiteCollection)) {
22
+ $this->_websiteCollection = Mage::getResourceModel('core/website_collection')
23
+ ->load();
24
+ }
25
+
26
+ Mage::register('website_collection', $this->_websiteCollection);
27
+
28
+ return $this->_websiteCollection;
29
+ }
30
+
31
+ public function getCondition()
32
+ {
33
+
34
+ $id = $this->getValue();
35
+ if(!$id) {
36
+ return null;
37
+ }
38
+
39
+ $website = Mage::app()->getWebsite($id);
40
+
41
+ return array('in'=>$website->getStoresIds(true));
42
+ }
43
+
44
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Subscriber/Grid/Renderer/Type.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Subscriber_Grid_Renderer_Type extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
8
+ {
9
+ public function render(Varien_Object $row)
10
+ {
11
+ $str = '';
12
+ $type = $row->getSubscriberType();
13
+
14
+ if ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE) {
15
+ $str = Mage::helper('magentokey_newsletter')->__('Product Update');
16
+ } elseif($type == Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION) {
17
+ $str = Mage::helper('magentokey_newsletter')->__('Price Reduction');
18
+ } elseif($type == Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE) {
19
+ $str = Mage::helper('magentokey_newsletter')->__('Stock Available');
20
+ } elseif($type == Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_NEW) {
21
+ $str = Mage::helper('magentokey_newsletter')->__('New Products');
22
+ } elseif($type == Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_PRICE) {
23
+ $str = Mage::helper('magentokey_newsletter')->__('Prices Reduction');
24
+ }
25
+ return $str;
26
+ }
27
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template.php ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Template extends Mage_Adminhtml_Block_Template
8
+ {
9
+ public function __construct()
10
+ {
11
+ parent::__construct();
12
+ $this->setTemplate('magentokey/newsletter/template/list.phtml');
13
+ }
14
+
15
+
16
+ protected function _prepareLayout()
17
+ {
18
+ $this->setChild('grid', $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_template_grid', 'newsletter.product.template.grid'));
19
+ return parent::_prepareLayout();
20
+ }
21
+
22
+ public function getProductCreateUrl()
23
+ {
24
+ return $this->getUrl('*/*/new', array('level'=>'product'));
25
+ }
26
+ public function getCategoryCreateUrl()
27
+ {
28
+ return $this->getUrl('*/*/new', array('level'=>'category'));
29
+ }
30
+ public function getHeaderText()
31
+ {
32
+ return Mage::helper('newsletter')->__('Magentokey Newsletter Templates');
33
+ }
34
+
35
+
36
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Edit.php ADDED
@@ -0,0 +1,376 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com>
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentkey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Template_Edit extends Mage_Adminhtml_Block_Widget
8
+ {
9
+ /**
10
+ * Edit Block model
11
+ *
12
+ * @var bool
13
+ */
14
+ protected $_editMode = false;
15
+
16
+ /**
17
+ * Retrieve template object
18
+ *
19
+ * @return Mage_Newsletter_Model_Template
20
+ */
21
+ public function getModel()
22
+ {
23
+ return Mage::registry('_current_product_template');
24
+ }
25
+
26
+ /**
27
+ * Preparing block layout
28
+ *
29
+ * @return Mage_Adminhtml_Block_Newsletter_Template_Edit
30
+ */
31
+ protected function _prepareLayout()
32
+ {
33
+ // Load Wysiwyg on demand and Prepare layout
34
+ if (Mage::getSingleton('cms/wysiwyg_config')->isEnabled() && ($block = $this->getLayout()->getBlock('head'))) {
35
+ $block->setCanLoadTinyMce(true);
36
+ }
37
+
38
+ $this->setChild('back_button',
39
+ $this->getLayout()->createBlock('adminhtml/widget_button')
40
+ ->setData(array(
41
+ 'label' => Mage::helper('magentokey_newsletter')->__('Back'),
42
+ 'onclick' => "window.location.href = '" . $this->getUrl('*/*') . "'",
43
+ 'class' => 'back'
44
+ ))
45
+ );
46
+
47
+ $this->setChild('reset_button',
48
+ $this->getLayout()->createBlock('adminhtml/widget_button')
49
+ ->setData(array(
50
+ 'label' => Mage::helper('magentokey_newsletter')->__('Reset'),
51
+ 'onclick' => 'window.location.href = window.location.href'
52
+ ))
53
+ );
54
+
55
+ $this->setChild('to_plain_button',
56
+ $this->getLayout()->createBlock('adminhtml/widget_button')
57
+ ->setData(array(
58
+ 'label' => Mage::helper('magentokey_newsletter')->__('Convert to Plain Text'),
59
+ 'onclick' => 'templateControl.stripTags();',
60
+ 'id' => 'convert_button',
61
+ 'class' => 'task'
62
+ ))
63
+ );
64
+
65
+ $this->setChild('to_html_button',
66
+ $this->getLayout()->createBlock('adminhtml/widget_button')
67
+ ->setData(array(
68
+ 'label' => Mage::helper('magentokey_newsletter')->__('Return HTML Version'),
69
+ 'onclick' => 'templateControl.unStripTags();',
70
+ 'id' => 'convert_button_back',
71
+ 'style' => 'display:none',
72
+ 'class' => 'task'
73
+ ))
74
+ );
75
+
76
+ $this->setChild('save_button',
77
+ $this->getLayout()->createBlock('adminhtml/widget_button')
78
+ ->setData(array(
79
+ 'label' => Mage::helper('magentokey_newsletter')->__('Save Template'),
80
+ 'onclick' => 'templateControl.save();',
81
+ 'class' => 'save'
82
+ ))
83
+ );
84
+ $this->setChild('preview_button',
85
+ $this->getLayout()->createBlock('adminhtml/widget_button')
86
+ ->setData(array(
87
+ 'label' => Mage::helper('magentokey_newsletter')->__('Preview Template'),
88
+ 'onclick' => 'templateControl.preview();',
89
+ 'class' => 'task'
90
+ ))
91
+ );
92
+
93
+ $this->setChild('delete_button',
94
+ $this->getLayout()->createBlock('adminhtml/widget_button')
95
+ ->setData(array(
96
+ 'label' => Mage::helper('magentokey_newsletter')->__('Delete Template'),
97
+ 'onclick' => 'templateControl.deleteTemplate();',
98
+ 'class' => 'delete'
99
+ ))
100
+ );
101
+ $level = $this->getRequest()->getParam('level');
102
+ if ($level == 'category') {
103
+ $this->setChild('subgrid', $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_template_edit_category', 'newsletter.template.category'));
104
+ } elseif($level == 'product') {
105
+ $this->setChild('subgrid', $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_template_edit_product', 'newsletter.template.product'));
106
+ }
107
+ return parent::_prepareLayout();
108
+ }
109
+ public function isLevel()
110
+ {
111
+ $level = $this->getRequest()->getParam('level');
112
+ if ($level == 'category' || $level == 'product') {
113
+ return true;
114
+ }
115
+ return false;
116
+ }
117
+ public function isCategoryLevel()
118
+ {
119
+ $level = $this->getRequest()->getParam('level');
120
+ if ($level == 'category') {
121
+ return 1;
122
+ }
123
+ return 0;
124
+ }
125
+ public function getSubHeaderText()
126
+ {
127
+ $level = $this->getRequest()->getParam('level');
128
+ if ($level == 'category') {
129
+ return Mage::helper('magentokey_newsletter')->__('Choose Categories');
130
+ } elseif ($level == 'product') {
131
+ return Mage::helper('magentokey_newsletter')->__('Choose Products');
132
+ }
133
+ $model = $this->getModel();
134
+ if ($model->getId()) {
135
+ $productId = $model->getTemplateProductId();
136
+ $categoryId = $model->getTemplateCategoryId();
137
+ if ($productId) {
138
+ return Mage::helper('magentokey_newsletter')->__('Product Template');
139
+ } elseif ($categoryId) {
140
+ return Mage::helper('magentokey_newsletter')->__('Category Template');
141
+ }
142
+ }
143
+ }
144
+ public function getFieldHeadLabel()
145
+ {
146
+ $model = $this->getModel();
147
+ if ($model->getId()) {
148
+ $productId = $model->getTemplateProductId();
149
+ $categoryId = $model->getTemplateCategoryId();
150
+ if ($productId) {
151
+ return Mage::helper('magentokey_newsletter')->__('Product');
152
+ } elseif ($categoryId) {
153
+ return Mage::helper('magentokey_newsletter')->__('Category');
154
+ }
155
+ }
156
+ }
157
+ public function getFieldHeadText()
158
+ {
159
+ $model = $this->getModel();
160
+ if ($model->getId()) {
161
+ $productId = $model->getTemplateProductId();
162
+ $categoryId = $model->getTemplateCategoryId();
163
+ if ($productId) {
164
+ $productModel = Mage::getModel('catalog/product')->load($productId);
165
+ return $productId."[".$productModel->getName()."]";
166
+ } elseif ($categoryId) {
167
+ $categoryModel = Mage::getModel('catalog/category')->load($categoryId);
168
+ return $categoryId."[".$categoryModel->getName()."]";
169
+ }
170
+ }
171
+ }
172
+ /**
173
+ * Retrieve Back Button HTML
174
+ *
175
+ * @return string
176
+ */
177
+ public function getBackButtonHtml()
178
+ {
179
+ return $this->getChildHtml('back_button');
180
+ }
181
+
182
+ /**
183
+ * Retrieve Reset Button HTML
184
+ *
185
+ * @return string
186
+ */
187
+ public function getResetButtonHtml()
188
+ {
189
+ return $this->getChildHtml('reset_button');
190
+ }
191
+
192
+ /**
193
+ * Retrieve Convert To Plain Button HTML
194
+ *
195
+ * @return string
196
+ */
197
+ public function getToPlainButtonHtml()
198
+ {
199
+ return $this->getChildHtml('to_plain_button');
200
+ }
201
+
202
+ /**
203
+ * Retrieve Convert to HTML Button HTML
204
+ *
205
+ * @return string
206
+ */
207
+ public function getToHtmlButtonHtml()
208
+ {
209
+ return $this->getChildHtml('to_html_button');
210
+ }
211
+
212
+ /**
213
+ * Retrieve Save Button HTML
214
+ *
215
+ * @return string
216
+ */
217
+ public function getSaveButtonHtml()
218
+ {
219
+ return $this->getChildHtml('save_button');
220
+ }
221
+
222
+ /**
223
+ * Retrieve Preview Button HTML
224
+ *
225
+ * @return string
226
+ */
227
+ public function getPreviewButtonHtml()
228
+ {
229
+ return $this->getChildHtml('preview_button');
230
+ }
231
+
232
+ /**
233
+ * Retrieve Delete Button HTML
234
+ *
235
+ * @return string
236
+ */
237
+ public function getDeleteButtonHtml()
238
+ {
239
+ return $this->getChildHtml('delete_button');
240
+ }
241
+
242
+ /**
243
+ * Set edit flag for block
244
+ *
245
+ * @param boolean $value
246
+ * @return Mage_Adminhtml_Block_Newsletter_Template_Edit
247
+ */
248
+ public function setEditMode($value = true)
249
+ {
250
+ $this->_editMode = (bool)$value;
251
+ return $this;
252
+ }
253
+
254
+ /**
255
+ * Return edit flag for block
256
+ *
257
+ * @return boolean
258
+ */
259
+ public function getEditMode()
260
+ {
261
+ return $this->_editMode;
262
+ }
263
+
264
+ /**
265
+ * Return header text for form
266
+ *
267
+ * @return string
268
+ */
269
+ public function getHeaderText()
270
+ {
271
+ if ($this->getEditMode()) {
272
+ return Mage::helper('magentokey_newsletter')->__('Edit Newsletter Template');
273
+ }
274
+
275
+ return Mage::helper('magentokey_newsletter')->__('New Newsletter Template');
276
+ }
277
+
278
+ /**
279
+ * Return form block HTML
280
+ *
281
+ * @return string
282
+ */
283
+ public function getForm()
284
+ {
285
+ return $this->getLayout()
286
+ ->createBlock('magentokey_newsletter/adminhtml_newsletter_template_edit_form')
287
+ ->toHtml();
288
+ }
289
+
290
+ /**
291
+ * Return return template name for JS
292
+ *
293
+ * @return string
294
+ */
295
+ public function getJsTemplateName()
296
+ {
297
+ return addcslashes($this->getModel()->getTemplateCode(), "\"\r\n\\");
298
+ }
299
+
300
+ /**
301
+ * Return action url for form
302
+ *
303
+ * @return string
304
+ */
305
+ public function getSaveUrl()
306
+ {
307
+ $level = $this->getRequest()->getParam('level');
308
+ if ($level) {
309
+ return $this->getUrl('*/*/save', array('level'=>$level));
310
+ } else {
311
+ return $this->getUrl('*/*/save');
312
+ }
313
+
314
+
315
+ }
316
+
317
+ /**
318
+ * Return preview action url for form
319
+ *
320
+ * @return string
321
+ */
322
+ public function getPreviewUrl()
323
+ {
324
+ return $this->getUrl('*/*/preview');
325
+ }
326
+
327
+ /**
328
+ * Check Template Type is Plain Text
329
+ *
330
+ * @return bool
331
+ */
332
+ public function isTextType()
333
+ {
334
+ return $this->getModel()->isPlain();
335
+ }
336
+
337
+ /**
338
+ * Return delete url for customer group
339
+ *
340
+ * @return string
341
+ */
342
+ public function getDeleteUrl()
343
+ {
344
+ return $this->getUrl('*/*/delete', array('id' => $this->getRequest()->getParam('id')));
345
+ }
346
+
347
+ /**
348
+ * Retrieve Save As Flag
349
+ *
350
+ * @return int
351
+ */
352
+ public function getSaveAsFlag()
353
+ {
354
+ return $this->getRequest()->getParam('_save_as_flag') ? '1' : '';
355
+ }
356
+
357
+ /**
358
+ * Getter for single store mode check
359
+ *
360
+ * @return boolean
361
+ */
362
+ protected function isSingleStoreMode()
363
+ {
364
+ return Mage::app()->isSingleStoreMode();
365
+ }
366
+
367
+ /**
368
+ * Getter for id of current store (the only one in single-store mode and current in multi-stores mode)
369
+ *
370
+ * @return boolean
371
+ */
372
+ protected function getStoreId()
373
+ {
374
+ return Mage::app()->getStore(true)->getId();
375
+ }
376
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Edit/Category.php ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com>
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentkey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Template_Edit_Category extends Mage_Adminhtml_Block_Widget_Grid
8
+ {
9
+ protected function _construct()
10
+ {
11
+ $this->setEmptyText(Mage::helper('magentokey_newsletter')->__('No Category Found'));
12
+ $this->setUseAjax(true);
13
+ $this->setId('categoryGrid');
14
+ $this->setDefaultSort('entity_id');
15
+ $this->setSaveParametersInSession(true);
16
+
17
+ }
18
+
19
+ protected function _prepareCollection()
20
+ {
21
+ $this->setTemplate('magentokey/newsletter/widget/grid.phtml');
22
+ $category = Mage::getModel('catalog/category');
23
+ $tree = $category->getTreeModel();
24
+ $tree->load();
25
+ $collection = $tree->getCollection()->addAttributeToFilter('name',array('notnull'=>1));
26
+ $this->setCollection($collection);
27
+ return parent::_prepareCollection();
28
+ }
29
+
30
+ protected function _prepareColumns()
31
+ {
32
+ $this->addColumn('category_id', array(
33
+ 'header' => Mage::helper('catalog')->__('Category ID'),
34
+ 'sortable' => true,
35
+ 'width' => '60',
36
+ 'index' => 'entity_id'
37
+ ));
38
+ $this->addColumn('name', array(
39
+ 'header' => Mage::helper('catalog')->__('Name'),
40
+ 'index' => 'name'
41
+ ));
42
+
43
+ return parent::_prepareColumns();
44
+ }
45
+
46
+ protected function _prepareMassaction()
47
+ {
48
+ $this->setMassactionIdField('category_id');
49
+ $this->getMassactionBlock()->setFormFieldName('category_id[]');
50
+ $this->getMassactionBlock()->setTemplate('magentokey/newsletter/widget/grid/massaction.phtml');
51
+ $this->getMassactionBlock()->addItem('Disable', array(
52
+ 'label' => Mage::helper('magentokey_newsletter')->__('DisableDisableDisable'),
53
+ 'url' => $this->getUrl('*/*/disable')
54
+ ));
55
+ return $this;
56
+ }
57
+ public function getGridUrl()
58
+ {
59
+ return $this->getUrl('*/*/categorygrid', array('_current'=> true));
60
+ }
61
+ }
62
+
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Edit/Form.php ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com>
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentkey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Template_Edit_Form extends Mage_Adminhtml_Block_Widget_Form
8
+ {
9
+ /**
10
+ * Define Form settings
11
+ *
12
+ */
13
+ public function __construct()
14
+ {
15
+ parent::__construct();
16
+ }
17
+
18
+ /**
19
+ * Retrieve template object
20
+ *
21
+ * @return Magentokey_Newsletter_Model_Template
22
+ */
23
+ public function getModel()
24
+ {
25
+ return Mage::registry('_current_product_template');
26
+ }
27
+
28
+ /**
29
+ * Prepare form before rendering HTML
30
+ *
31
+ * @return Magentokey_Newsletter_Block_Adminhtml_Newsletter_Template_Edit_Form
32
+ */
33
+ protected function _prepareForm()
34
+ {
35
+ $model = $this->getModel();
36
+ $identity = Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY);
37
+ $identityName = Mage::getStoreConfig('trans_email/ident_'.$identity.'/name');
38
+ $identityEmail = Mage::getStoreConfig('trans_email/ident_'.$identity.'/email');
39
+ $form = new Varien_Data_Form(array(
40
+ 'id' => 'edit_form',
41
+ 'action' => $this->getData('action'),
42
+ 'method' => 'post'
43
+ ));
44
+
45
+ $fieldset = $form->addFieldset('base_fieldset', array(
46
+ 'legend' => Mage::helper('magentokey_newsletter')->__('Template Information'),
47
+ 'class' => 'fieldset-wide'
48
+ ));
49
+
50
+ if ($model->getId()) {
51
+ $fieldset->addField('id', 'hidden', array(
52
+ 'name' => 'id',
53
+ 'value' => $model->getId(),
54
+ ));
55
+ }
56
+
57
+ $fieldset->addField('code', 'text', array(
58
+ 'name' => 'code',
59
+ 'label' => Mage::helper('magentokey_newsletter')->__('Template Name'),
60
+ 'title' => Mage::helper('magentokey_newsletter')->__('Template Name'),
61
+ 'required' => true,
62
+ 'value' => $model->getTemplateCode(),
63
+ ));
64
+ $fieldset->addField('subject', 'text', array(
65
+ 'name' => 'subject',
66
+ 'label' => Mage::helper('magentokey_newsletter')->__('Template Subject'),
67
+ 'title' => Mage::helper('magentokey_newsletter')->__('Template Subject'),
68
+ 'required' => true,
69
+ 'value' => $model->getTemplateSubject(),
70
+ ));
71
+ $options = array(
72
+ '' => Mage::helper('magentokey_newsletter')->__(' - Please Select - '),
73
+ Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION => Mage::helper('magentokey_newsletter')->__('Price Reduction Notification'),
74
+ Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE => Mage::helper('magentokey_newsletter')->__('Stock Available Notification'),
75
+ Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE => Mage::helper('magentokey_newsletter')->__('Product Update Notification'),
76
+
77
+ );
78
+ $categoryId = $model->getTemplateCategoryId();
79
+ if ($categoryId) {
80
+ $options[Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_NEW] = Mage::helper('magentokey_newsletter')->__('New Products Notification');
81
+ }
82
+ $fieldset->addField('template_subscriber_type', 'select', array(
83
+ 'name' => 'template_subscriber_type',
84
+ 'label' => Mage::helper('magentokey_newsletter')->__('Subscriber Type'),
85
+ 'title' => Mage::helper('magentokey_newsletter')->__('Subscriber Type'),
86
+ 'required' => true,
87
+ 'options' => $options,
88
+ 'value' => Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION,
89
+
90
+ ));
91
+ $dateFormatIso = Mage::app()->getLocale()->getDateFormat(
92
+ Mage_Core_Model_Locale::FORMAT_TYPE_SHORT
93
+ );
94
+ $fieldset->addField('start_at', 'date', array(
95
+ 'name' => 'start_at',
96
+ 'label' => Mage::helper('cms')->__('Date From'),
97
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
98
+ 'format' => $dateFormatIso,
99
+ 'required' => true,
100
+ 'value' => $model->getStartAt(),
101
+ ));
102
+ $fieldset->addField('end_at', 'date', array(
103
+ 'name' => 'end_at',
104
+ 'label' => Mage::helper('cms')->__('Date To'),
105
+ 'image' => $this->getSkinUrl('images/grid-cal.gif'),
106
+ 'format' => $dateFormatIso,
107
+ 'required' => true,
108
+ 'value' => $model->getEndAt(),
109
+ ));
110
+ $fieldset->addField('template_position', 'text', array(
111
+ 'name' => 'template_position',
112
+ 'label' => Mage::helper('magentokey_newsletter')->__('Template Position'),
113
+ 'title' => Mage::helper('magentokey_newsletter')->__('Template Position'),
114
+ 'required' => false,
115
+ 'style' => 'width:110px !important;',
116
+ 'value' => $model->getTemplatePosition(),
117
+ ));
118
+ $fieldset->addField('template_memo', 'text', array(
119
+ 'name' => 'template_memo',
120
+ 'label' => Mage::helper('magentokey_newsletter')->__('Template Memo'),
121
+ 'title' => Mage::helper('magentokey_newsletter')->__('Template Memo'),
122
+ 'required' => false,
123
+ 'value' => $model->getTemplateMemo(),
124
+ ));
125
+
126
+
127
+ $fieldset->addField('sender_name', 'text', array(
128
+ 'name' =>'sender_name',
129
+ 'label' => Mage::helper('magentokey_newsletter')->__('Sender Name'),
130
+ 'title' => Mage::helper('magentokey_newsletter')->__('Sender Name'),
131
+ 'required' => true,
132
+ 'value' => $model->getId() !== null
133
+ ? $model->getTemplateSenderName()
134
+ : $identityName,
135
+ ));
136
+
137
+ $fieldset->addField('sender_email', 'text', array(
138
+ 'name' =>'sender_email',
139
+ 'label' => Mage::helper('magentokey_newsletter')->__('Sender Email'),
140
+ 'title' => Mage::helper('magentokey_newsletter')->__('Sender Email'),
141
+ 'class' => 'validate-email',
142
+ 'required' => true,
143
+ 'value' => $model->getId() !== null
144
+ ? $model->getTemplateSenderEmail()
145
+ : $identityEmail
146
+ ));
147
+
148
+
149
+ $widgetFilters = array('is_email_compatible' => 1);
150
+ $wysiwygConfig = Mage::getSingleton('cms/wysiwyg_config')->getConfig(array('widget_filters' => $widgetFilters));
151
+ if ($model->isPlain()) {
152
+ $wysiwygConfig->setEnabled(false);
153
+ }
154
+ $fieldset->addField('text', 'editor', array(
155
+ 'name' => 'text',
156
+ 'label' => Mage::helper('magentokey_newsletter')->__('Template Content'),
157
+ 'title' => Mage::helper('magentokey_newsletter')->__('Template Content'),
158
+ 'required' => true,
159
+ 'state' => 'html',
160
+ 'style' => 'height:36em;',
161
+ 'value' => $model->getTemplateText(),
162
+ 'config' => $wysiwygConfig
163
+ ));
164
+
165
+ if (!$model->isPlain()) {
166
+ $fieldset->addField('template_styles', 'textarea', array(
167
+ 'name' =>'styles',
168
+ 'label' => Mage::helper('magentokey_newsletter')->__('Template Styles'),
169
+ 'container_id' => 'field_template_styles',
170
+ 'value' => $model->getTemplateStyles()
171
+ ));
172
+ }
173
+ $this->setForm($form);
174
+
175
+ return parent::_prepareForm();
176
+ }
177
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Edit/Product.php ADDED
@@ -0,0 +1,203 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com>
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentkey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Template_Edit_Product extends Mage_Adminhtml_Block_Widget_Grid
8
+ {
9
+ protected function _getStore()
10
+ {
11
+ $storeId = (int) $this->getRequest()->getParam('store', 0);
12
+ return Mage::app()->getStore($storeId);
13
+ }
14
+ protected function _construct()
15
+ {
16
+ $this->setEmptyText(Mage::helper('magentokey_newsletter')->__('No Product Found'));
17
+ $this->setUseAjax(true);
18
+ $this->setId('productGrid');
19
+ $this->setDefaultSort('entity_id');
20
+ $this->setSaveParametersInSession(true);
21
+ }
22
+
23
+ protected function _prepareCollection()
24
+ {
25
+ $this->setTemplate('magentokey/newsletter/widget/grid.phtml');
26
+ $store = $this->_getStore();
27
+ $collection = Mage::getModel('catalog/product')->getCollection()
28
+ ->addAttributeToSelect('sku')
29
+ ->addAttributeToSelect('name')
30
+ ->addAttributeToSelect('attribute_set_id')
31
+ ->addAttributeToSelect('type_id');
32
+
33
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
34
+ $collection->joinField('qty',
35
+ 'cataloginventory/stock_item',
36
+ 'qty',
37
+ 'product_id=entity_id',
38
+ '{{table}}.stock_id=1',
39
+ 'left');
40
+ }
41
+ if ($store->getId()) {
42
+ //$collection->setStoreId($store->getId());
43
+ $adminStore = Mage_Core_Model_App::ADMIN_STORE_ID;
44
+ $collection->addStoreFilter($store);
45
+ $collection->joinAttribute('name', 'catalog_product/name', 'entity_id', null, 'inner', $adminStore);
46
+ $collection->joinAttribute('custom_name', 'catalog_product/name', 'entity_id', null, 'inner', $store->getId());
47
+ $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner', $store->getId());
48
+ $collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner', $store->getId());
49
+ $collection->joinAttribute('price', 'catalog_product/price', 'entity_id', null, 'left', $store->getId());
50
+ }
51
+ else {
52
+ $collection->addAttributeToSelect('price');
53
+ $collection->joinAttribute('status', 'catalog_product/status', 'entity_id', null, 'inner');
54
+ $collection->joinAttribute('visibility', 'catalog_product/visibility', 'entity_id', null, 'inner');
55
+ }
56
+
57
+ $this->setCollection($collection);
58
+
59
+ parent::_prepareCollection();
60
+ $this->getCollection()->addWebsiteNamesToResult();
61
+ return $this;
62
+ }
63
+ protected function _addColumnFilterToCollection($column)
64
+ {
65
+ if ($this->getCollection()) {
66
+ if ($column->getId() == 'websites') {
67
+ $this->getCollection()->joinField('websites',
68
+ 'catalog/product_website',
69
+ 'website_id',
70
+ 'product_id=entity_id',
71
+ null,
72
+ 'left');
73
+ }
74
+ }
75
+ return parent::_addColumnFilterToCollection($column);
76
+ }
77
+ protected function _prepareColumns()
78
+ {
79
+ $this->addColumn('entity_id',
80
+ array(
81
+ 'header'=> Mage::helper('catalog')->__('ID'),
82
+ 'width' => '50px',
83
+ 'type' => 'number',
84
+ 'index' => 'entity_id',
85
+ ));
86
+ $this->addColumn('name',
87
+ array(
88
+ 'header'=> Mage::helper('catalog')->__('Name'),
89
+ 'index' => 'name',
90
+ ));
91
+
92
+ $store = $this->_getStore();
93
+ if ($store->getId()) {
94
+ $this->addColumn('custom_name',
95
+ array(
96
+ 'header'=> Mage::helper('catalog')->__('Name in %s', $store->getName()),
97
+ 'index' => 'custom_name',
98
+ ));
99
+ }
100
+
101
+ $this->addColumn('type',
102
+ array(
103
+ 'header'=> Mage::helper('catalog')->__('Type'),
104
+ 'width' => '60px',
105
+ 'index' => 'type_id',
106
+ 'type' => 'options',
107
+ 'options' => Mage::getSingleton('catalog/product_type')->getOptionArray(),
108
+ ));
109
+
110
+ $sets = Mage::getResourceModel('eav/entity_attribute_set_collection')
111
+ ->setEntityTypeFilter(Mage::getModel('catalog/product')->getResource()->getTypeId())
112
+ ->load()
113
+ ->toOptionHash();
114
+
115
+ $this->addColumn('set_name',
116
+ array(
117
+ 'header'=> Mage::helper('catalog')->__('Attrib. Set Name'),
118
+ 'width' => '100px',
119
+ 'index' => 'attribute_set_id',
120
+ 'type' => 'options',
121
+ 'options' => $sets,
122
+ ));
123
+
124
+ $this->addColumn('sku',
125
+ array(
126
+ 'header'=> Mage::helper('catalog')->__('SKU'),
127
+ 'width' => '80px',
128
+ 'index' => 'sku',
129
+ ));
130
+
131
+ $store = $this->_getStore();
132
+ $this->addColumn('price',
133
+ array(
134
+ 'header'=> Mage::helper('catalog')->__('Price'),
135
+ 'type' => 'price',
136
+ 'currency_code' => $store->getBaseCurrency()->getCode(),
137
+ 'index' => 'price',
138
+ ));
139
+
140
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_CatalogInventory')) {
141
+ $this->addColumn('qty',
142
+ array(
143
+ 'header'=> Mage::helper('catalog')->__('Qty'),
144
+ 'width' => '100px',
145
+ 'type' => 'number',
146
+ 'index' => 'qty',
147
+ ));
148
+ }
149
+
150
+ $this->addColumn('visibility',
151
+ array(
152
+ 'header'=> Mage::helper('catalog')->__('Visibility'),
153
+ 'width' => '70px',
154
+ 'index' => 'visibility',
155
+ 'type' => 'options',
156
+ 'options' => Mage::getModel('catalog/product_visibility')->getOptionArray(),
157
+ ));
158
+
159
+ $this->addColumn('status',
160
+ array(
161
+ 'header'=> Mage::helper('catalog')->__('Status'),
162
+ 'width' => '70px',
163
+ 'index' => 'status',
164
+ 'type' => 'options',
165
+ 'options' => Mage::getSingleton('catalog/product_status')->getOptionArray(),
166
+ ));
167
+
168
+ if (!Mage::app()->isSingleStoreMode()) {
169
+ $this->addColumn('websites',
170
+ array(
171
+ 'header'=> Mage::helper('catalog')->__('Websites'),
172
+ 'width' => '100px',
173
+ 'sortable' => false,
174
+ 'index' => 'websites',
175
+ 'type' => 'options',
176
+ 'options' => Mage::getModel('core/website')->getCollection()->toOptionHash(),
177
+ ));
178
+ }
179
+
180
+ if (Mage::helper('catalog')->isModuleEnabled('Mage_Rss')) {
181
+ $this->addRssList('rss/catalog/notifystock', Mage::helper('catalog')->__('Notify Low Stock RSS'));
182
+ }
183
+
184
+ return parent::_prepareColumns();
185
+ }
186
+ protected function _prepareMassaction()
187
+ {
188
+ $this->setMassactionIdField('product_id');
189
+ $this->getMassactionBlock()->setFormFieldName('product_id[]');
190
+ $this->getMassactionBlock()->setTemplate('magentokey/newsletter/widget/grid/massaction.phtml');
191
+ $this->getMassactionBlock()->addItem('Disable', array(
192
+ 'label' => Mage::helper('magentokey_newsletter')->__('DisableDisableDisable'),
193
+ 'url' => $this->getUrl('*/*/disable')
194
+ ));
195
+ return $this;
196
+ }
197
+ public function getGridUrl()
198
+ {
199
+ return $this->getUrl('*/*/productgrid', array('_current'=> true));
200
+ }
201
+
202
+ }
203
+
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Grid.php ADDED
@@ -0,0 +1,174 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com>
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Template_Grid extends Mage_Adminhtml_Block_Widget_Grid
8
+ {
9
+ public function __construct()
10
+ {
11
+ parent::__construct();
12
+ $this->setId('templateGrid');
13
+ $this->setDefaultSort('template_id', 'desc');
14
+ }
15
+ protected function _construct()
16
+ {
17
+ $this->setEmptyText(Mage::helper('magentokey_newsletter')->__('No Templates Found'));
18
+
19
+ }
20
+
21
+ protected function _prepareCollection()
22
+ {
23
+ $collection = Mage::getResourceSingleton('magentokey_newsletter/template_collection')
24
+ ->useOnlyActual();
25
+ $this->setCollection($collection);
26
+
27
+ return parent::_prepareCollection();
28
+ }
29
+
30
+ protected function _prepareColumns()
31
+ {
32
+ $this->addColumn('template_id',
33
+ array(
34
+ 'header'=>Mage::helper('magentokey_newsletter')->__('ID'),
35
+ 'align'=>'center',
36
+ 'index'=>'template_id'
37
+ ));
38
+ $this->addColumn('code',
39
+ array(
40
+ 'header'=>Mage::helper('magentokey_newsletter')->__('Template Name'),
41
+ 'index'=>'template_code'
42
+ ));
43
+ $this->addColumn('template_subscriber_type',
44
+ array(
45
+ 'header'=>Mage::helper('magentokey_newsletter')->__('Subscriber Type'),
46
+ 'index'=>'template_subscriber_type',
47
+ 'type' => 'options',
48
+ 'renderer' => 'magentokey_newsletter/adminhtml_newsletter_template_grid_renderer_type',
49
+ 'options' => array(
50
+ Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE => Mage::helper('magentokey_newsletter')->__('Product Update'),
51
+ Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION => Mage::helper('magentokey_newsletter')->__('Price Reduction'),
52
+ Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE => Mage::helper('magentokey_newsletter')->__('Stock Available'),
53
+ Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_NEW => Mage::helper('magentokey_newsletter')->__('New Products'),
54
+ ),
55
+ ));
56
+ $this->addColumn('template_category_id',
57
+ array(
58
+ 'header'=>Mage::helper('magentokey_newsletter')->__('CId'),
59
+ 'index'=>'template_category_id',
60
+ 'renderer' => 'magentokey_newsletter/adminhtml_newsletter_template_grid_renderer_category',
61
+ ));
62
+ $this->addColumn('template_product_id',
63
+ array(
64
+ 'header'=>Mage::helper('magentokey_newsletter')->__('PId'),
65
+ 'index'=>'template_product_id',
66
+ 'renderer' => 'magentokey_newsletter/adminhtml_newsletter_template_grid_renderer_product',
67
+ ));
68
+ $this->addColumn('start_at',
69
+ array(
70
+ 'header'=>Mage::helper('magentokey_newsletter')->__('Start At'),
71
+ 'index'=>'start_at',
72
+ 'gmtoffset' => true,
73
+ 'type'=>'date',
74
+ 'width'=>'40'
75
+ ));
76
+ $this->addColumn('end_at',
77
+ array(
78
+ 'header'=>Mage::helper('magentokey_newsletter')->__('End At'),
79
+ 'index'=>'end_at',
80
+ 'gmtoffset' => true,
81
+ 'type'=>'date',
82
+ 'width'=>'40'
83
+ ));
84
+ $this->addColumn('added_at',
85
+ array(
86
+ 'header'=>Mage::helper('magentokey_newsletter')->__('Date Added'),
87
+ 'index'=>'added_at',
88
+ 'gmtoffset' => true,
89
+ 'type'=>'datetime'
90
+ ));
91
+
92
+ $this->addColumn('modified_at',
93
+ array(
94
+ 'header'=>Mage::helper('magentokey_newsletter')->__('Date Updated'),
95
+ 'index'=>'modified_at',
96
+ 'gmtoffset' => true,
97
+ 'type'=>'datetime'
98
+ ));
99
+
100
+ $this->addColumn('type',
101
+ array(
102
+ 'header'=>Mage::helper('magentokey_newsletter')->__('Type'),
103
+ 'index'=>'template_type',
104
+ 'type' => 'options',
105
+ 'options' => array(
106
+ Magentokey_Newsletter_Model_Template::TYPE_HTML => 'html',
107
+ Magentokey_Newsletter_Model_Template::TYPE_TEXT => 'text'
108
+ ),
109
+ ));
110
+ $this->addColumn('position',
111
+ array(
112
+ 'header'=>Mage::helper('magentokey_newsletter')->__('Position'),
113
+ 'index'=>'template_position',
114
+ 'width' => '10',
115
+ ));
116
+ $this->addColumn('status',
117
+ array(
118
+ 'header'=>Mage::helper('magentokey_newsletter')->__('Status'),
119
+ 'index'=>'template_status',
120
+ 'type' => 'options',
121
+ 'options' => array(
122
+ Magentokey_Newsletter_Model_Template::STATUS_ENABLE => 'Enable',
123
+ Magentokey_Newsletter_Model_Template::STATUS_DISABLE => 'Disable'
124
+ ),
125
+ ));
126
+ $this->addColumn('action',
127
+ array(
128
+ 'header' => Mage::helper('newsletter')->__('Action'),
129
+ 'index' =>'template_id',
130
+ 'sortable' =>false,
131
+ 'filter' => false,
132
+ 'no_link' => true,
133
+ 'width' => '50',
134
+ 'renderer' => 'magentokey_newsletter/adminhtml_newsletter_template_grid_renderer_action'
135
+ ));
136
+ $this->addColumn('sender',
137
+ array(
138
+ 'header'=>Mage::helper('newsletter')->__('Sender'),
139
+ 'index'=>'template_sender_email',
140
+ 'renderer' => 'magentokey_newsletter/adminhtml_newsletter_template_grid_renderer_sender'
141
+ ));
142
+ return $this;
143
+ }
144
+ protected function _prepareMassaction()
145
+ {
146
+ $this->setMassactionIdField('template_id');
147
+ $this->getMassactionBlock()->setFormFieldName('template');
148
+
149
+ $this->getMassactionBlock()->addItem('enable', array(
150
+ 'label' => Mage::helper('magentokey_newsletter')->__('Enable'),
151
+ 'url' => $this->getUrl('*/*/massEnable'),
152
+ 'confirm' => Mage::helper('magentokey_newsletter')->__('Are you sure?')
153
+ ));
154
+
155
+ $this->getMassactionBlock()->addItem('disable', array(
156
+ 'label' => Mage::helper('magentokey_newsletter')->__('Disable'),
157
+ 'url' => $this->getUrl('*/*/massDisable'),
158
+ 'confirm' => Mage::helper('magentokey_newsletter')->__('Are you sure?')
159
+ ));
160
+ $this->getMassactionBlock()->addItem('delete', array(
161
+ 'label' => Mage::helper('magentokey_newsletter')->__('Delete'),
162
+ 'url' => $this->getUrl('*/*/massDelete'),
163
+ 'confirm' => Mage::helper('magentokey_newsletter')->__('Are you sure?')
164
+ ));
165
+ return $this;
166
+ }
167
+ public function getRowUrl($row)
168
+ {
169
+ return $this->getUrl('*/*/edit', array('id'=>$row->getId()));
170
+ }
171
+
172
+
173
+ }
174
+
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Grid/Renderer/Action.php ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com>
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Template_Grid_Renderer_Action extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Action
8
+ {
9
+ /**
10
+ * Renderer for "Action" column in Newsletter templates grid
11
+ *
12
+ * @var Magentokey_Newsletter_Model_Template $row
13
+ * @return string
14
+ */
15
+ public function render(Varien_Object $row)
16
+ {
17
+ $actions[] = array(
18
+ 'url' => $this->getUrl('*/*/preview', array('id'=>$row->getId())),
19
+ 'popup' => true,
20
+ 'caption' => Mage::helper('magentokey_newsletter')->__('Preview')
21
+ );
22
+
23
+ $this->getColumn()->setActions($actions);
24
+
25
+ return parent::render($row);
26
+ }
27
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Grid/Renderer/Category.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com>
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentkey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Template_Grid_Renderer_Category extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
8
+ {
9
+ public function render(Varien_Object $row)
10
+ {
11
+ $id = $row->getTemplateCategoryId();
12
+ return $id;
13
+ }
14
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Grid/Renderer/Product.php ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Template_Grid_Renderer_Product extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
8
+ {
9
+ public function render(Varien_Object $row)
10
+ {
11
+ $id = $row->getTemplateProductId();
12
+ return $id;
13
+ }
14
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Grid/Renderer/Sender.php ADDED
@@ -0,0 +1,23 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com>
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Template_Grid_Renderer_Sender extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
8
+ {
9
+ public function render(Varien_Object $row)
10
+ {
11
+ $str = '';
12
+ if($row->getTemplateSenderName()) {
13
+ $str .= htmlspecialchars($row->getTemplateSenderName()) . ' ';
14
+ }
15
+ if($row->getTemplateSenderEmail()) {
16
+ $str .= '[' . $row->getTemplateSenderEmail() . ']';
17
+ }
18
+ if($str == '') {
19
+ $str .= '---';
20
+ }
21
+ return $str;
22
+ }
23
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Grid/Renderer/Type.php ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com>
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Template_Grid_Renderer_Type extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
8
+ {
9
+ public function render(Varien_Object $row)
10
+ {
11
+ $str = '';
12
+ $type = $row->getTemplateSubscriberType();
13
+ if ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE) {
14
+ $str = Mage::helper('magentokey_newsletter')->__('Product Update');
15
+ } elseif($type == Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION) {
16
+ $str = Mage::helper('magentokey_newsletter')->__('Price Reduction');
17
+ } elseif($type == Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE) {
18
+ $str = Mage::helper('magentokey_newsletter')->__('Stock Available');
19
+ } elseif($type == Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_NEW) {
20
+ $str = Mage::helper('magentokey_newsletter')->__('New Products');
21
+ }
22
+ return $str;
23
+ }
24
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Preview.php ADDED
@@ -0,0 +1,67 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Template_Preview extends Mage_Adminhtml_Block_Widget
8
+ {
9
+
10
+ protected function _toHtml()
11
+ {
12
+ /* @var $template Magentokey_Newsletter_Model_Template */
13
+ $template = Mage::getModel('magentokey_newsletter/template');
14
+ if($id = (int)$this->getRequest()->getParam('id')) {
15
+ $template->load($id);
16
+ }
17
+ if($type = $this->getRequest()->getParam('type')){
18
+ $template->setTemplateType($type);
19
+ }
20
+ if($text = $this->getRequest()->getParam('text')){
21
+ $template->setTemplateText($text);
22
+ }
23
+ if($styles = $this->getRequest()->getParam('styles')){
24
+ $template->setTemplateStyles($styles);
25
+ }
26
+ $type = $template->getTemplateSubscriberType();
27
+ $productId = $categoryId = '';
28
+ if ($productId = $template->getTemplateProductId()) {
29
+ $productId = $productId;
30
+ } elseif ($categoryId = $template->getTemplateCategoryId()) {
31
+ $categoryId = $categoryId;
32
+ } elseif ($productId = $this->getRequest()->getParam('preview_product_id')) {
33
+ $productId = $productId;
34
+ } elseif ($categoryId = $this->getRequest()->getParam('preview_category_id')) {
35
+ $categoryId = $categoryId;
36
+ }
37
+ if ($categoryId) {
38
+ $productId = Mage::getModel('catalog/category')->load($categoryId)
39
+ ->getProductCollection()
40
+ ->getFirstItem()
41
+ ->getId();
42
+ }
43
+ if ($productId) {
44
+ Mage::register('_magentokey_newsletter_product', $productId);
45
+ }
46
+ $storeId = (int)$this->getRequest()->getParam('store_id');
47
+ if(!$storeId) {
48
+ $storeId = Mage::app()->getDefaultStoreView()->getId();
49
+ }
50
+
51
+ Varien_Profiler::start("newsletter_template_proccessing");
52
+ $vars = array();
53
+
54
+ $vars['subscriber'] = Mage::getModel('magentokey_newsletter/subscriber');
55
+ $template->emulateDesign($storeId);
56
+ $templateProcessed = $template->getProcessedTemplate($vars, true);
57
+ $template->revertDesign();
58
+
59
+ if($template->isPlain()) {
60
+ $templateProcessed = "<pre>" . htmlspecialchars($templateProcessed) . "</pre>";
61
+ }
62
+
63
+ Varien_Profiler::stop("newsletter_template_proccessing");
64
+ return $templateProcessed;
65
+ }
66
+
67
+ }
app/code/community/Magentokey/Newsletter/Block/Adminhtml/Newsletter/Template/Preview/Form.php ADDED
@@ -0,0 +1,43 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Adminhtml_Newsletter_Template_Preview_Form extends Mage_Adminhtml_Block_Widget_Form
8
+ {
9
+
10
+ /**
11
+ * Preparing from for revision page
12
+ *
13
+ * @return Mage_Adminhtml_Block_Widget_Form
14
+ */
15
+ protected function _prepareForm()
16
+ {
17
+ $form = new Varien_Data_Form(array(
18
+ 'id' => 'preview_form',
19
+ 'action' => $this->getUrl('*/*/drop', array('_current' => true)),
20
+ 'method' => 'post'
21
+ ));
22
+
23
+ if ($data = $this->getFormData()) {
24
+
25
+ $mapper = array('preview_store_id' => 'store_id');
26
+
27
+ foreach ($data as $key => $value) {
28
+ if(array_key_exists($key, $mapper)) {
29
+ $name = $mapper[$key];
30
+ } else {
31
+ $name = $key;
32
+ }
33
+ $form->addField($key, 'hidden', array('name' => $name));
34
+ }
35
+ $form->setValues($data);
36
+ }
37
+
38
+ $form->setUseContainer(true);
39
+ $this->setForm($form);
40
+ return parent::_prepareForm();
41
+ }
42
+ }
43
+
app/code/community/Magentokey/Newsletter/Block/Link.php ADDED
@@ -0,0 +1,244 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Link extends Mage_Core_Block_Template
8
+ {
9
+ public function isProduct()
10
+ {
11
+ return Mage::helper('magentokey_newsletter')->isProduct($this->getRequest()->getParam('type'));
12
+ }
13
+ public function isCategory()
14
+ {
15
+ return Mage::helper('magentokey_newsletter')->isCategory($this->getRequest()->getParam('type'));
16
+ }
17
+ public function getProduct()
18
+ {
19
+ return Mage::getModel('catalog/product')->load($this->getRequest()->getParam('id'));
20
+ }
21
+ public function getCategory()
22
+ {
23
+ return Mage::getModel('catalog/category')->load($this->getRequest()->getParam('id'));
24
+ }
25
+ public function isProductTypeAvaible()
26
+ {
27
+ $productType = $this->getProduct()->getTypeId();
28
+ if ($productType=='simple' && Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_TYPE_SIMPLE)) {
29
+ return true;
30
+ } elseif ($productType=='configurable' && Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_TYPE_CONFIG)) {
31
+ return true;
32
+ } elseif ($productType=='virtual' && Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_TYPE_VIRTUAL)) {
33
+ return true;
34
+ } else {
35
+ return false;
36
+ }
37
+ }
38
+ public function isProductPopUp()
39
+ {
40
+ return Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_PRODUCT_POPUP);
41
+ }
42
+ public function isCategoryPopUp()
43
+ {
44
+ return Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_CATEGORY_POPUP);
45
+ }
46
+ public function getNewsletterUrl()
47
+ {
48
+ return $this->getUrl('newsletters/subscribe/add');
49
+ }
50
+ public function getNewsletterUpdate()
51
+ {
52
+ return Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE;
53
+ }
54
+ public function getNewsletterReduction()
55
+ {
56
+ return Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION;
57
+ }
58
+ public function getNewsletterStock()
59
+ {
60
+ return Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE;
61
+ }
62
+
63
+ public function getStoreId()
64
+ {
65
+ return Mage::app()->getStore()->getId();
66
+ }
67
+ public function getCustomerId()
68
+ {
69
+ return Mage::getSingleton('customer/session')->getCustomerId();
70
+ }
71
+ public function getPreUrl()
72
+ {
73
+ if ($this->isProduct()) {
74
+ return $this->getProduct()->getProductUrl();
75
+ }
76
+ if ($this->isCategory()) {
77
+ $navigation = Mage::getBlockSingleton('catalog/navigation');
78
+ return $navigation->getCategoryUrl($this->getCategory());
79
+ }
80
+
81
+ }
82
+ public function getCustomerEmail()
83
+ {
84
+ return Mage::getSingleton('customer/session')->getCustomer()->getEmail();
85
+ }
86
+ public function getSubscribeUrl()
87
+ {
88
+ return $this->getUrl('newsletters/subscribe/save', array('isAjax'=>'true'));
89
+ }
90
+ public function isUpdateAvailable()
91
+ {
92
+ return Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_PRODUCT_UPDATE);
93
+ }
94
+ public function isPriceAvailable()
95
+ {
96
+ return Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_PRODUCT_PRICE_REDUCTION);
97
+ }
98
+ public function isStockAvailable()
99
+ {
100
+ return Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_PRODUCT_STOCK_AVAILABLE);
101
+ }
102
+ public function isCategoryAvailable()
103
+ {
104
+ return Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_CATEGORY_NEW) || Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_CATEGORY_PRICE);
105
+ }
106
+ public function getProductUpdatePopUrl($productId)
107
+ {
108
+ return $this->getUrl('newsletters/subscribe/add',array('id'=>$productId,'type'=>Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE));
109
+ }
110
+ public function getProductPricePopUrl($productId)
111
+ {
112
+ return $this->getUrl('newsletters/subscribe/add',array('id'=>$productId,'type'=>Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION));
113
+ }
114
+ public function getProductStockPopUrl($productId)
115
+ {
116
+ return $this->getUrl('newsletters/subscribe/add',array('id'=>$productId,'type'=>Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE));
117
+ }
118
+ public function getProductUpdateUrl($productId)
119
+ {
120
+ return $this->getUrl('newsletters/subscribe/index',array('id'=>$productId,'type'=>Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE));
121
+ }
122
+ public function getProductPriceUrl($productId)
123
+ {
124
+ return $this->getUrl('newsletters/subscribe/index',array('id'=>$productId,'type'=>Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION));
125
+ }
126
+ public function getProductStockUrl($productId)
127
+ {
128
+ return $this->getUrl('newsletters/subscribe/index',array('id'=>$productId,'type'=>Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE));
129
+ }
130
+
131
+
132
+ public function getCategoryNewUrl($categoryId)
133
+ {
134
+ return $this->getUrl('newsletters/subscribe/index',array('id'=>$categoryId,'type'=>Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_NEW));
135
+ }
136
+ public function getCategoryPriceUrl($categoryId)
137
+ {
138
+ return $this->getUrl('newsletters/subscribe/index',array('id'=>$categoryId,'type'=>Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_PRICE));
139
+ }
140
+ public function getCategoryPopNewUrl($categoryId)
141
+ {
142
+ return $this->getUrl('newsletters/subscribe/add',array('id'=>$categoryId, 'type'=>Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_NEW));
143
+ }
144
+ public function getCategoryPopPriceUrl($categoryId)
145
+ {
146
+ return $this->getUrl('newsletters/subscribe/add',array('id'=>$categoryId, 'type'=>Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_PRICE));
147
+ }
148
+ public function getCurrentType()
149
+ {
150
+ return $this->getRequest()->getParam('type');
151
+
152
+ }
153
+ public function isAmountAvailable()
154
+ {
155
+ $type = $this->getRequest()->getParam('type');
156
+ $flag = false;
157
+ if ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION) {
158
+ if (Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_PRODUCT_PRICE_REDUCTION_AMOUNT)) {
159
+ $flag = true;
160
+ }
161
+ } elseif ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE) {
162
+ if (Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_PRODUCT_STOCK_AVAILABLE_AMOUNT)) {
163
+ $flag = true;;
164
+ }
165
+ }
166
+ return $flag;
167
+ }
168
+ public function getAmountTitle()
169
+ {
170
+ $type = $this->getRequest()->getParam('type');
171
+ $title = '';
172
+ if ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION) {
173
+ $title = Mage::helper('magentokey_newsletter')->__('Price');
174
+ } elseif ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE) {
175
+ $title = Mage::helper('magentokey_newsletter')->__('Quantity');
176
+ }
177
+ return $title;
178
+ }
179
+
180
+
181
+ public function getCurrentDate()
182
+ {
183
+ return Mage::helper('magentokey_newsletter')->getCurrentDate();
184
+ }
185
+ public function isPopDateEnable()
186
+ {
187
+ return Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_DATE_DURATION_ENABLE);
188
+ }
189
+ public function getPopDefaultDay()
190
+ {
191
+ return Mage::helper('magentokey_newsletter')->getDefaultDuration();
192
+ }
193
+ public function isPageDateEnable()
194
+ {
195
+ return Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_DATE_PAGE_ENABLE);
196
+ }
197
+ public function getPageDefaultDay()
198
+ {
199
+ return Mage::helper('magentokey_newsletter')->getPageDateDefault();
200
+ }
201
+ public function getTypeTitle()
202
+ {
203
+ return Mage::helper('magentokey_newsletter')->getTitleByType($this->getRequest()->getParam('type'));
204
+ }
205
+ public function getTitle()
206
+ {
207
+ $type = $this->getRequest()->getParam('type');
208
+ $title = '';
209
+ if ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION) {
210
+ $title = Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_PRODUCT_TITLE_PRICE);
211
+ } elseif ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE) {
212
+ $title = Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_PRODUCT_TITLE_STOCK);
213
+ } elseif ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE) {
214
+ $title = Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_PRODUCT_TITLE_UPDATE);
215
+ } elseif ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_NEW) {
216
+ $title = Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_CATEGORY_TITLE_NEW);
217
+ } elseif ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_PRICE) {
218
+ $title = Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_CATEGORY_TITLE_PRICE);
219
+ }
220
+ return $title;
221
+ }
222
+ public function getNotice()
223
+ {
224
+ $type = $this->getRequest()->getParam('type');
225
+ $notice = '';
226
+ if ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION) {
227
+ $notice = Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_PRODUCT_NOTICE_PRICE);
228
+ } elseif ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE) {
229
+ $notice = Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_PRODUCT_NOTICE_STOCK);
230
+ } elseif ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE) {
231
+ $notice = Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_PRODUCT_NOTICE_UPDATE);
232
+ } elseif ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_NEW) {
233
+ $notice = Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_CATEGORY_NOTICE_NEW);
234
+ } elseif ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_PRICE) {
235
+ $notice = Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_CATEGORY_NOTICE_PRICE);
236
+ }
237
+ return $notice;
238
+ }
239
+ public function getTypeAjaxUrl()
240
+ {
241
+ return $this->getUrl('newsletters/subscribe/amount');
242
+ }
243
+ }
244
+ ?>
app/code/community/Magentokey/Newsletter/Block/Widget/Product.php ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Block_Widget_Product extends Mage_Catalog_Block_Product_Abstract implements Mage_Widget_Block_Interface
8
+ {
9
+ protected function _beforeToHtml()
10
+ {
11
+ $this->setProduct(Mage::getModel('catalog/product')->load(Mage::registry('_magentokey_newsletter_product')));
12
+ return parent::_beforeToHtml();
13
+ }
14
+ }
15
+ ?>
app/code/community/Magentokey/Newsletter/Helper/Data.php ADDED
@@ -0,0 +1,149 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Helper_Data extends Mage_Core_Helper_Abstract
8
+ {
9
+ const XML_PATH_TEMPLATE_FILTER = 'global/newsletter/tempate_filter';
10
+ const DAY_DEFAULT = 15;
11
+ public function randomSequence($length=32)
12
+ {
13
+ $id = '';
14
+ $par = array();
15
+ $char = array_merge(range('a','z'),range(0,9));
16
+ $charLen = count($char)-1;
17
+ for ($i=0;$i<$length;$i++){
18
+ $disc = mt_rand(0, $charLen);
19
+ $par[$i] = $char[$disc];
20
+ $id = $id.$char[$disc];
21
+ }
22
+ return $id;
23
+ }
24
+ public function getCurrentDate()
25
+ {
26
+ return Mage::getSingleton('core/date')->gmtDate('Y-m-d');
27
+ }
28
+ public function getDefaultDuration($day = 0)
29
+ {
30
+ if (!$day) {
31
+ $day = Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_DATE_DURATION_DAY);
32
+ $day = $day ? (int)$day : self::DAY_DEFAULT;
33
+ }
34
+ return date('Y-m-d',mktime(0,0,0,date('m'),date('d')+$day,date('Y')));
35
+ }
36
+ public function getPageDateDefault($day = 0)
37
+ {
38
+ if (!$day) {
39
+ $day = Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_DATE_PAGE_DEFAULT);
40
+ $day = $day ? (int)$day : self::DAY_DEFAULT;
41
+ }
42
+ return date('Y-m-d',mktime(0,0,0,date('m'),date('d')+$day,date('Y')));
43
+ }
44
+ public function getTimeoutDays()
45
+ {
46
+ if (Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_DATE_TIMEOUT_ENABLE)) {
47
+ $timeoutDays = (int)Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_DATE_TIMEOUT_DAY);
48
+ return date('Y-m-d',mktime(0,0,0,date('m'),date('d')-$timeoutDays,date('Y')));
49
+ }
50
+ return false;
51
+ }
52
+ public function getTitleByType($type)
53
+ {
54
+ $title = '';
55
+ if ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION) {
56
+ $title = Mage::helper('magentokey_newsletter')->__('Price reduction notification');
57
+ } elseif ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE) {
58
+ $title = Mage::helper('magentokey_newsletter')->__('Stock available notification');
59
+ } elseif ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE) {
60
+ $title = Mage::helper('magentokey_newsletter')->__('Product update notification');
61
+ } elseif ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_NEW) {
62
+ $title = Mage::helper('magentokey_newsletter')->__('New products notification');
63
+ } elseif ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_PRICE) {
64
+ $title = Mage::helper('magentokey_newsletter')->__('Price reduction notification');
65
+ }
66
+ return $title;
67
+ }
68
+ public function isProduct($type = '')
69
+ {
70
+ if ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION || $type == Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE || $type == Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE) {
71
+ return true;
72
+ }
73
+ return false;
74
+ }
75
+ public function isCategory($type = '')
76
+ {
77
+ if ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_NEW || $type == Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_PRICE) {
78
+ return true;
79
+ }
80
+ return false;
81
+ }
82
+ /**
83
+ * Retrieve subsription confirmation url
84
+ *
85
+ * @param Mage_Newsletter_Model_Subscriber $subscriber
86
+ * @return string
87
+ */
88
+ public function getConfirmationUrl($subscriber)
89
+ {
90
+ return Mage::getModel('core/url')
91
+ ->setStore($subscriber->getStoreId())
92
+ ->getUrl('newsletters/subscribe/confirm', array(
93
+ 'id' => $subscriber->getId(),
94
+ 'code' => $subscriber->getCode(),
95
+ '_nosid' => true
96
+ ));
97
+ }
98
+
99
+ /**
100
+ * Retrieve unsubsription url
101
+ *
102
+ * @param Mage_Newsletter_Model_Subscriber $subscriber
103
+ * @return string
104
+ */
105
+ public function getUnsubscribeUrl($subscriber)
106
+ {
107
+
108
+ return Mage::getModel('core/url')
109
+ ->setStore($subscriber->getStoreId())
110
+ ->getUrl('newsletters/subscribe/unsubscribe', array(
111
+ 'id' => $subscriber->getId(),
112
+ 'code' => $subscriber->getCode(),
113
+ '_nosid' => true
114
+ ));
115
+ }
116
+
117
+ /**
118
+ * Retrieve Template processor for Newsletter template
119
+ *
120
+ * @return Varien_Filter_Template
121
+ */
122
+ public function getTemplateProcessor()
123
+ {
124
+ $model = (string)Mage::getConfig()->getNode(self::XML_PATH_TEMPLATE_FILTER);
125
+ return Mage::getModel($model);
126
+ }
127
+ public function checkQueueNum(Mage_Catalog_Model_Proce $product,$type)
128
+ {
129
+ $subscriberCollection = Mage::getResourceModel('magentokey_newsletter/subscriber_collection')->setQueueRecipients($product,$type);
130
+ if (count($subscriberCollection)) {
131
+ $templateId = Mage::getResourceModel('magentokey_newsletter/template_collection')->getTemplate($product, $type);
132
+ Mage::getModel('magentokey_newsletter/queue')->addQueue($product->getId(), $type, $templateId, $subscriberCollection);
133
+ return true;
134
+ } else {
135
+ return false;
136
+ }
137
+
138
+ }
139
+ public function checkPriceMatchQueueNum(Mage_Catalog_Model_Product $product, $price) {
140
+ $subscriberCollection = Mage::getResourceModel('magentokey_newsletter/subscriber_collection')->setQueuePriceMatch($product,$price,Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION);
141
+ if (count($subscriberCollection)) {
142
+ $templateId = Mage::getResourceModel('magentokey_newsletter/template_collection')->getTemplate($product, Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION);
143
+ Mage::getModel('magentokey_newsletter/queue')->addQueue($product->getId(), Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION, $templateId, $subscriberCollection);
144
+ return true;
145
+ } else {
146
+ return false;
147
+ }
148
+ }
149
+ }
app/code/community/Magentokey/Newsletter/Model/Mysql4/Problem.php ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Model_Mysql4_Problem extends Mage_Core_Model_Mysql4_Abstract
8
+ {
9
+ /**
10
+ * Define main table
11
+ *
12
+ */
13
+ protected function _construct()
14
+ {
15
+ $this->_init('magentokey_newsletter/problem', 'problem_id');
16
+ }
17
+ }
app/code/community/Magentokey/Newsletter/Model/Mysql4/Problem/Collection.php ADDED
@@ -0,0 +1,111 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Model_Mysql4_Problem_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
8
+ {
9
+ /**
10
+ * True when subscribers info joined
11
+ *
12
+ * @var bool
13
+ */
14
+ protected $_subscribersInfoJoinedFlag = false;
15
+
16
+ /**
17
+ * True when grouped
18
+ *
19
+ * @var bool
20
+ */
21
+ protected $_problemGrouped = false;
22
+
23
+ /**
24
+ * Define resource model and model
25
+ *
26
+ */
27
+ protected function _construct()
28
+ {
29
+ $this->_init('magentokey_newsletter/problem');
30
+ }
31
+
32
+ /**
33
+ * Adds subscribers info
34
+ *
35
+ * @return Mage_Newsletter_Model_Resource_Problem_Collection
36
+ */
37
+ public function addSubscriberInfo()
38
+ {
39
+ $this->getSelect()->joinLeft(array('subscriber'=>$this->getTable('magentokey_newsletter/subscriber')),
40
+ 'main_table.subscriber_id = subscriber.subscriber_id',
41
+ array('subscriber_email','customer_id','subscriber_status')
42
+ );
43
+ $this->_subscribersInfoJoinedFlag = true;
44
+
45
+ return $this;
46
+ }
47
+
48
+ /**
49
+ * Adds queue info
50
+ *
51
+ * @return Mage_Newsletter_Model_Resource_Problem_Collection
52
+ */
53
+ public function addQueueInfo()
54
+ {
55
+ $this->getSelect()->joinLeft(array('queue'=>$this->getTable('magentokey_newsletter/queue')),
56
+ 'main_table.queue_id = queue.queue_id',
57
+ array('added_at', 'product_id', 'subscriber_type', 'template_id', 'newsletter_subject')
58
+ );
59
+ return $this;
60
+ }
61
+
62
+ /**
63
+ * Loads customers info to collection
64
+ *
65
+ */
66
+ protected function _addCustomersData()
67
+ {
68
+ $customersIds = array();
69
+
70
+ foreach ($this->getItems() as $item) {
71
+ if ($item->getCustomerId()) {
72
+ $customersIds[] = $item->getCustomerId();
73
+ }
74
+ }
75
+
76
+ if (count($customersIds) == 0) {
77
+ return;
78
+ }
79
+
80
+ $customers = Mage::getResourceModel('customer/customer_collection')
81
+ ->addNameToSelect()
82
+ ->addAttributeToFilter('entity_id', array("in"=>$customersIds));
83
+
84
+ $customers->load();
85
+
86
+ foreach ($customers->getItems() as $customer) {
87
+ $problems = $this->getItemsByColumnValue('customer_id', $customer->getId());
88
+ foreach ($problems as $problem) {
89
+ $problem->setCustomerName($customer->getName())
90
+ ->setCustomerFirstName($customer->getFirstName())
91
+ ->setCustomerLastName($customer->getLastName());
92
+ }
93
+ }
94
+ }
95
+
96
+ /**
97
+ * Loads collecion and adds customers info
98
+ *
99
+ * @param bool $printQuery
100
+ * @param bool $logQuery
101
+ * @return Mage_Newsletter_Model_Resource_Problem_Collection
102
+ */
103
+ public function load($printQuery = false, $logQuery = false)
104
+ {
105
+ parent::load($printQuery, $logQuery);
106
+ if ($this->_subscribersInfoJoinedFlag && !$this->isLoaded()) {
107
+ $this->_addCustomersData();
108
+ }
109
+ return $this;
110
+ }
111
+ }
app/code/community/Magentokey/Newsletter/Model/Mysql4/Queue.php ADDED
@@ -0,0 +1,133 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Model_Mysql4_Queue extends Mage_Core_Model_Mysql4_Abstract
8
+ {
9
+ protected function _construct()
10
+ {
11
+ $this->_init('magentokey_newsletter/queue', 'queue_id');
12
+ }
13
+
14
+ public function addSubscribersToQueue(Magentokey_Newsletter_Model_Queue $queue, array $subscriberIds)
15
+ {
16
+
17
+ if (count($subscriberIds)==0) {
18
+ Mage::throwException(Mage::helper('magentokey_newsletter')->__('No subscribers selected.'));
19
+ }
20
+
21
+ if (!$queue->getId() && $queue->getQueueStatus()!=Magentokey_Newsletter_Model_Queue::STATUS_NEVER) {
22
+ Mage::throwException(Mage::helper('magentokey_newsletter')->__('Invalid queue selected.'));
23
+ }
24
+ $adapter = $this->_getWriteAdapter();
25
+ $select = $adapter->select();
26
+ $select->from($this->getTable('magentokey_newsletter/queue_link'), 'subscriber_id')
27
+ ->where('queue_id = ?', $queue->getId())
28
+ ->where('subscriber_id in (?)', $subscriberIds);
29
+ //var_dump($select->__toString());
30
+ $usedIds = $adapter->fetchCol($select);
31
+ $adapter->beginTransaction();
32
+ try {
33
+ foreach ($subscriberIds as $subscriberId) {
34
+ if (in_array($subscriberId, $usedIds)) {
35
+ continue;
36
+ }
37
+ $data = array();
38
+ $data['queue_id'] = $queue->getId();
39
+ $data['subscriber_id'] = $subscriberId;
40
+ $adapter->insert($this->getTable('magentokey_newsletter/queue_link'), $data);
41
+ }
42
+ $adapter->commit();
43
+ }
44
+ catch (Exception $e) {
45
+ $adapter->rollBack();
46
+ }
47
+ }
48
+
49
+ public function removeSubscribersFromQueue(Magentokey_Newsletter_Model_Queue $queue)
50
+ {
51
+ $adapter = $this->_getWriteAdapter();
52
+ try {
53
+ $adapter->delete(
54
+ $this->getTable('magentokey_newsletter/queue_link'),
55
+ array(
56
+ 'queue_id = ?' => $queue->getId(),
57
+ 'letter_sent_at IS NULL'
58
+ )
59
+ );
60
+
61
+ $adapter->commit();
62
+ }
63
+ catch (Exception $e) {
64
+ $adapter->rollBack();
65
+ }
66
+ }
67
+
68
+ public function setStores(Magentokey_Newsletter_Model_Queue $queue)
69
+ {
70
+ $adapter = $this->_getWriteAdapter();
71
+ $adapter->delete(
72
+ $this->getTable('magentokey_newsletter/queue_store_link'),
73
+ array('queue_id = ?' => $queue->getId())
74
+ );
75
+
76
+ $stores = $queue->getStores();
77
+ if (!is_array($stores)) {
78
+ $stores = array();
79
+ }
80
+
81
+ foreach ($stores as $storeId) {
82
+ $data = array();
83
+ $data['store_id'] = $storeId;
84
+ $data['queue_id'] = $queue->getId();
85
+ $adapter->insert($this->getTable('magentokey_newsletter/queue_store_link'), $data);
86
+ }
87
+ $this->removeSubscribersFromQueue($queue);
88
+
89
+ if (count($stores) == 0) {
90
+ return $this;
91
+ }
92
+
93
+ $subscribers = Mage::getResourceSingleton('magentokey_newsletter/subscriber_collection')
94
+ ->addFieldToFilter('store_id', array('in'=>$stores))
95
+ ->useOnlySubscribed()
96
+ ->load();
97
+
98
+ $subscriberIds = array();
99
+
100
+ foreach ($subscribers as $subscriber) {
101
+ $subscriberIds[] = $subscriber->getId();
102
+ }
103
+
104
+ if (count($subscriberIds) > 0) {
105
+ $this->addSubscribersToQueue($queue, $subscriberIds);
106
+ }
107
+
108
+ return $this;
109
+ }
110
+
111
+
112
+ public function getStores(Magentokey_Newsletter_Model_Queue $queue)
113
+ {
114
+ $adapter = $this->_getReadAdapter();
115
+ $select = $adapter->select()->from($this->getTable('magentokey_newsletter/queue_store_link'), 'store_id')
116
+ ->where('queue_id = :queue_id');
117
+
118
+ if (!($result = $adapter->fetchCol($select, array('queue_id'=>$queue->getId())))) {
119
+ $result = array();
120
+ }
121
+
122
+ return $result;
123
+ }
124
+
125
+
126
+ protected function _afterSave(Mage_Core_Model_Abstract $queue)
127
+ {
128
+ if ($queue->getSaveStoresFlag()) {
129
+ $this->setStores($queue);
130
+ }
131
+ return $this;
132
+ }
133
+ }
app/code/community/Magentokey/Newsletter/Model/Mysql4/Queue/Collection.php ADDED
@@ -0,0 +1,210 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Model_Mysql4_Queue_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
8
+ {
9
+ /**
10
+ * True when subscribers info joined
11
+ *
12
+ * @var bool
13
+ */
14
+ protected $_addSubscribersFlag = false;
15
+
16
+ /**
17
+ * True when filtered by store
18
+ *
19
+ * @var bool
20
+ */
21
+ protected $_isStoreFilter = false;
22
+
23
+ protected function _construct()
24
+ {
25
+ $this->_init('magentokey_newsletter/queue');
26
+ }
27
+
28
+ public function addTemplateInfo()
29
+ {
30
+ $this->getSelect()->joinLeft(array('template'=>$this->getTable('template')),
31
+ 'template.template_id=main_table.template_id',
32
+ array('template_subject','template_code','template_sender_name','template_sender_email')
33
+ );
34
+ $this->_joinedTables['template'] = true;
35
+ return $this;
36
+ }
37
+ /**
38
+ * Adds subscribers info to selelect
39
+ *
40
+ * @return Magentokey_Newsletter_Model_Mysql4_Queue_Collection
41
+ */
42
+ protected function _addSubscriberInfoToSelect()
43
+ {
44
+ if (!$this->_addSubscribersFlag) {
45
+ $this->_addSubscribersFlag = true;
46
+ //Possibel solution with join select
47
+ $select = $this->getConnection()->select()
48
+ ->from(array('qlt' => $this->getTable('magentokey_newsletter/queue_link')), 'COUNT(qlt.queue_link_id)')
49
+ ->where('qlt.queue_id = main_table.queue_id');
50
+ $totalExpr = new Zend_Db_Expr(sprintf('(%s)', $select->assemble()));
51
+ $select = $this->getConnection()->select()
52
+ ->from(array('qls' => $this->getTable('magentokey_newsletter/queue_link')), 'COUNT(qls.queue_link_id)')
53
+ ->where('qls.queue_id = main_table.queue_id')
54
+ ->where('qls.letter_sent_at IS NOT NULL');
55
+ $sentExpr = new Zend_Db_Expr(sprintf('(%s)', $select->assemble()));
56
+
57
+ $this->getSelect()->columns(array(
58
+ 'subscribers_sent' => $sentExpr,
59
+ 'subscribers_total' => $totalExpr
60
+ ));
61
+ }
62
+ return $this;
63
+ }
64
+
65
+ /**
66
+ * Adds subscribers info to select and loads collection
67
+ *
68
+ * @param bool $printQuery
69
+ * @param bool $logQuery
70
+ * @return Magentokey_Newsletter_Model_Mysql4_Queue_Collection
71
+ */
72
+ public function load($printQuery = false, $logQuery = false)
73
+ {
74
+ if ($this->_addSubscribersFlag && !$this->isLoaded()) {
75
+ $this->_addSubscriberInfoToSelect();
76
+ }
77
+ return parent::load($printQuery, $logQuery);
78
+ }
79
+
80
+ /**
81
+ * Joines subscribers information
82
+ *
83
+ * @return Mage_Newsletter_Model_Resource_Queue_Collection
84
+ */
85
+ public function addSubscribersInfo()
86
+ {
87
+ $this->_addSubscribersFlag = true;
88
+ return $this;
89
+ }
90
+
91
+ /**
92
+ * Checks if field is 'subscribers_total', 'subscribers_sent'
93
+ * to add specific filter or adds reguler filter
94
+ *
95
+ * @param string $field
96
+ * @param mixed $condition
97
+ * @return Mage_Newsletter_Model_Resource_Queue_Collection
98
+ */
99
+ public function addFieldToFilter($field, $condition = null)
100
+ {
101
+ if (in_array($field, array('subscribers_total', 'subscribers_sent'))) {
102
+ $this->addFieldToFilter('main_table.queue_id', array('in'=>$this->_getIdsFromLink($field, $condition)));
103
+ return $this;
104
+ } else {
105
+ return parent::addFieldToFilter($field, $condition);
106
+ }
107
+ }
108
+
109
+ /**
110
+ * Returns ids from queue_link table
111
+ *
112
+ * @param string $field
113
+ * @param mixed $condition
114
+ * @return array
115
+ */
116
+ protected function _getIdsFromLink($field, $condition)
117
+ {
118
+ $select = $this->getConnection()->select()
119
+ ->from(
120
+ $this->getTable('magentokey_newsletter/queue_link'),
121
+ array('queue_id', 'total' => new Zend_Db_Expr('COUNT(queue_link_id)'))
122
+ )
123
+ ->group('queue_id')
124
+ ->having($this->_getConditionSql('total', $condition));
125
+
126
+ if ($field == 'subscribers_sent') {
127
+ $select->where('letter_sent_at IS NOT NULL');
128
+ }
129
+
130
+ $idList = $this->getConnection()->fetchCol($select);
131
+
132
+ if (count($idList)) {
133
+ return $idList;
134
+ }
135
+
136
+ return array(0);
137
+ }
138
+
139
+ /**
140
+ * Set filter for queue by subscriber.
141
+ *
142
+ * @param int $subscriberId
143
+ * @return Magentokey_Newsletter_Model_Mysql4_Queue_Collection
144
+ */
145
+ public function addSubscriberFilter($subscriberId)
146
+ {
147
+ $this->getSelect()->join(array('link'=>$this->getTable('magentokey_newsletter/queue_link')),
148
+ 'main_table.queue_id=link.queue_id',
149
+ array('letter_sent_at')
150
+ )
151
+ ->where('link.subscriber_id = ?', $subscriberId);
152
+
153
+ return $this;
154
+ }
155
+
156
+ /**
157
+ * Add filter by only ready fot sending item
158
+ *
159
+ * @return Magentokey_Newsletter_Model_Mysql4_Queue_Collection
160
+ */
161
+ public function addOnlyForSendingFilter()
162
+ {
163
+ $this->getSelect()
164
+ ->where('main_table.queue_status in (?)', array(Magentokey_Newsletter_Model_Queue::STATUS_SENDING,
165
+ Magentokey_Newsletter_Model_Queue::STATUS_NEVER,
166
+ Magentokey_Newsletter_Model_Queue::STATUS_PAUSE));
167
+ return $this;
168
+ }
169
+
170
+ /**
171
+ * Add filter by only not sent items
172
+ *
173
+ * @return Mage_Newsletter_Model_Resource_Queue_Collection
174
+ */
175
+ public function addOnlyUnsentFilter()
176
+ {
177
+ $this->addFieldToFilter('main_table.queue_status', Magentokey_Newsletter_Model_Queue::STATUS_NEVER);
178
+
179
+ return $this;
180
+ }
181
+
182
+ /**
183
+ * Returns options array
184
+ *
185
+ * @return array
186
+ */
187
+ public function toOptionArray()
188
+ {
189
+ return $this->_toOptionArray('queue_id', 'template_subject');
190
+ }
191
+
192
+ /**
193
+ * Filter collection by specified store ids
194
+ *
195
+ * @param array|int $storeIds
196
+ * @return Mage_Newsletter_Model_Resource_Queue_Collection
197
+ */
198
+ public function addStoreFilter($storeIds)
199
+ {
200
+ if (!$this->_isStoreFilter) {
201
+ $this->getSelect()->joinInner(array('store_link' => $this->getTable('magentokey_newsletter/queue_store_link')),
202
+ 'main_table.queue_id = store_link.queue_id', array()
203
+ )
204
+ ->where('store_link.store_id IN (?)', $storeIds)
205
+ ->group('main_table.queue_id');
206
+ $this->_isStoreFilter = true;
207
+ }
208
+ return $this;
209
+ }
210
+ }
app/code/community/Magentokey/Newsletter/Model/Mysql4/Report/Categories.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Model_Mysql4_Report_Categories extends Magentokey_Newsletter_Model_Mysql4_Subscriber_Collection
8
+ {
9
+ /**
10
+ * Join fields
11
+ *
12
+ * @param string $from
13
+ * @param string $to
14
+ * @return Magentokey_Newsletter_Model_Mysql4_Subscriber_Collection
15
+ */
16
+ protected function _joinFields($from = '', $to = '')
17
+ {
18
+ $this->addExpressionFieldToSelect("num", "COUNT(subscriber_id)", array("subscriber_id"));
19
+ $this->getSelect()->where('product_id!=0');
20
+ $this->getSelect()->where('added_at>=?',$from);
21
+ $this->getSelect()->where('added_at<?',$to);
22
+
23
+ $this->getSelect()->group("product_id");
24
+ //echo $this->getSelect();
25
+ return $this;
26
+ }
27
+
28
+ /**
29
+ * Set date range
30
+ *
31
+ * @param string $from
32
+ * @param string $to
33
+ * @return Magentokey_Newsletter_Model_Mysql4_Subscriber_Collection
34
+ */
35
+ public function setDateRange($from, $to)
36
+ {
37
+ $this->_reset()
38
+ ->_joinFields($from, $to);
39
+ return $this;
40
+ }
41
+
42
+ /**
43
+ * Set store ids
44
+ *
45
+ * @param array $storeIds
46
+ * @return Magentokey_Newsletter_Model_Mysql4_Subscriber_Collection
47
+ */
48
+ public function setStoreIds($storeIds)
49
+ {
50
+ if ($storeIds) {
51
+ $this->addFieldToFilter('store_id', array('in' => (array)$storeIds));
52
+ }
53
+ return $this;
54
+ }
55
+ }
app/code/community/Magentokey/Newsletter/Model/Mysql4/Report/Category.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Model_Mysql4_Report_Category extends Magentokey_Newsletter_Model_Mysql4_Subscriber_Collection
8
+ {
9
+ /**
10
+ * Join fields
11
+ *
12
+ * @param string $from
13
+ * @param string $to
14
+ * @return Magentokey_Newsletter_Model_Mysql4_Subscriber_Collection
15
+ */
16
+ protected function _joinFields($from = '', $to = '')
17
+ {
18
+ $this->addExpressionFieldToSelect("num", "COUNT(subscriber_id)", array("subscriber_id"));
19
+ $this->getSelect()->where('category_id!=0');
20
+ $this->getSelect()->where('added_at>=?',$from);
21
+ $this->getSelect()->where('added_at<?',$to);
22
+
23
+ $this->getSelect()->group("category_id");
24
+ //echo $this->getSelect();
25
+ return $this;
26
+ }
27
+
28
+ /**
29
+ * Set date range
30
+ *
31
+ * @param string $from
32
+ * @param string $to
33
+ * @return Magentokey_Newsletter_Model_Mysql4_Subscriber_Collection
34
+ */
35
+ public function setDateRange($from, $to)
36
+ {
37
+ $this->_reset()
38
+ ->_joinFields($from, $to);
39
+ return $this;
40
+ }
41
+
42
+ /**
43
+ * Set store ids
44
+ *
45
+ * @param array $storeIds
46
+ * @return Magentokey_Newsletter_Model_Mysql4_Subscriber_Collection
47
+ */
48
+ public function setStoreIds($storeIds)
49
+ {
50
+ if ($storeIds) {
51
+ $this->addFieldToFilter('store_id', array('in' => (array)$storeIds));
52
+ }
53
+ return $this;
54
+ }
55
+ }
app/code/community/Magentokey/Newsletter/Model/Mysql4/Report/Collection.php ADDED
@@ -0,0 +1,55 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Model_Mysql4_Report_Collection extends Magentokey_Newsletter_Model_Mysql4_Subscriber_Collection
8
+ {
9
+ /**
10
+ * Join fields
11
+ *
12
+ * @param string $from
13
+ * @param string $to
14
+ * @return Magentokey_Newsletter_Model_Mysql4_Subscriber_Collection
15
+ */
16
+ protected function _joinFields($from = '', $to = '')
17
+ {
18
+ $this->addExpressionFieldToSelect("num", "COUNT(subscriber_id)", array("subscriber_id"));
19
+ $this->getSelect()->where('product_id!=0');
20
+ $this->getSelect()->where('added_at>=?',$from);
21
+ $this->getSelect()->where('added_at<?',$to);
22
+
23
+ $this->getSelect()->group("product_id");
24
+ //echo $this->getSelect();
25
+ return $this;
26
+ }
27
+
28
+ /**
29
+ * Set date range
30
+ *
31
+ * @param string $from
32
+ * @param string $to
33
+ * @return Magentokey_Newsletter_Model_Mysql4_Subscriber_Collection
34
+ */
35
+ public function setDateRange($from, $to)
36
+ {
37
+ $this->_reset()
38
+ ->_joinFields($from, $to);
39
+ return $this;
40
+ }
41
+
42
+ /**
43
+ * Set store ids
44
+ *
45
+ * @param array $storeIds
46
+ * @return Magentokey_Newsletter_Model_Mysql4_Subscriber_Collection
47
+ */
48
+ public function setStoreIds($storeIds)
49
+ {
50
+ if ($storeIds) {
51
+ $this->addFieldToFilter('store_id', array('in' => (array)$storeIds));
52
+ }
53
+ return $this;
54
+ }
55
+ }
app/code/community/Magentokey/Newsletter/Model/Mysql4/Report/Type.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Model_Mysql4_Report_Type extends Magentokey_Newsletter_Model_Mysql4_Subscriber_Collection
8
+ {
9
+ /**
10
+ * Join fields
11
+ *
12
+ * @param string $from
13
+ * @param string $to
14
+ * @return Magentokey_Newsletter_Model_Mysql4_Subscriber_Collection
15
+ */
16
+ protected function _joinFields($from = '', $to = '')
17
+ {
18
+ $this->addExpressionFieldToSelect("num", "COUNT(subscriber_id)", array("subscriber_id"));
19
+ $this->getSelect()->where('added_at>=?',$from);
20
+ $this->getSelect()->where('added_at<?',$to);
21
+
22
+ $this->getSelect()->group("subscriber_type");
23
+ //echo $this->getSelect();
24
+ return $this;
25
+ }
26
+
27
+ /**
28
+ * Set date range
29
+ *
30
+ * @param string $from
31
+ * @param string $to
32
+ * @return Magentokey_Newsletter_Model_Mysql4_Subscriber_Collection
33
+ */
34
+ public function setDateRange($from, $to)
35
+ {
36
+ $this->_reset()
37
+ ->_joinFields($from, $to);
38
+ return $this;
39
+ }
40
+
41
+ /**
42
+ * Set store ids
43
+ *
44
+ * @param array $storeIds
45
+ * @return Magentokey_Newsletter_Model_Mysql4_Subscriber_Collection
46
+ */
47
+ public function setStoreIds($storeIds)
48
+ {
49
+ if ($storeIds) {
50
+ $this->addFieldToFilter('store_id', array('in' => (array)$storeIds));
51
+ }
52
+ return $this;
53
+ }
54
+ }
app/code/community/Magentokey/Newsletter/Model/Mysql4/Subscriber.php ADDED
@@ -0,0 +1,115 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Model_Mysql4_Subscriber extends Mage_Core_Model_Mysql4_Abstract
8
+ {
9
+ /**
10
+ * DB read connection
11
+ *
12
+ * @var Zend_Db_Adapter_Abstract
13
+ */
14
+ protected $_read;
15
+
16
+ /**
17
+ * DB write connection
18
+ *
19
+ * @var Zend_Db_Adapter_Abstract
20
+ */
21
+ protected $_write;
22
+
23
+ /**
24
+ * Name of subscriber link DB table
25
+ *
26
+ * @var string
27
+ */
28
+ protected $_subscriberLinkTable;
29
+
30
+ /**
31
+ * Name of scope for error messages
32
+ *
33
+ * @var string
34
+ */
35
+ protected $_messagesScope = 'magentokey_newsletter/session';
36
+
37
+ /**
38
+ * Initialize resource model
39
+ * Get tablename from config
40
+ *
41
+ */
42
+ protected function _construct()
43
+ {
44
+ $this->_init('magentokey_newsletter/subscriber', 'subscriber_id');
45
+ $this->_subscriberLinkTable = $this->getTable('magentokey_newsletter/queue_link');
46
+ $this->_read = $this->_getReadAdapter();
47
+ $this->_write = $this->_getWriteAdapter();
48
+ }
49
+
50
+ /**
51
+ * Set error messages scope
52
+ *
53
+ * @param string $scope
54
+ */
55
+ public function setMessagesScope($scope)
56
+ {
57
+ $this->_messagesScope = $scope;
58
+ }
59
+
60
+ /**
61
+ * Generates random code for subscription confirmation
62
+ *
63
+ * @return string
64
+ */
65
+ protected function _generateRandomCode()
66
+ {
67
+ return Mage::helper('core')->uniqHash();
68
+ }
69
+
70
+ /**
71
+ * Updates data when subscriber received
72
+ *
73
+ * @param Magentokey_Newsletter_Model_Subscriber $subscriber
74
+ * @param Magentokey_Newsletter_Model_Queue $queue
75
+ * @return Magentokey_Newsletter_Model_Resource_Subscriber
76
+ */
77
+ public function received(Magentokey_Newsletter_Model_Subscriber $subscriber, Magentokey_Newsletter_Model_Queue $queue)
78
+ {
79
+
80
+ $this->_write->beginTransaction();
81
+ try {
82
+ $data['letter_sent_at'] = Mage::getSingleton('core/date')->gmtDate();
83
+
84
+ $this->_write->update($this->_subscriberLinkTable, $data, array(
85
+ 'subscriber_id = ?' => $subscriber->getId(),
86
+ 'queue_id = ?' => $queue->getId()
87
+ ));
88
+ $this->_write->commit();
89
+ }
90
+ catch (Exception $e) {
91
+ $this->_write->rollBack();
92
+ Mage::throwException(Mage::helper('magentokey_newsletter')->__('Cannot mark as received subscriber.'));
93
+ }
94
+ return $this;
95
+ }
96
+ protected function _beforeSave(Mage_Core_Model_Abstract $object)
97
+ {
98
+ if (!$object->hasAddedAt()) {
99
+ $object->setAddedAt(Mage::getSingleton('core/date')->gmtDate());
100
+ }
101
+ if (!$object->hasSubscriberConfirmCode()) {
102
+ $object->setSubscriberConfirmCode(Mage::helper('magentokey_newsletter')->randomSequence());
103
+ }
104
+ if (!$object->hasDateFrom()) {
105
+ $object->setDateFrom(Mage::helper('magentokey_newsletter')->getCurrentDate());
106
+ }
107
+ if (!$object->hasDateTo()) {
108
+ $object->setDateTo(Mage::helper('magentokey_newsletter')->getDefaultDuration());
109
+ }
110
+ if (!$object->hasSubscriberStatus()) {
111
+
112
+ }
113
+ return parent::_beforeSave($object);
114
+ }
115
+ }
app/code/community/Magentokey/Newsletter/Model/Mysql4/Subscriber/Collection.php ADDED
@@ -0,0 +1,231 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Model_Mysql4_Subscriber_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
8
+ {
9
+ protected $_queueLinkTable;
10
+ protected $_storeTable;
11
+ protected $_queueJoinedFlag = false;
12
+ protected $_showCustomersInfo = false;
13
+ protected $_countFilterPart = array();
14
+
15
+ protected function _construct()
16
+ {
17
+ parent::_construct();
18
+ $this->_init('magentokey_newsletter/subscriber');
19
+ $this->_queueLinkTable = $this->getTable('magentokey_newsletter/queue_link');
20
+ $this->_storeTable = $this->getTable('core/store');
21
+
22
+ // Defining mapping for fields represented in several tables
23
+ $this->_map['fields']['customer_lastname'] = 'customer_lastname_table.value';
24
+ $this->_map['fields']['customer_firstname'] = 'customer_firstname_table.value';
25
+ $this->_map['fields']['type'] = 'IF(main_table.customer_id = 0, 1, 2)';
26
+ $this->_map['fields']['website_id'] = 'store.website_id';
27
+ $this->_map['fields']['group_id'] = 'store.group_id';
28
+ $this->_map['fields']['store_id'] = 'main_table.store_id';
29
+ }
30
+
31
+ /***
32
+ * Set queue recipients
33
+ */
34
+ public function setQueueRecipients(Mage_Catalog_Model_Product $product, $type)
35
+ {
36
+ $date = Mage::helper('magentokey_newsletter')->getCurrentDate();
37
+ $timeout = Mage::helper('magentokey_newsletter')->getTimeoutDays();
38
+ $end = $timeout ? $timeout : $date;
39
+ $status = Magentokey_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED;
40
+ $productId = $product->getId();
41
+ $this->getSelect()
42
+ ->where('date_from <= ?', $date)
43
+ ->where('date_to >= ?', $end)
44
+ ->where('subscriber_type = ?',$type)
45
+ ->where('subscriber_status = ?', $status)
46
+ ->where("category_id in (?) or product_id = {$productId}", $product->getCategoryIds());
47
+ $subscriberCollection = $this->load();
48
+ return $subscriberCollection;
49
+ }
50
+ public function setQueuePriceMatch(Mage_Catalog_Model_Product $product, $price, $type)
51
+ {
52
+ $date = Mage::helper('magentokey_newsletter')->getCurrentDate();
53
+ $timeout = Mage::helper('magentokey_newsletter')->getTimeoutDays();
54
+ $end = $timeout ? $timeout : $date;
55
+ $status = Magentokey_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED;
56
+ $productId = $product->getId();
57
+ $this->getSelect()
58
+ ->where('date_from <= ?', $date)
59
+ ->where('date_to >= ?', $end)
60
+ ->where('subscriber_type = ?',$type)
61
+ ->where('subscriber_status = ?', $status)
62
+ ->where("category_id in (?) or (product_id = {$productId} AND (subscriber_type_amount=0 OR (subscriber_type_amount>0 AND subscriber_type_amount>={$price})))", $product->getCategoryIds());
63
+ $subscriberCollection = $this->load();
64
+ return $subscriberCollection;
65
+ }
66
+ /**
67
+ * Set loading mode subscribers by queue
68
+ *
69
+ * @param Magentokey_Newsletter_Model_Queue $queue
70
+ * @return Magentokey_Newsletter_Model_Resource_Subscriber_Collection
71
+ */
72
+ public function useQueue(Magentokey_Newsletter_Model_Queue $queue)
73
+ {
74
+ $this->getSelect()
75
+ ->join(array('link'=>$this->_queueLinkTable), "link.subscriber_id = main_table.subscriber_id", array())
76
+ ->where("link.queue_id = ? ", $queue->getId());
77
+ $this->_queueJoinedFlag = true;
78
+ return $this;
79
+ }
80
+
81
+ /**
82
+ * Set using of links to only unsendet letter subscribers.
83
+ *
84
+ * @return Magentokey_Newsletter_Model_Resource_Subscriber_Collection
85
+ */
86
+ public function useOnlyUnsent()
87
+ {
88
+ if ($this->_queueJoinedFlag) {
89
+ $this->addFieldToFilter('link.letter_sent_at', array('null' => 1));
90
+ }
91
+
92
+ return $this;
93
+ }
94
+
95
+
96
+
97
+ /**
98
+ * Adds customer info to select
99
+ *
100
+ * @return Magentokey_Newsletter_Model_Resource_Subscriber_Collection
101
+ */
102
+ public function showCustomerInfo()
103
+ {
104
+ $adapter = $this->getConnection();
105
+ $customer = Mage::getModel('customer/customer');
106
+ $firstname = $customer->getAttribute('firstname');
107
+ $lastname = $customer->getAttribute('lastname');
108
+
109
+ $this->getSelect()
110
+ ->joinLeft(
111
+ array('customer_lastname_table'=>$lastname->getBackend()->getTable()),
112
+ $adapter->quoteInto('customer_lastname_table.entity_id=main_table.customer_id
113
+ AND customer_lastname_table.attribute_id = ?', (int)$lastname->getAttributeId()),
114
+ array('customer_lastname'=>'value')
115
+ )
116
+ ->joinLeft(
117
+ array('customer_firstname_table'=>$firstname->getBackend()->getTable()),
118
+ $adapter->quoteInto('customer_firstname_table.entity_id=main_table.customer_id
119
+ AND customer_firstname_table.attribute_id = ?', (int)$firstname->getAttributeId()),
120
+ array('customer_firstname'=>'value')
121
+ );
122
+
123
+ return $this;
124
+ }
125
+
126
+ /**
127
+ * Add type field expression to select
128
+ *
129
+ * @return Magentokey_Newsletter_Model_Resource_Subscriber_Collection
130
+ */
131
+ public function addSubscriberTypeField()
132
+ {
133
+ $this->getSelect()
134
+ ->columns(array('type'=>new Zend_Db_Expr($this->_getMappedField('type'))));
135
+ return $this;
136
+ }
137
+
138
+ /**
139
+ * Sets flag for customer info loading on load
140
+ *
141
+ * @return Magentokey_Newsletter_Model_Resource_Subscriber_Collection
142
+ */
143
+ public function showStoreInfo()
144
+ {
145
+ $this->getSelect()->join(
146
+ array('store' => $this->_storeTable),
147
+ 'store.store_id = main_table.store_id',
148
+ array('group_id', 'website_id')
149
+ );
150
+
151
+ return $this;
152
+ }
153
+
154
+ /**
155
+ * Returns field table alias
156
+ *
157
+ * @deprecated after 1.4.0.0-rc1
158
+ *
159
+ * @param string $field
160
+ * @return string
161
+ */
162
+ public function _getFieldTableAlias($field)
163
+ {
164
+ if (strpos($field, 'customer') === 0) {
165
+ return $field .'_table.value';
166
+ }
167
+
168
+ if ($field == 'type') {
169
+ return new Zend_Db_Expr('IF(main_table.customer_id = 0, 1, 2)');
170
+ }
171
+
172
+ if (in_array($field, array('website_id', 'group_id'))) {
173
+ return 'store.' . $field;
174
+ }
175
+
176
+ return 'main_table.' . $field;
177
+ }
178
+
179
+ /**
180
+ * Returns select count sql
181
+ *
182
+ * @return string
183
+ */
184
+ public function getSelectCountSql()
185
+ {
186
+
187
+ $select = parent::getSelectCountSql();
188
+ $countSelect = clone $this->getSelect();
189
+
190
+ $countSelect->reset(Zend_Db_Select::HAVING);
191
+
192
+ return $select;
193
+ }
194
+
195
+ /**
196
+ * Load only subscribed customers
197
+ *
198
+ * @return Magentokey_Newsletter_Model_Resource_Subscriber_Collection
199
+ */
200
+ public function useOnlyCustomers()
201
+ {
202
+ $this->addFieldToFilter('main_table.customer_id', array('gt' => 0));
203
+
204
+ return $this;
205
+ }
206
+
207
+ /**
208
+ * Show only with subscribed status
209
+ *
210
+ * @return Magentokey_Newsletter_Model_Resource_Subscriber_Collection
211
+ */
212
+ public function useOnlySubscribed()
213
+ {
214
+ $this->addFieldToFilter('main_table.subscriber_status', Magentokey_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
215
+
216
+ return $this;
217
+ }
218
+
219
+ /**
220
+ * Filter collection by specified store ids
221
+ *
222
+ * @param array|int $storeIds
223
+ * @return Magentokey_Newsletter_Model_Resource_Subscriber_Collection
224
+ */
225
+ public function addStoreFilter($storeIds)
226
+ {
227
+ $this->addFieldToFilter('main_table.store_id', array('in'=>$storeIds));
228
+ return $this;
229
+ }
230
+
231
+ }
app/code/community/Magentokey/Newsletter/Model/Mysql4/Template.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Model_Mysql4_Template extends Mage_Core_Model_Mysql4_Abstract
8
+ {
9
+ /**
10
+ * Initialize connection
11
+ *
12
+ */
13
+ protected function _construct()
14
+ {
15
+ $this->_init('magentokey_newsletter/template', 'template_id');
16
+ }
17
+
18
+ /**
19
+ * Load an object by template code
20
+ *
21
+ * @param Mage_Newsletter_Model_Template $object
22
+ * @param string $templateCode
23
+ * @return Mage_Newsletter_Model_Resource_Template
24
+ */
25
+ public function loadByCode(Mage_Newsletter_Model_Template $object, $templateCode)
26
+ {
27
+ $read = $this->_getReadAdapter();
28
+ if ($read && !is_null($templateCode)) {
29
+ $select = $this->_getLoadSelect('template_code', $templateCode, $object)
30
+ ->where('template_actual = :template_actual');
31
+ $data = $read->fetchRow($select, array('template_actual'=>1));
32
+
33
+ if ($data) {
34
+ $object->setData($data);
35
+ }
36
+ }
37
+
38
+ $this->_afterLoad($object);
39
+
40
+ return $this;
41
+ }
42
+
43
+ /**
44
+ * Check usage of template in queue
45
+ *
46
+ * @param Mage_Newsletter_Model_Template $template
47
+ * @return boolean
48
+ */
49
+ public function checkUsageInQueue(Mage_Newsletter_Model_Template $template)
50
+ {
51
+ if ($template->getTemplateActual() !== 0 && !$template->getIsSystem()) {
52
+ $select = $this->_getReadAdapter()->select()
53
+ ->from($this->getTable('magentokey_newsletter/queue'), new Zend_Db_Expr('COUNT(queue_id)'))
54
+ ->where('template_id = :template_id');
55
+
56
+ $countOfQueue = $this->_getReadAdapter()->fetchOne($select, array('template_id'=>$template->getId()));
57
+
58
+ return $countOfQueue > 0;
59
+ } elseif ($template->getIsSystem()) {
60
+ return false;
61
+ } else {
62
+ return true;
63
+ }
64
+ }
65
+
66
+ /**
67
+ * Check usage of template code in other templates
68
+ *
69
+ * @param Mage_Newsletter_Model_Template $template
70
+ * @return boolean
71
+ */
72
+ public function checkCodeUsage(Mage_Newsletter_Model_Template $template)
73
+ {
74
+ if ($template->getTemplateActual() != 0 || is_null($template->getTemplateActual())) {
75
+ $bind = array(
76
+ 'template_id' => $template->getId(),
77
+ 'template_code' => $template->getTemplateCode(),
78
+ 'template_actual' => 1
79
+ );
80
+ $select = $this->_getReadAdapter()->select()
81
+ ->from($this->getMainTable(), new Zend_Db_Expr('COUNT(template_id)'))
82
+ ->where('template_id != :template_id')
83
+ ->where('template_code = :template_code')
84
+ ->where('template_actual = :template_actual');
85
+
86
+ $countOfCodes = $this->_getReadAdapter()->fetchOne($select, $bind);
87
+
88
+ return $countOfCodes > 0;
89
+ } else {
90
+ return false;
91
+ }
92
+ }
93
+
94
+ /**
95
+ * Perform actions before object save
96
+ *
97
+ * @param Mage_Core_Model_Abstract $object
98
+ * @return Mage_Newsletter_Model_Resource_Template
99
+ */
100
+ protected function _beforeSave(Mage_Core_Model_Abstract $object)
101
+ {
102
+ /*
103
+ if ($this->checkCodeUsage($object)) {
104
+ Mage::throwException(Mage::helper('magentokey_newsletter')->__('Duplicate template code.'));
105
+ }*/
106
+
107
+ if (!$object->hasTemplateActual()) {
108
+ $object->setTemplateActual(1);
109
+ }
110
+ if (!$object->hasAddedAt()) {
111
+ $object->setAddedAt(Mage::getSingleton('core/date')->gmtDate());
112
+ }
113
+ $object->setModifiedAt(Mage::getSingleton('core/date')->gmtDate());
114
+
115
+ return parent::_beforeSave($object);
116
+ }
117
+ }
app/code/community/Magentokey/Newsletter/Model/Mysql4/Template/Collection.php ADDED
@@ -0,0 +1,54 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Model_Mysql4_Template_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
8
+ {
9
+ /**
10
+ * Define resource model and model
11
+ *
12
+ */
13
+ protected function _construct()
14
+ {
15
+ $this->_init('magentokey_newsletter/template');
16
+ }
17
+
18
+ /**
19
+ * Load only actual template
20
+ *
21
+ * @return Magentokey_Newsletter_Model_Resource_Template_Collection
22
+ */
23
+ public function useOnlyActual()
24
+ {
25
+ $this->addFieldToFilter('template_actual', 1);
26
+
27
+ return $this;
28
+ }
29
+
30
+ /**
31
+ * Returns options array
32
+ *
33
+ * @return array
34
+ */
35
+ public function toOptionArray()
36
+ {
37
+ return $this->_toOptionArray('template_id', 'template_code');
38
+ }
39
+
40
+ public function getTemplate(Mage_Catalog_Model_Product $product, $type)
41
+ {
42
+ $productId = $product->getId();
43
+ $date = Mage::helper('magentokey_newsletter')->getCurrentDate();
44
+ $this->getSelect()
45
+ ->where('template_subscriber_type = ?', $type)
46
+ ->where('start_at <= ?', $date)
47
+ ->where('end_at >= ?', $date)
48
+ ->where("template_category_id in (?) or template_product_id = {$productId}", $product->getCategoryIds())
49
+ ->order('template_product_id DESC');
50
+ $templateCollection = $this->load();
51
+ $templateId = count($templateCollection) ? $templateCollection->getFirstItem()->getTemplateId() : 1;
52
+ return $templateId;
53
+ }
54
+ }
app/code/community/Magentokey/Newsletter/Model/Observer.php ADDED
@@ -0,0 +1,179 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Model_Observer
8
+ {
9
+ const XML_BACKEND_ENABLE = 'magentokey_newsletter/backend/enable';
10
+ const XML_BACKEND_ENABLE_UPDATE = 'magentokey_newsletter/backend/enable_update';
11
+ const XML_BACKEND_ENABLE_PRICE = 'magentokey_newsletter/backend/enable_price';
12
+ const XML_BACKEND_ENABLE_STOCK = 'magentokey_newsletter/backend/enable_stock';
13
+ const XML_BACKEND_ENABLE_NEW = 'magentokey_newsletter/backend/enable_new';
14
+ const XML_BACKEND_CAN_BACK_IN_STOCK = 'magentokey_newsletter/backend/order_cancel';
15
+ protected function _isEnable()
16
+ {
17
+ return Mage::getStoreConfig(self::XML_BACKEND_ENABLE);
18
+ }
19
+ protected function _isUpdateEnable()
20
+ {
21
+ return Mage::getStoreConfig(self::XML_BACKEND_ENABLE_UPDATE);
22
+ }
23
+ protected function _isPriceEnable()
24
+ {
25
+ return Mage::getStoreConfig(self::XML_BACKEND_ENABLE_PRICE);
26
+ }
27
+ protected function _isStockEnable()
28
+ {
29
+ return Mage::getStoreConfig(self::XML_BACKEND_ENABLE_STOCK);
30
+ }
31
+ protected function _isNewEnable()
32
+ {
33
+ return Mage::getStoreConfig(self::XML_BACKEND_ENABLE_NEW);
34
+ }
35
+ public function getCanBackInStock()
36
+ {
37
+ return Mage::getStoreConfigFlag(self::XML_BACKEND_CAN_BACK_IN_STOCK);
38
+ }
39
+ public function productUpdate($observer)
40
+ {
41
+ if (!$this->_isEnable()) {
42
+ return $this;
43
+ }
44
+
45
+ $product = $observer->getEvent()->getProduct();
46
+ $request = $observer->getEvent()->getRequest();
47
+ $productOriginal = Mage::getModel('catalog/product')->load($request->getParam('id'));
48
+ $productData = $request->getPost('product');
49
+ $stockData = $productData['stock_data'];
50
+ //Price
51
+ $priceOriginal = $productOriginal->getMinimalPrice();
52
+ $price = $product->getMinimalPrice();
53
+ //Final Price
54
+ $minSaleQtyOriginal = $productOriginal->getStockItem()->getMinSaleQty();
55
+ $minSaleQty = $product->getStockItem()->getMinSaleQty();
56
+ $minSaleQtyOriginal = $minSaleQtyOriginal < 1 ? 1 : (int)$minSaleQtyOriginal;
57
+ $minSaleQty = $minSaleQty < 1 ? 1 : (int)$minSaleQty;
58
+
59
+ $finalPriceOriginal = $productOriginal->getFinalPrice($minSaleQtyOriginal)/$minSaleQtyOriginal;
60
+ $finalPrice = $product->getFinalPrice($minSaleQty)/$minSaleQty;
61
+ $update = false;
62
+ //Price Event,Configurable at backend
63
+ if ($this->_isPriceEnable()) {
64
+ if ($finalPriceOriginal > $finalPrice) {//Price Event, add to newsletter queue
65
+ try {
66
+ if (!$this->isPriceMatchEnable()) {
67
+ Mage::helper('magentokey_newsletter')->checkQueueNum($product,Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION);
68
+ if($parentProduct = $this->getParentProduct($product)) {
69
+ Mage::helper('magentokey_newsletter')->checkQueueNum($parentProduct,Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION);
70
+ }
71
+ } else {
72
+ Mage::helper('magentokey_newsletter')->checkPriceMatchQueueNum($product,$finalPrice);
73
+ }
74
+ } catch (Exception $e) {
75
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
76
+ }
77
+ }
78
+ }
79
+ if ($finalPriceOriginal != $finalPrice) {
80
+ $update = true;
81
+ }
82
+ //Stock
83
+ $isInStockOriginal = $productOriginal->getIsInStock();
84
+ $isInStock = $product->getStockData();
85
+ if ($this->_isStockEnable()) {
86
+ if (!$isInStockOriginal && $isInStock['is_in_stock'] && $isInStock['qty']) {//Stock Event
87
+ try {
88
+ Mage::helper('magentokey_newsletter')->checkQueueNum($product,Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE);
89
+ if($parentProduct = $this->getParentProduct($product)) {
90
+ Mage::helper('magentokey_newsletter')->checkQueueNum($parentProduct,Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE);
91
+ }
92
+ } catch (Exception $e) {
93
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
94
+ }
95
+ $update = true;
96
+ }
97
+ }
98
+ if ($this->_isUpdateEnable() && $update) {
99
+ try {
100
+ Mage::helper('magentokey_newsletter')->checkQueueNum($product,Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE);
101
+ if($parentProduct = $this->getParentProduct($product)) {
102
+ Mage::helper('magentokey_newsletter')->checkQueueNum($parentProduct,Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE);
103
+ }
104
+ } catch (Exception $e) {
105
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
106
+ }
107
+ }
108
+ return $this;
109
+
110
+ }
111
+ public function cancelOrderItem($observer)
112
+ {
113
+ if ($this->_isStockEnable()) {
114
+ $item = $observer->getEvent()->getItem();
115
+ $children = $item->getChildrenItems();
116
+ $qty = $item->getQtyOrdered() - max($item->getQtyShipped(), $item->getQtyInvoiced()) - $item->getQtyCanceled();
117
+
118
+ if ($item->getId() && ($productId = $item->getProductId()) && empty($children) && $qty) {
119
+ $stockItem = Mage::getModel('cataloginventory/stock_item')->loadByProduct($productId);
120
+ $product = Mage::getModel('catalog/product')->load($productId);
121
+ $isInStock = $stockItem->getData('is_in_stock');
122
+ if ($this->getCanBackInStock() && !$isInStock && $stockItem->getId() && Mage::helper('catalogInventory')->isQty($stockItem->getTypeId())) {
123
+ if ($stockItem->getQty() > $stockItem->getMinQty()) {
124
+ $stockItem->setIsInStock(true)->setStockStatusChangedAutomaticallyFlag(true);
125
+ $stockItem->save();
126
+ try {
127
+ Mage::helper('magentokey_newsletter')->checkQueueNum($product, Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE);
128
+ Mage::helper('magentokey_newsletter')->checkQueueNum($product, Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE);
129
+ if($parentProduct = $this->getParentProduct($product)) {
130
+ Mage::helper('magentokey_newsletter')->checkQueueNum($parentProduct,Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE);
131
+ Mage::helper('magentokey_newsletter')->checkQueueNum($parentProduct,Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE);
132
+ }
133
+ } catch (Exception $e) {
134
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
135
+ }
136
+ }
137
+ }
138
+ }
139
+ }
140
+
141
+ return $this;
142
+ }
143
+
144
+ public function getParentProduct(Mage_Catalog_Model_Product $product)
145
+ {
146
+ //not work with all magento all version
147
+ if ($this->isConfigurableEnable() && $product->type_id == "simple"){
148
+ $parentIds = Mage::getResourceSingleton('catalog/product_type_configurable')
149
+ ->getParentIdsByChild($product->getId());
150
+ if (isset($parentIds[0])) {
151
+ return Mage::getModel('catalog/product')->load($parentIds[0]);
152
+ }
153
+ }
154
+ return NULL;
155
+ }
156
+ public function isConfigurableEnable()
157
+ {
158
+ return Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_TYPE_CONFIG);
159
+ }
160
+ public function isPriceMatchEnable()
161
+ {
162
+ return Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_PRODUCT_PRICE_REDUCTION_MATCH);
163
+ }
164
+ public function scheduledSend($schedule)
165
+ {
166
+ $countOfQueue = 3;
167
+ $countOfSubscritions = 20;
168
+
169
+ $collection = Mage::getModel('magentokey_newsletter/queue')
170
+ ->getSubscribersCollection()
171
+ ->useOnlyUnsent()
172
+ ->showCustomerInfo()
173
+ ->setPageSize($countOfQueue)
174
+ ->setCurPage(1)
175
+ ->load();
176
+
177
+ $collection->walk('sendPerSubscriber', array($countOfSubscritions));
178
+ }
179
+ }
app/code/community/Magentokey/Newsletter/Model/Problem.php ADDED
@@ -0,0 +1,95 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Joy <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Model_Problem extends Mage_Core_Model_Abstract
8
+ {
9
+ /**
10
+ * Current Subscriber
11
+ *
12
+ * @var Mage_Newsletter_Model_Subscriber
13
+ */
14
+ protected $_subscriber = null;
15
+
16
+ /**
17
+ * Initialize Newsletter Problem Model
18
+ */
19
+ protected function _construct()
20
+ {
21
+ $this->_init('magentokey_newsletter/problem');
22
+ }
23
+
24
+ /**
25
+ * Add Subscriber Data
26
+ *
27
+ * @param Mage_Newsletter_Model_Subscriber $subscriber
28
+ * @return Mage_Newsletter_Model_Problem
29
+ */
30
+ public function addSubscriberData(Magentokey_Newsletter_Model_Subscriber $subscriber)
31
+ {
32
+ $this->setSubscriberId($subscriber->getId());
33
+ return $this;
34
+ }
35
+
36
+ /**
37
+ * Add Queue Data
38
+ *
39
+ * @param Mage_Newsletter_Model_Queue $queue
40
+ * @return Mage_Newsletter_Model_Problem
41
+ */
42
+ public function addQueueData(Magentokey_Newsletter_Model_Queue $queue)
43
+ {
44
+ $this->setQueueId($queue->getId());
45
+ return $this;
46
+ }
47
+
48
+ /**
49
+ * Add Error Data
50
+ *
51
+ * @param Exception $e
52
+ * @return Mage_Newsletter_Model_Problem
53
+ */
54
+ public function addErrorData(Exception $e)
55
+ {
56
+ $this->setProblemErrorCode($e->getCode());
57
+ $this->setProblemErrorText($e->getMessage());
58
+ return $this;
59
+ }
60
+
61
+ /**
62
+ * Retrieve Subscriber
63
+ *
64
+ * @return Mage_Newsletter_Model_Subscriber
65
+ */
66
+ public function getSubscriber()
67
+ {
68
+ if(!$this->getSubscriberId()) {
69
+ return null;
70
+ }
71
+
72
+ if(is_null($this->_subscriber)) {
73
+ $this->_subscriber = Mage::getModel('magentokey_newsletter/subscriber')
74
+ ->load($this->getSubscriberId());
75
+ }
76
+
77
+ return $this->_subscriber;
78
+ }
79
+
80
+ /**
81
+ * Unsubscribe Subscriber
82
+ *
83
+ * @return Mage_Newsletter_Model_Problem
84
+ */
85
+ public function unsubscribe()
86
+ {
87
+ if($this->getSubscriber()) {
88
+ $this->getSubscriber()->setSubscriberStatus(Magentokey_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED)
89
+ ->setIsStatusChanged(true)
90
+ ->save();
91
+ }
92
+ return $this;
93
+ }
94
+
95
+ }
app/code/community/Magentokey/Newsletter/Model/Queue.php ADDED
@@ -0,0 +1,146 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Model_Queue extends Mage_Core_Model_Template
8
+ {
9
+ protected $_template;
10
+ protected $_subscribersCollection = null;
11
+ protected $_stores = array();
12
+
13
+ const STATUS_NEVER = 0;
14
+ const STATUS_SENDING = 1;
15
+ const STATUS_CANCEL = 2;
16
+ const STATUS_SENT = 3;
17
+ const STATUS_PAUSE = 4;
18
+
19
+ protected function _construct()
20
+ {
21
+ $this->_init('magentokey_newsletter/queue');
22
+ }
23
+
24
+ public function getSubscribersCollection()
25
+ {
26
+ if (is_null($this->_subscribersCollection)) {
27
+ $this->_subscribersCollection = Mage::getResourceModel('magentokey_newsletter/subscriber_collection')
28
+ ->useQueue($this);
29
+ }
30
+ return $this->_subscribersCollection;
31
+ }
32
+
33
+ public function sendPerSubscriber($count=20, array $additionalVariables=array())
34
+ {
35
+ if($this->getQueueStatus()!=self::STATUS_SENDING && $this->getQueueStatus()!=self::STATUS_NEVER && $this->getQueueStatus()!=self::STATUS_PAUSE) {
36
+ return $this;
37
+ }
38
+ //SET PRODUCT TEMPLATE INFO
39
+ if(!$productId = $this->getProductId()) {
40
+ return $this;
41
+ } else {
42
+ Mage::register('_magentokey_newsletter_product', $productId);
43
+ }
44
+
45
+ $this->_subscribersCollection = null;
46
+ if ($this->getSubscribersCollection()->getSize() == 0) {
47
+ $this->_finishQueue();
48
+ return $this;
49
+ }
50
+
51
+ $collection = $this->getSubscribersCollection()
52
+ ->useOnlyUnsent()
53
+ ->showCustomerInfo()
54
+ ->setPageSize($count)
55
+ ->setCurPage(1)
56
+ ->load();
57
+ //echo count($collection).$collection->getSelect().'send item3';if(count($collection)) { die(); };
58
+ /* @var $sender Mage_Core_Model_Email_Template */
59
+ $sender = Mage::getModel('core/email_template');
60
+ $sender->setSenderName($this->getNewsletterSenderName())
61
+ ->setSenderEmail($this->getNewsletterSenderEmail())
62
+ ->setTemplateType(self::TYPE_HTML)
63
+ ->setTemplateSubject($this->getNewsletterSubject())
64
+ ->setTemplateText($this->getNewsletterText())
65
+ ->setTemplateStyles($this->getNewsletterStyles())
66
+ ->setTemplateFilter(Mage::helper('magentokey_newsletter')->getTemplateProcessor());
67
+ foreach($collection->getItems() as $item) {
68
+
69
+ $email = $item->getSubscriberEmail();
70
+ $name = $item->getSubscriberFullName();
71
+
72
+ $sender->emulateDesign($item->getStoreId());
73
+ $successSend = $sender->send($email, $name, array('subscriber' => $item));
74
+ $sender->revertDesign();
75
+ if($successSend) {
76
+ $item->received($this);
77
+ } else {
78
+ $problem = Mage::getModel('magentokey_newsletter/problem');
79
+ $notification = Mage::helper('magentokey_newsletter')->__('Please refer to exception.log');
80
+ $problem->addSubscriberData($item)
81
+ ->addQueueData($this)
82
+ ->addErrorData(new Exception($notification))
83
+ ->save();
84
+ $item->received($this);
85
+ }
86
+ }
87
+ if(count($collection->getItems()) < $count-1 || count($collection->getItems()) == 0) {
88
+ $this->_finishQueue();
89
+ }
90
+ Mage::unregister('_magentokey_newsletter_product');
91
+ return $this;
92
+ }
93
+
94
+ protected function _finishQueue()
95
+ {
96
+ $this->setSentAt(Mage::getSingleton('core/date')->gmtDate());
97
+ $this->setQueueStatus(self::STATUS_SENT);
98
+ $this->save();
99
+ return $this;
100
+ }
101
+
102
+ public function addSubscribersToQueue(array $subscriberIds)
103
+ {
104
+ $this->_getResource()->addSubscribersToQueue($this, $subscriberIds);
105
+
106
+ return $this;
107
+ }
108
+
109
+
110
+ public function getTemplate()
111
+ {
112
+ if (is_null($this->_template)) {
113
+ $this->_template = Mage::getModel('magentokey_newsletter/template')
114
+ ->load($this->getTemplateId());
115
+ }
116
+ return $this->_template;
117
+ }
118
+ public function addQueue($productId, $type, $templateId, $subscriberCollection)
119
+ {
120
+ try {
121
+ $template = Mage::getModel('magentokey_newsletter/template')->load($templateId);
122
+ $this->setProductId($productId)
123
+ ->setSubscriberType($type)
124
+ ->setNewsletterSenderName($template->getTemplateSenderName())
125
+ ->setNewsletterSenderEmail($template->getTemplateSenderEmail())
126
+ ->setNewsletterSubject($template->getTemplateSubject())
127
+ ->setNewsletterText($template->getTemplateText())
128
+ ->setNewsletterStyles($template->getTemplateStyles())
129
+ ->setTemplateId($templateId)
130
+ ->setQueueNum(count($subscriberCollection))
131
+ ->setAddedAt(Mage::getModel('core/date')->gmtDate())
132
+ ->save();
133
+ $subscriberIds = array();
134
+ foreach ($subscriberCollection as $s) {
135
+ array_push($subscriberIds, $s->getSubscriberId());
136
+ }
137
+ $this->addSubscribersToQueue($subscriberIds);
138
+ } catch (Exception $e) {
139
+ //Set Newsletter Problem
140
+ }
141
+ }
142
+ public function getType(){
143
+ return $this->getNewsletterType();
144
+ }
145
+
146
+ }
app/code/community/Magentokey/Newsletter/Model/Session.php ADDED
@@ -0,0 +1,39 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Model_Session extends Mage_Core_Model_Session_Abstract
8
+ {
9
+ public function __construct()
10
+ {
11
+ $this->init('magentokey_newsletter');
12
+ }
13
+
14
+ public function addError($message)
15
+ {
16
+ $this->setErrorMessage($message);
17
+ return $this;
18
+ }
19
+
20
+ public function addSuccess($message)
21
+ {
22
+ $this->setSuccessMessage($message);
23
+ return $this;
24
+ }
25
+
26
+ public function getError()
27
+ {
28
+ $message = $this->getErrorMessage();
29
+ $this->unsErrorMessage();
30
+ return $message;
31
+ }
32
+
33
+ public function getSuccess()
34
+ {
35
+ $message = $this->getSuccessMessage();
36
+ $this->unsSuccessMessage();
37
+ return $message;
38
+ }
39
+ }
app/code/community/Magentokey/Newsletter/Model/Subscriber.php ADDED
@@ -0,0 +1,474 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Model_Subscriber extends Mage_Core_Model_Abstract
8
+ {
9
+ const TYPE_UPDATE = 0;
10
+ const TYPE_PRICE_REDUCTION = 1;
11
+ const TYPE_STOCK_AVAILABLE = 2;
12
+ const TYPE_CATEGORY_NEW = 3;
13
+ const TYPE_CATEGORY_PRICE = 4;
14
+
15
+ const STATUS_SUBSCRIBED = 1;
16
+ const STATUS_NOT_ACTIVE = 2;
17
+ const STATUS_UNSUBSCRIBED = 3;
18
+ const STATUS_UNCONFIRMED = 4;
19
+
20
+ const XML_PATH_CONFIRM_EMAIL_TEMPLATE = 'magentokey_newsletter/subscription/confirm_email_template';
21
+ const XML_PATH_CONFIRM_EMAIL_IDENTITY = 'magentokey_newsletter/subscription/confirm_email_identity';
22
+ const XML_PATH_SUCCESS_EMAIL_TEMPLATE = 'magentokey_newsletter/subscription/success_email_template';
23
+ const XML_PATH_SUCCESS_EMAIL_IDENTITY = 'magentokey_newsletter/subscription/success_email_identity';
24
+ const XML_PATH_UNSUBSCRIBE_EMAIL_TEMPLATE = 'magentokey_newsletter/subscription/un_email_template';
25
+ const XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY = 'magentokey_newsletter/subscription/un_email_identity';
26
+ const XML_PATH_CONFIRMATION_FLAG = 'magentokey_newsletter/subscription/confirm';
27
+ const XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG = 'magentokey_newsletter/subscription/allow_guest_subscribe';
28
+
29
+ const XML_TYPE_SIMPLE = 'magentokey_newsletter/product_type/simple_enable';
30
+ const XML_TYPE_CONFIG = 'magentokey_newsletter/product_type/configurable_enable';
31
+ const XML_TYPE_VIRTUAL = 'magentokey_newsletter/product_type/virtual_enable';
32
+
33
+ const XML_DATE_DURATION_ENABLE = 'magentokey_newsletter/date/duration_enable';
34
+ const XML_DATE_DURATION_DAY = 'magentokey_newsletter/date/duration_day';
35
+ const XML_DATE_PAGE_ENABLE = 'magentokey_newsletter/date/date_enable';
36
+ const XML_DATE_PAGE_DEFAULT = 'magentokey_newsletter/date/date_default';
37
+ const XML_DATE_TIMEOUT_ENABLE = 'magentokey_newsletter/date/timeout_enable';
38
+ const XML_DATE_TIMEOUT_DAY = 'magentokey_newsletter/date/timeout_day';
39
+
40
+ const XML_PRODUCT_ENABLE = 'magentokey_newsletter/product/enable';
41
+ const XML_PRODUCT_POPUP = 'magentokey_newsletter/product/popup';
42
+ const XML_PRODUCT_TITLE_PRICE = 'magentokey_newsletter/product/title_price';
43
+ const XML_PRODUCT_NOTICE_PRICE = 'magentokey_newsletter/product/notice_price';
44
+ const XML_PRODUCT_TITLE_STOCK = 'magentokey_newsletter/product/title_stock';
45
+ const XML_PRODUCT_NOTICE_STOCK = 'magentokey_newsletter/product/notice_stock';
46
+ const XML_PRODUCT_TITLE_UPDATE = 'magentokey_newsletter/product/title_update';
47
+ const XML_PRODUCT_NOTICE_UPDATE = 'magentokey_newsletter/product/notice_update';
48
+
49
+ const XML_PRODUCT_UPDATE = 'magentokey_newsletter/product/update';
50
+ const XML_PRODUCT_PRICE_REDUCTION = 'magentokey_newsletter/product/price_reduction';
51
+ const XML_PRODUCT_PRICE_REDUCTION_AMOUNT = 'magentokey_newsletter/product/price_reduction_amount';
52
+ const XML_PRODUCT_PRICE_REDUCTION_MATCH = 'magentokey_newsletter/product/price_reduction_match';
53
+ const XML_PRODUCT_STOCK_AVAILABLE = 'magentokey_newsletter/product/stock_available';
54
+ const XML_PRODUCT_STOCK_AVAILABLE_AMOUNT = 'magentokey_newsletter/product/stock_available_amount';
55
+
56
+ const XML_CATEGORY_ENABLE = 'magentokey_newsletter/category/enable';
57
+ const XML_CATEGORY_POPUP = 'magentokey_newsletter/category/popup';
58
+ const XML_CATEGORY_NEW = 'magentokey_newsletter/category/new';
59
+ const XML_CATEGORY_PRICE = 'magentokey_newsletter/category/price';
60
+ const XML_CATEGORY_TITLE_NEW = 'magentokey_newsletter/category/title_new';
61
+ const XML_CATEGORY_NOTICE_NEW = 'magentokey_newsletter/category/notice_new';
62
+ const XML_CATEGORY_TITLE_PRICE = 'magentokey_newsletter/category/title_price';
63
+ const XML_CATEGORY_NOTICE_PRICE = 'magentokey_newsletter/category/notice_price';
64
+
65
+ /**
66
+ * True if data changed
67
+ *
68
+ * @var bool
69
+ */
70
+ protected $_isStatusChanged = false;
71
+
72
+ /**
73
+ * Initialize resource model
74
+ */
75
+ protected function _construct()
76
+ {
77
+ $this->_init('magentokey_newsletter/subscriber');
78
+ }
79
+
80
+ /**
81
+ * Alias for getSubscriberId()
82
+ *
83
+ * @return int
84
+ */
85
+ public function getId()
86
+ {
87
+ return $this->getSubscriberId();
88
+ }
89
+
90
+ /**
91
+ * Alias for setSubscriberId()
92
+ *
93
+ * @param int $value
94
+ */
95
+ public function setId($value)
96
+ {
97
+ return $this->setSubscriberId($value);
98
+ }
99
+
100
+ /**
101
+ * Alias for getSubscriberConfirmCode()
102
+ *
103
+ * @return string
104
+ */
105
+ public function getCode()
106
+ {
107
+ return $this->getSubscriberConfirmCode();
108
+ }
109
+
110
+ /**
111
+ * Return link for confirmation of subscription
112
+ *
113
+ * @return string
114
+ */
115
+ public function getConfirmationLink() {
116
+ return Mage::helper('magentokey_newsletter')->getConfirmationUrl($this);
117
+ }
118
+
119
+ /**
120
+ * Returns Insubscribe url
121
+ *
122
+ * @return string
123
+ */
124
+ public function getUnsubscriptionLink() {
125
+ return Mage::helper('magentokey_newsletter')->getUnsubscribeUrl($this);
126
+ }
127
+
128
+ /**
129
+ * Alias for setSubscriberConfirmCode()
130
+ *
131
+ * @param string $value
132
+ */
133
+ public function setCode($value)
134
+ {
135
+ return $this->setSubscriberConfirmCode($value);
136
+ }
137
+
138
+ /**
139
+ * Alias for getSubscriberStatus()
140
+ *
141
+ * @return int
142
+ */
143
+ public function getStatus()
144
+ {
145
+ return $this->getSubscriberStatus();
146
+ }
147
+
148
+ /**
149
+ * Alias for setSubscriberStatus()
150
+ *
151
+ * @param int
152
+ */
153
+ public function setStatus($value)
154
+ {
155
+ return $this->setSubscriberStatus($value);
156
+ }
157
+
158
+ /**
159
+ * Set the error messages scope for subscription
160
+ *
161
+ * @param boolean $scope
162
+ * @return Mage_Newsletter_Model_Subscriber
163
+ */
164
+
165
+ public function setMessagesScope($scope)
166
+ {
167
+ $this->getResource()->setMessagesScope($scope);
168
+ return $this;
169
+ }
170
+
171
+ /**
172
+ * Alias for getSubscriberEmail()
173
+ *
174
+ * @return string
175
+ */
176
+ public function getEmail()
177
+ {
178
+ return $this->getSubscriberEmail();
179
+ }
180
+
181
+ /**
182
+ * Alias for setSubscriberEmail()
183
+ *
184
+ * @param string $value
185
+ */
186
+ public function setEmail($value)
187
+ {
188
+ return $this->setSubscriberEmail($value);
189
+ }
190
+
191
+ public function setType($value)
192
+ {
193
+ return $this->setSubscriberType($value);
194
+ }
195
+ public function setAmount($value)
196
+ {
197
+ return $this->setSubscriberTypeAmount($value);
198
+ }
199
+
200
+ /**
201
+ * Return status change flag value
202
+ *
203
+ * @return boolean
204
+ */
205
+ public function getIsStatusChanged()
206
+ {
207
+ return $this->_isStatusChanged;
208
+ }
209
+ public function isEmailAvailable($email) {
210
+ $customerSession = Mage::getSingleton('customer/session');
211
+ $ownerId = Mage::getModel('customer/customer')
212
+ ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
213
+ ->loadByEmail($email)
214
+ ->getId();
215
+ if (!$ownerId || ($customerSession->isLoggedIn() && $ownerId == $customerSession->getId())) {
216
+ return true;
217
+ } else {
218
+ return false;
219
+ }
220
+ }
221
+ public function isSubscribed($email, $categoryId, $productId, $type, $storeId, $customerId)
222
+ {
223
+ //echo $email.$categoryId.$productId.$type.$storeId.$customerId;
224
+ $subscriber = $this->getCollection()
225
+ ->addFieldTofilter('subscriber_email', $email)
226
+ ->addFieldTofilter('category_id', $categoryId)
227
+ ->addFieldTofilter('product_id', $productId)
228
+ ->addFieldTofilter('subscriber_type', $type)
229
+ ->addFieldTofilter('store_id', $storeId)
230
+ ->addFieldTofilter('customer_id', $customerId)
231
+ ->addOrder('added_at', 'DESC')
232
+ ->load();
233
+ //echo $subscriber->getSelect();
234
+ //echo "<xmp>";var_dump(count($subscriber));echo "</xmp>";
235
+ if (count($subscriber) && $subscriber->getFirstItem()->getId()) {
236
+ return $this->load($subscriber->getFirstItem()->getId());
237
+ } else {
238
+ return false;
239
+ }
240
+ }
241
+ public function updateSubscriber($amount = '', $from = '', $to = '')
242
+ {
243
+ $from = $from ? $from : Mage::helper('magentokey_newsletter')->getCurrentDate();
244
+ if (!$to) {
245
+ $to = Mage::helper('magentokey_newsletter')->getDefaultDuration();
246
+ }
247
+ $this->setDateFrom($from)
248
+ ->setDateTo($to);
249
+ if ($amount) {
250
+ $this->setAmount($amount);
251
+ }
252
+ try {
253
+ $this->save();
254
+ } catch(Exception $e) {
255
+ throw new Exception($e->getMessage());
256
+ }
257
+
258
+ }
259
+ public function subscribe($email,$customerId,$categoryId,$productId,$productType,$type,$amount,$storeId,$from,$to)
260
+ {
261
+ $customerSession = Mage::getSingleton('customer/session');
262
+ $isConfirmNeed = (Mage::getStoreConfig(self::XML_PATH_CONFIRMATION_FLAG) == 1) ? true : false;
263
+ $ownerId = Mage::getModel('customer/customer')
264
+ ->setWebsiteId(Mage::app()->getStore()->getWebsiteId())
265
+ ->loadByEmail($email)
266
+ ->getId();
267
+ $isSubscribeOwnEmail = $customerSession->isLoggedIn() && $ownerId == $customerSession->getId();
268
+ if ($isConfirmNeed === true) {
269
+ // if user subscribes own login email - confirmation is not needed
270
+ $isOwnSubscribes = $isSubscribeOwnEmail;
271
+ if ($isOwnSubscribes == true){
272
+ $this->setStatus(self::STATUS_SUBSCRIBED);
273
+ } else {
274
+ $this->setStatus(self::STATUS_UNCONFIRMED);
275
+ }
276
+ } else {
277
+ $this->setStatus(self::STATUS_SUBSCRIBED);
278
+ }
279
+ $from = $from ? $from : Mage::helper('magentokey_newsletter')->getCurrentDate();
280
+ if (!$to) {
281
+ $to = Mage::helper('magentokey_newsletter')->getDefaultDuration();
282
+ }
283
+ $this->setDateFrom($from)
284
+ ->setDateTo($to);
285
+ $this->setSubscriberEmail($email)
286
+ ->setCustomerId($customerId)
287
+ ->setCategoryId($categoryId)
288
+ ->setProductId($productId)
289
+ ->setProductType($productType)
290
+ ->setType($type)
291
+ ->setAmount($amount)
292
+ ->setStoreId($storeId)
293
+ ->setDateFrom($from)
294
+ ->setDateTo($to);
295
+
296
+ try {
297
+ $this->save();
298
+ if ($isConfirmNeed === true && $isOwnSubscribes === false) {
299
+
300
+ $this->sendConfirmationRequestEmail();
301
+ } else {
302
+ $this->sendConfirmationSuccessEmail();
303
+ }
304
+ return $this->getStatus();
305
+ } catch (Exception $e) {
306
+ throw new Exception($e->getMessage());
307
+ }
308
+ }
309
+
310
+ /**
311
+ * Unsubscribes loaded subscription
312
+ *
313
+ */
314
+ public function unsubscribe()
315
+ {
316
+ if ($this->hasCheckCode() && $this->getCode() != $this->getCheckCode()) {
317
+ Mage::throwException(Mage::helper('magentokey_newsletter')->__('Invalid subscription confirmation code.'));
318
+ }
319
+
320
+ $this->setSubscriberStatus(self::STATUS_UNSUBSCRIBED)
321
+ ->save();
322
+ $this->sendUnsubscriptionEmail();
323
+ return $this;
324
+ }
325
+
326
+ /**
327
+ * Confirms subscriber newsletter
328
+ *
329
+ * @param string $code
330
+ * @return boolean
331
+ */
332
+ public function confirm($code)
333
+ {
334
+ if($this->getCode()==$code) {
335
+ $this->setStatus(self::STATUS_SUBSCRIBED)
336
+ ->save();
337
+ return true;
338
+ }
339
+
340
+ return false;
341
+ }
342
+
343
+ /**
344
+ * Mark receiving subscriber of queue newsletter
345
+ *
346
+ * @param Mage_Newsletter_Model_Queue $queue
347
+ * @return boolean
348
+ */
349
+ public function received(Magentokey_Newsletter_Model_Queue $queue)
350
+ {
351
+ $this->getResource()->received($this,$queue);
352
+ return $this;
353
+ }
354
+
355
+ /**
356
+ * Sends out confirmation email
357
+ *
358
+ * @return Mage_Newsletter_Model_Subscriber
359
+ */
360
+ public function sendConfirmationRequestEmail()
361
+ {
362
+ if ($this->getImportMode()) {
363
+ return $this;
364
+ }
365
+
366
+ if(!Mage::getStoreConfig(self::XML_PATH_CONFIRM_EMAIL_TEMPLATE)
367
+ || !Mage::getStoreConfig(self::XML_PATH_CONFIRM_EMAIL_IDENTITY)
368
+ ) {
369
+ return $this;
370
+ }
371
+
372
+ $translate = Mage::getSingleton('core/translate');
373
+ /* @var $translate Mage_Core_Model_Translate */
374
+ $translate->setTranslateInline(false);
375
+
376
+ $email = Mage::getModel('core/email_template');
377
+
378
+ $email->sendTransactional(
379
+ Mage::getStoreConfig(self::XML_PATH_CONFIRM_EMAIL_TEMPLATE),
380
+ Mage::getStoreConfig(self::XML_PATH_CONFIRM_EMAIL_IDENTITY),
381
+ $this->getEmail(),
382
+ $this->getSubscriberFullName(),
383
+ array('subscriber'=>$this)
384
+ );
385
+ $translate->setTranslateInline(true);
386
+
387
+ return $this;
388
+ }
389
+
390
+ /**
391
+ * Sends out confirmation success email
392
+ *
393
+ * @return Mage_Newsletter_Model_Subscriber
394
+ */
395
+ public function sendConfirmationSuccessEmail()
396
+ {
397
+ if ($this->getImportMode()) {
398
+ return $this;
399
+ }
400
+
401
+ if(!Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE)
402
+ || !Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY)
403
+ ) {
404
+ return $this;
405
+ }
406
+
407
+ $translate = Mage::getSingleton('core/translate');
408
+ /* @var $translate Mage_Core_Model_Translate */
409
+ $translate->setTranslateInline(false);
410
+
411
+ $email = Mage::getModel('core/email_template');
412
+
413
+ $email->sendTransactional(
414
+ Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_TEMPLATE),
415
+ Mage::getStoreConfig(self::XML_PATH_SUCCESS_EMAIL_IDENTITY),
416
+ $this->getEmail(),
417
+ $this->getSubscriberFullName(),
418
+ array('subscriber'=>$this)
419
+ );
420
+
421
+ $translate->setTranslateInline(true);
422
+
423
+ return $this;
424
+ }
425
+
426
+ /**
427
+ * Sends out unsubsciption email
428
+ *
429
+ * @return Mage_Newsletter_Model_Subscriber
430
+ */
431
+ public function sendUnsubscriptionEmail()
432
+ {
433
+ if ($this->getImportMode()) {
434
+ return $this;
435
+ }
436
+ if(!Mage::getStoreConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_TEMPLATE)
437
+ || !Mage::getStoreConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY)
438
+ ) {
439
+ return $this;
440
+ }
441
+
442
+ $translate = Mage::getSingleton('core/translate');
443
+ /* @var $translate Mage_Core_Model_Translate */
444
+ $translate->setTranslateInline(false);
445
+
446
+ $email = Mage::getModel('core/email_template');
447
+
448
+ $email->sendTransactional(
449
+ Mage::getStoreConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_TEMPLATE),
450
+ Mage::getStoreConfig(self::XML_PATH_UNSUBSCRIBE_EMAIL_IDENTITY),
451
+ $this->getEmail(),
452
+ $this->getSubscriberFullName(),
453
+ array('subscriber'=>$this)
454
+ );
455
+
456
+ $translate->setTranslateInline(true);
457
+
458
+ return $this;
459
+ }
460
+
461
+ /**
462
+ * Retrieve Subscribers Full Name if it was set
463
+ *
464
+ * @return string|null
465
+ */
466
+ public function getSubscriberFullName()
467
+ {
468
+ $name = null;
469
+ if ($this->hasCustomerFirstname() || $this->hasCustomerLastname()) {
470
+ $name = $this->getCustomerFirstname() . ' ' . $this->getCustomerLastname();
471
+ }
472
+ return $name;
473
+ }
474
+ }
app/code/community/Magentokey/Newsletter/Model/Template.php ADDED
@@ -0,0 +1,349 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Model_Template extends Mage_Core_Model_Template
8
+ {
9
+ const TYPE_TEXT= 1;
10
+ const TYPE_HTML = 2;
11
+ const STATUS_DISABLE = 0;
12
+ const STATUS_ENABLE = 1;
13
+
14
+ /**
15
+ * Template Text Preprocessed flag
16
+ *
17
+ * @var bool
18
+ */
19
+ protected $_preprocessFlag = false;
20
+
21
+ /**
22
+ * Mail object
23
+ *
24
+ * @var Zend_Mail
25
+ */
26
+ protected $_mail;
27
+
28
+ /**
29
+ * Initialize resource model
30
+ *
31
+ */
32
+ protected function _construct()
33
+ {
34
+ $this->_init('magentokey_newsletter/template');
35
+ }
36
+
37
+ /**
38
+ * Validate Newsletter template
39
+ *
40
+ * @throws Mage_Core_Exception
41
+ * @return bool
42
+ */
43
+ public function validate()
44
+ {
45
+ $validators = array(
46
+ 'template_code' => array(Zend_Filter_Input::ALLOW_EMPTY => false),
47
+ 'template_type' => 'Int',
48
+ 'template_sender_email' => 'EmailAddress',
49
+ 'template_sender_name' => array(Zend_Filter_Input::ALLOW_EMPTY => false)
50
+ );
51
+ $data = array();
52
+ foreach (array_keys($validators) as $validateField) {
53
+ $data[$validateField] = $this->getDataUsingMethod($validateField);
54
+ }
55
+
56
+ $validateInput = new Zend_Filter_Input(array(), $validators, $data);
57
+ if (!$validateInput->isValid()) {
58
+ $errorMessages = array();
59
+ foreach ($validateInput->getMessages() as $messages) {
60
+ if (is_array($messages)) {
61
+ foreach ($messages as $message) {
62
+ $errorMessages[] = $message;
63
+ }
64
+ }
65
+ else {
66
+ $errorMessages[] = $messages;
67
+ }
68
+ }
69
+
70
+ Mage::throwException(join("\n", $errorMessages));
71
+ }
72
+ }
73
+
74
+ /**
75
+ * Processing object before save data
76
+ *
77
+ * @return Magentokey_Newsletter_Model_Template
78
+ */
79
+ protected function _beforeSave()
80
+ {
81
+ $this->validate();
82
+ return parent::_beforeSave();
83
+ }
84
+
85
+ /**
86
+ * Load template by code
87
+ *
88
+ * @param string $templateCode
89
+ * @return Magentokey_Newsletter_Model_Template
90
+ */
91
+ public function loadByCode($templateCode)
92
+ {
93
+ $this->_getResource()->loadByCode($this, $templateCode);
94
+ return $this;
95
+ }
96
+
97
+ /**
98
+ * Return true if this template can be used for sending queue as main template
99
+ *
100
+ * @return boolean
101
+ * @deprecated since 1.4.0.1
102
+ */
103
+ public function isValidForSend()
104
+ {
105
+ return !Mage::getStoreConfigFlag('system/smtp/disable')
106
+ && $this->getTemplateSenderName()
107
+ && $this->getTemplateSenderEmail()
108
+ && $this->getTemplateSubject();
109
+ }
110
+
111
+ /**
112
+ * Getter for template type
113
+ *
114
+ * @return int|string
115
+ */
116
+ public function getType(){
117
+ return $this->getTemplateType();
118
+ }
119
+
120
+ /**
121
+ * Check is Preprocessed
122
+ *
123
+ * @return bool
124
+ */
125
+ public function isPreprocessed()
126
+ {
127
+ return strlen($this->getTemplateTextPreprocessed()) > 0;
128
+ }
129
+
130
+ /**
131
+ * Check Template Text Preprocessed
132
+ *
133
+ * @return bool
134
+ */
135
+ public function getTemplateTextPreprocessed()
136
+ {
137
+ if ($this->_preprocessFlag) {
138
+ $this->setTemplateTextPreprocessed($this->getProcessedTemplate());
139
+ }
140
+
141
+ return $this->getData('template_text_preprocessed');
142
+ }
143
+
144
+ /**
145
+ * Retrieve processed template
146
+ *
147
+ * @param array $variables
148
+ * @param bool $usePreprocess
149
+ * @return string
150
+ */
151
+ public function getProcessedTemplate(array $variables = array(), $usePreprocess = false)
152
+ {
153
+ /* @var $processor Magentokey_Newsletter_Model_Template_Filter */
154
+ $processor = Mage::helper('magentokey_newsletter')->getTemplateProcessor();
155
+
156
+ if (!$this->_preprocessFlag) {
157
+ $variables['this'] = $this;
158
+ }
159
+
160
+ if (Mage::app()->isSingleStoreMode()) {
161
+ $processor->setStoreId(Mage::app()->getStore());
162
+ } else {
163
+ $processor->setStoreId(Mage::app()->getRequest()->getParam('store_id'));
164
+ }
165
+
166
+ $processor
167
+ ->setIncludeProcessor(array($this, 'getInclude'))
168
+ ->setVariables($variables);
169
+
170
+ if ($usePreprocess && $this->isPreprocessed()) {
171
+ return $processor->filter($this->getPreparedTemplateText(true));
172
+ }
173
+
174
+ return $processor->filter($this->getPreparedTemplateText());
175
+ }
176
+
177
+ /**
178
+ * Makes additional text preparations for HTML templates
179
+ *
180
+ * @param bool $usePreprocess Use Preprocessed text or original text
181
+ * @return string
182
+ */
183
+ public function getPreparedTemplateText($usePreprocess = false)
184
+ {
185
+ $text = $usePreprocess ? $this->getTemplateTextPreprocessed() : $this->getTemplateText();
186
+
187
+ if ($this->_preprocessFlag || $this->isPlain() || !$this->getTemplateStyles()) {
188
+ return $text;
189
+ }
190
+ // wrap styles into style tag
191
+ $html = "<style type=\"text/css\">\n%s\n</style>\n%s";
192
+ return sprintf($html, $this->getTemplateStyles(), $text);
193
+ }
194
+
195
+ /**
196
+ * Retrieve included template
197
+ *
198
+ * @param string $templateCode
199
+ * @param array $variables
200
+ * @return string
201
+ */
202
+ public function getInclude($templateCode, array $variables)
203
+ {
204
+ return Mage::getModel('magentokey_newsletter/template')
205
+ ->loadByCode($templateCode)
206
+ ->getProcessedTemplate($variables);
207
+ }
208
+
209
+ /**
210
+ * Retrieve mail object instance
211
+ *
212
+ * @return Zend_Mail
213
+ * @deprecated since 1.4.0.1
214
+ */
215
+ public function getMail()
216
+ {
217
+ if (is_null($this->_mail)) {
218
+ $this->_mail = new Zend_Mail('utf-8');
219
+ }
220
+ return $this->_mail;
221
+ }
222
+
223
+
224
+ /**
225
+ * Send mail to subscriber
226
+ *
227
+ * @param Magentokey_Newsletter_Model_Subscriber|string $subscriber subscriber Model or E-mail
228
+ * @param array $variables template variables
229
+ * @param string|null $name receiver name (if subscriber model not specified)
230
+ * @param Magentokey_Newsletter_Model_Queue|null $queue queue model, used for problems reporting.
231
+ * @return boolean
232
+ * @deprecated since 1.4.0.1
233
+ **/
234
+ public function send($subscriber, array $variables = array(), $name=null, Magentokey_Newsletter_Model_Queue $queue=null)
235
+ {
236
+ if (!$this->isValidForSend()) {
237
+ return false;
238
+ }
239
+
240
+ $email = '';
241
+ if ($subscriber instanceof Magentokey_Newsletter_Model_Subscriber) {
242
+ $email = $subscriber->getSubscriberEmail();
243
+ if (is_null($name) && ($subscriber->hasCustomerFirstname() || $subscriber->hasCustomerLastname()) ) {
244
+ $name = $subscriber->getCustomerFirstname() . ' ' . $subscriber->getCustomerLastname();
245
+ }
246
+ }
247
+ else {
248
+ $email = (string) $subscriber;
249
+ }
250
+
251
+ if (Mage::getStoreConfigFlag(Mage_Core_Model_Email_Template::XML_PATH_SENDING_SET_RETURN_PATH)) {
252
+ $this->getMail()->setReturnPath($this->getTemplateSenderEmail());
253
+ }
254
+
255
+ ini_set('SMTP', Mage::getStoreConfig('system/smtp/host'));
256
+ ini_set('smtp_port', Mage::getStoreConfig('system/smtp/port'));
257
+
258
+ $mail = $this->getMail();
259
+ $mail->addTo($email, $name);
260
+ $text = $this->getProcessedTemplate($variables, true);
261
+
262
+ if ($this->isPlain()) {
263
+ $mail->setBodyText($text);
264
+ }
265
+ else {
266
+ $mail->setBodyHTML($text);
267
+ }
268
+
269
+ $mail->setSubject($this->getProcessedTemplateSubject($variables));
270
+ $mail->setFrom($this->getTemplateSenderEmail(), $this->getTemplateSenderName());
271
+
272
+ try {
273
+ $mail->send();
274
+ $this->_mail = null;
275
+ if (!is_null($queue)) {
276
+ $subscriber->received($queue);
277
+ }
278
+ }
279
+ catch (Exception $e) {
280
+ if ($subscriber instanceof Magentokey_Newsletter_Model_Subscriber) {
281
+ // If letter sent for subscriber, we create a problem report entry
282
+ $problem = Mage::getModel('magentokey_newsletter/problem');
283
+ $problem->addSubscriberData($subscriber);
284
+ if (!is_null($queue)) {
285
+ $problem->addQueueData($queue);
286
+ }
287
+ $problem->addErrorData($e);
288
+ $problem->save();
289
+
290
+ if (!is_null($queue)) {
291
+ $subscriber->received($queue);
292
+ }
293
+ } else {
294
+ // Otherwise throw error to upper level
295
+ throw $e;
296
+ }
297
+ return false;
298
+ }
299
+
300
+ return true;
301
+ }
302
+
303
+ /**
304
+ * Prepare Process (with save)
305
+ *
306
+ * @return Magentokey_Newsletter_Model_Template
307
+ */
308
+ public function preprocess()
309
+ {
310
+ $this->_preprocessFlag = true;
311
+ $this->save();
312
+ $this->_preprocessFlag = false;
313
+ return $this;
314
+ }
315
+
316
+ /**
317
+ * Retrieve processed template subject
318
+ *
319
+ * @param array $variables
320
+ * @return string
321
+ */
322
+ public function getProcessedTemplateSubject(array $variables)
323
+ {
324
+ $processor = new Varien_Filter_Template();
325
+
326
+ if (!$this->_preprocessFlag) {
327
+ $variables['this'] = $this;
328
+ }
329
+
330
+ $processor->setVariables($variables);
331
+ return $processor->filter($this->getTemplateSubject());
332
+ }
333
+
334
+ /**
335
+ * Retrieve template text wrapper
336
+ *
337
+ * @return string
338
+ */
339
+ public function getTemplateText()
340
+ {
341
+ if (!$this->getData('template_text') && !$this->getId()) {
342
+ $this->setData('template_text',
343
+ Mage::helper('magentokey_newsletter')->__('Follow this link to unsubscribe <!-- This tag is for unsubscribe link --><a href="{{var subscriber.getUnsubscriptionLink()}}">{{var subscriber.getUnsubscriptionLink()}}</a>')
344
+ );
345
+ }
346
+
347
+ return $this->getData('template_text');
348
+ }
349
+ }
app/code/community/Magentokey/Newsletter/controllers/Adminhtml/Productnewsletter/ManageController.php ADDED
@@ -0,0 +1,61 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Adminhtml_Productnewsletter_ManageController extends Mage_Adminhtml_Controller_Action
8
+ {
9
+ public function indexAction()
10
+ {
11
+ $this->_forward('addQueue');
12
+ }
13
+ public function addQueueAction()
14
+ {
15
+ $this->_isAllowed();
16
+ if ($this->getRequest()->getQuery('ajax')) {
17
+ $this->_forward('grid');
18
+ return;
19
+ }
20
+ $this->loadLayout();
21
+ $this->_setActiveMenu('magentokey_newsletter/add_new_to_queue');
22
+ $this->_title($this->__('Magentokey Newsletter'))->_title($this->__('Add Product(s) To New Products Queue'));
23
+ $this->_addContent($this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_manage', 'newsletter.product.manage'));
24
+ $this->renderLayout();
25
+ }
26
+ public function gridAction ()
27
+ {
28
+ $this->loadLayout();
29
+ $grid = $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_manage_grid')
30
+ ->toHtml();
31
+ $this->getResponse()->setBody($grid);
32
+ }
33
+ public function massAddNewsAction()
34
+ {
35
+ $this->_isAllowed();
36
+ $productIds = $this->getRequest()->getParam('product');
37
+ if (!is_array($productIds)) {
38
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('magentokey_newsletter')->__('Please select product(s)'));
39
+ } else {
40
+ try {
41
+ foreach ($productIds as $productId) {
42
+ $product = Mage::getModel('catalog/product')->load($productId);
43
+ Mage::helper('magentokey_newsletter')->checkQueueNum($product,Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_NEW);
44
+ }
45
+ Mage::getSingleton('adminhtml/session')->addSuccess(
46
+ Mage::helper('magentokey_newsletter')->__(
47
+ 'Total of %d product(s) were added to new products queue', count($productIds)
48
+ )
49
+ );
50
+ } catch (Exception $e) {
51
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
52
+ }
53
+ }
54
+
55
+ $this->_redirect('*/*/addQueue');
56
+ }
57
+ protected function _isAllowed()
58
+ {
59
+ return Mage::getSingleton('admin/session')->isAllowed('magentokey_newsletter/add_new_to_queue');
60
+ }
61
+ }
app/code/community/Magentokey/Newsletter/controllers/Adminhtml/Productnewsletter/ProblemController.php ADDED
@@ -0,0 +1,52 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Adminhtml_Productnewsletter_ProblemController extends Mage_Adminhtml_Controller_Action
8
+ {
9
+ protected function _init()
10
+ {
11
+ $this->loadLayout()->_setActiveMenu('magentokey_newsletter');
12
+ return $this;
13
+ }
14
+ public function indexAction()
15
+ {
16
+ $this->_isAllowed();
17
+ $this->loadLayout();
18
+ $this->_setActiveMenu('magentokey_newsletter/problem');
19
+ $this->_title($this->__('Magentokey Newsletter'))->_title($this->__('Magentokey Newsletter Problem Reports'));
20
+ $this->_addContent($this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_problem', 'newsletter.product.problem'));
21
+ $this->renderLayout();
22
+ }
23
+ public function massDeleteAction()
24
+ {
25
+ $this->_isAllowed();
26
+ $problemIds = $this->getRequest()->getParam('problem_id');
27
+ if (!is_array($problemIds)) {
28
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('magentokey_newsletter')->__('Please select Problem(s)'));
29
+ }
30
+ else {
31
+ try {
32
+ foreach ($problemIds as $problemId) {
33
+ $problem = Mage::getModel('magentokey_newsletter/problem')->load($problemId);
34
+ $problem->delete();
35
+ }
36
+ Mage::getSingleton('adminhtml/session')->addSuccess(
37
+ Mage::helper('adminhtml')->__(
38
+ 'Total of %d problem(s) were deleted', count($problemIds)
39
+ )
40
+ );
41
+ } catch (Exception $e) {
42
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
43
+ }
44
+ }
45
+
46
+ $this->_redirect('*/*/index');
47
+ }
48
+ protected function _isAllowed()
49
+ {
50
+ return Mage::getSingleton('admin/session')->isAllowed('magentokey_newsletter/problem');
51
+ }
52
+ }
app/code/community/Magentokey/Newsletter/controllers/Adminhtml/Productnewsletter/QueueController.php ADDED
@@ -0,0 +1,178 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Adminhtml_Productnewsletter_QueueController extends Mage_Adminhtml_Controller_Action
8
+ {
9
+ public function indexAction()
10
+ {
11
+ $this->_isAllowed();
12
+ if ($this->getRequest()->getQuery('ajax')) {
13
+ $this->_forward('grid');
14
+ return;
15
+ }
16
+ $this->loadLayout();
17
+ $this->_setActiveMenu('magentokey_newsletter/queue');
18
+ $this->_title($this->__('Magentokey Newsletter'))->_title($this->__('Magentokey Newsletter Queue'));
19
+ $this->_addContent($this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_queue', 'newsletter.product.queue'));
20
+ $this->renderLayout();
21
+ }
22
+ public function gridAction ()
23
+ {
24
+ $this->loadLayout();
25
+ $grid = $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_queue_grid')
26
+ ->toHtml();
27
+ $this->getResponse()->setBody($grid);
28
+ }
29
+
30
+ public function previewAction ()
31
+ {
32
+ $this->_isAllowed();
33
+ $this->loadLayout();
34
+
35
+ $data = $this->getRequest()->getParams();
36
+ if (empty($data) || !isset($data['id'])) {
37
+ $this->_forward('noRoute');
38
+ return $this;
39
+ }
40
+ $data['preview_store_id'] = Mage::app()->getDefaultStoreView()->getId();
41
+
42
+ $this->getLayout()->getBlock('preview_form')->setFormData($data);
43
+ $this->renderLayout();
44
+ //Zend_Debug::dump($this->getLayout()->getUpdate()->getHandles());
45
+ }
46
+ /**
47
+ * Drop Newsletter Template
48
+ *
49
+ */
50
+ public function dropAction ()
51
+ {
52
+ $this->_isAllowed();
53
+ $this->loadLayout('magentokey_newsletter_queue_preview');
54
+ $this->renderLayout();
55
+ }
56
+ public function massCancelAction()
57
+ {
58
+ $this->_isAllowed();
59
+ $queueIds = $this->getRequest()->getParam('queue');
60
+ if (!is_array($queueIds)) {
61
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('magentokey_newsletter')->__('Please select queue(s)'));
62
+ }
63
+ else {
64
+ try {
65
+ foreach ($queueIds as $queueId) {
66
+ $queue = Mage::getModel('magentokey_newsletter/queue')->load($queueId);
67
+ $queue->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_CANCEL);
68
+ $queue->save();
69
+ }
70
+ Mage::getSingleton('adminhtml/session')->addSuccess(
71
+ Mage::helper('adminhtml')->__(
72
+ 'Total of %d queue(s) were canceled', count($queueIds)
73
+ )
74
+ );
75
+ } catch (Exception $e) {
76
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
77
+ }
78
+ }
79
+
80
+ $this->_redirect('*/*/index');
81
+ }
82
+ public function massDeleteAction()
83
+ {
84
+ $this->_isAllowed();
85
+ $queueIds = $this->getRequest()->getParam('queue');
86
+ if (!is_array($queueIds)) {
87
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('magentokey_newsletter')->__('Please select queue(s)'));
88
+ }
89
+ else {
90
+ try {
91
+ foreach ($queueIds as $queueId) {
92
+ $queue = Mage::getModel('magentokey_newsletter/queue')->load($queueId);
93
+ $queue->delete();
94
+ }
95
+ Mage::getSingleton('adminhtml/session')->addSuccess(
96
+ Mage::helper('adminhtml')->__(
97
+ 'Total of %d record(s) were deleted', count($queueIds)
98
+ )
99
+ );
100
+ } catch (Exception $e) {
101
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
102
+ }
103
+ }
104
+
105
+ $this->_redirect('*/*/index');
106
+ }
107
+ public function massSendAction()
108
+ {
109
+ $this->_isAllowed();
110
+ $countOfSubscritions = 100;
111
+ $queueIds = $this->getRequest()->getParam('queue');
112
+ if (!is_array($queueIds)) {
113
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('magentokey_newsletter')->__('Please select queue(s)'));
114
+ } else {
115
+ try {
116
+ $collection = Mage::getResourceModel('magentokey_newsletter/queue_collection')
117
+ ->addOnlyForSendingFilter()
118
+ ->addFieldToFilter('queue_id', array('in'=>$queueIds))
119
+ ->load();
120
+ $collection->walk('sendPerSubscriber', array($countOfSubscritions));
121
+ Mage::getSingleton('adminhtml/session')->addSuccess(
122
+ Mage::helper('adminhtml')->__(
123
+ 'Total of %d queue(s) were Sent', count($queueIds)
124
+ )
125
+ );
126
+ } catch (Exception $e) {
127
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
128
+ }
129
+ }
130
+
131
+ $this->_redirect('*/*/index');
132
+ }
133
+
134
+ public function massPauseAction()
135
+ {
136
+ $this->_isAllowed();
137
+ $queueIds = $this->getRequest()->getParam('queue');
138
+ if (!is_array($queueIds)) {
139
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('magentokey_newsletter')->__('Please select queue(s)'));
140
+ } else {
141
+ try {
142
+ $i = 0;
143
+ foreach ($queueIds as $queueId) {
144
+ $queue = Mage::getModel('magentokey_newsletter/queue')->load($queueId);
145
+ if (in_array($queue->getQueueStatus(),array(Magentokey_Newsletter_Model_Queue::STATUS_SENDING))) {
146
+ $queue->setQueueStatus(Mage_Newsletter_Model_Queue::STATUS_PAUSE);
147
+ $queue->save();
148
+ $i ++;
149
+ }
150
+ }
151
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Total of %d record(s) were paused', $i));
152
+ } catch (Exception $e) {
153
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
154
+ }
155
+ }
156
+
157
+ $this->_redirect('*/*/index');
158
+ }
159
+ public function sendingAction()
160
+ {
161
+ $this->_isAllowed();
162
+ // Run it on cron job
163
+ // Todo: put it somewhere in config!
164
+ $countOfQueue = 3;
165
+ $countOfSubscritions = 20;
166
+
167
+ $collection = Mage::getResourceModel('magentokey_newsletter/queue_collection')
168
+ ->setPageSize($countOfQueue)
169
+ ->setCurPage(1)
170
+ ->addOnlyForSendingFilter()
171
+ ->load();
172
+ $collection->walk('sendPerSubscriber', array($countOfSubscritions));
173
+ }
174
+ protected function _isAllowed()
175
+ {
176
+ return Mage::getSingleton('admin/session')->isAllowed('magentokey_newsletter/queue');
177
+ }
178
+ }
app/code/community/Magentokey/Newsletter/controllers/Adminhtml/Productnewsletter/ReportController.php ADDED
@@ -0,0 +1,121 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Adminhtml_Productnewsletter_ReportController extends Mage_Adminhtml_Controller_Action
8
+ {
9
+ protected function _init()
10
+ {
11
+ $this->loadLayout()
12
+ ->_setActiveMenu('magentokey_newsletter');
13
+ return $this;
14
+ }
15
+ public function indexAction()
16
+ {
17
+ $this->loadLayout();
18
+ $this->_setActiveMenu('magentokey_newsletter/report');
19
+ $this->_title($this->__('Magentokey Newsletter'))->_title($this->__('Magentokey Newsletter Product Reports'));
20
+ $this->_addContent($this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_report', 'newsletter.product.report'));
21
+ $this->renderLayout();
22
+ }
23
+
24
+ public function categoryAction()
25
+ {
26
+ $this->loadLayout();
27
+ $this->_setActiveMenu('magentokey_newsletter/report');
28
+ $this->_title($this->__('Magentokey Newsletter'))->_title($this->__('Magentokey Newsletter Category Reports'));
29
+ $this->_addContent($this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_report_category', 'newsletter.product.report.category'));
30
+ $this->renderLayout();
31
+ }
32
+ public function subscriberTypeAction()
33
+ {
34
+ $this->loadLayout();
35
+ $this->_setActiveMenu('magentokey_newsletter/report');
36
+ $this->_title($this->__('Magentokey Newsletter'))->_title($this->__('Magentokey Newsletter Subscriber Type Reports'));
37
+ $this->_addContent($this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_report_type', 'newsletter.product.report.type'));
38
+ $this->renderLayout();
39
+ }
40
+ public function exportCsvAction()
41
+ {
42
+ $fileName = 'subscribers_product.csv';
43
+ $content = $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_report_grid')
44
+ ->getCsv();
45
+
46
+ $this->_prepareDownloadResponse($fileName, $content);
47
+ }
48
+ public function exportExcelAction()
49
+ {
50
+ $fileName = 'subscribers_product.xml';
51
+ $content = $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_report_grid')
52
+ ->getExcel($fileName);
53
+
54
+ $this->_prepareDownloadResponse($fileName, $content);
55
+ }
56
+
57
+ public function exportCsvCategoryAction()
58
+ {
59
+ $fileName = 'subscribers_category.csv';
60
+ $content = $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_report_category_grid')
61
+ ->getCsv();
62
+
63
+ $this->_prepareDownloadResponse($fileName, $content);
64
+ }
65
+ public function exportExcelCategoryAction()
66
+ {
67
+ $fileName = 'subscribers_category.xml';
68
+ $content = $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_report_category_grid')
69
+ ->getExcel($fileName);
70
+
71
+ $this->_prepareDownloadResponse($fileName, $content);
72
+ }
73
+
74
+ public function exportCsvTypeAction()
75
+ {
76
+ $fileName = 'subscribers_subscriber_type.csv';
77
+ $content = $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_report_type_grid')
78
+ ->getCsv();
79
+
80
+ $this->_prepareDownloadResponse($fileName, $content);
81
+ }
82
+ public function exportExcelTypeAction()
83
+ {
84
+ $fileName = 'subscribers_subscriber_type.xml';
85
+ $content = $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_report_type_grid')
86
+ ->getExcel($fileName);
87
+
88
+ $this->_prepareDownloadResponse($fileName, $content);
89
+ }
90
+ protected function _isAllowed()
91
+ {
92
+ return Mage::getSingleton('admin/session')
93
+ ->isAllowed('magentokey_newsletter/report');
94
+ }
95
+
96
+ /*
97
+ public function categoriesAction()
98
+ {
99
+ $this->loadLayout();
100
+ $this->_setActiveMenu('magentokey_newsletter/report');
101
+ $this->_addBreadcrumb(Mage::helper('magentokey_newsletter')->__('Magentokey Newsletter'), Mage::helper('magentokey_newsletter')->__('Advance Report'));
102
+ $this->_addContent($this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_report_categories', 'newsletter.product.report.categories'));
103
+ $this->renderLayout();
104
+ }
105
+ public function exportCsvCategoriesAction()
106
+ {
107
+ $fileName = 'subscribers_categories.csv';
108
+ $content = $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_report_categories')
109
+ ->getCsvFile();
110
+
111
+ $this->_prepareDownloadResponse($fileName, $content);
112
+ }
113
+ public function exportExcelCategoriesAction()
114
+ {
115
+ $fileName = 'subscribers_categories.xml';
116
+ $content = $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_report_categories')
117
+ ->getExcelFile();
118
+
119
+ $this->_prepareDownloadResponse($fileName, $content);
120
+ }*/
121
+ }
app/code/community/Magentokey/Newsletter/controllers/Adminhtml/Productnewsletter/SubscriberController.php ADDED
@@ -0,0 +1,117 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Adminhtml_Productnewsletter_SubscriberController extends Mage_Adminhtml_Controller_Action
8
+ {
9
+ public function indexAction()
10
+ {
11
+ $this->_isAllowed();
12
+ $this->loadLayout();
13
+ if ($this->getRequest()->getQuery('ajax')) {
14
+ $this->_forward('grid');
15
+ return;
16
+ }
17
+ $this->_setActiveMenu('magentokey_newsletter/subscriber');
18
+ $this->_title($this->__('Magentokey Newsletter'))->_title($this->__('Magentokey Newsletter Subscriber'));
19
+ $this->_addContent($this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_subscriber', 'newsletter.product.subscriber'));
20
+ $this->renderLayout();
21
+ }
22
+ /**
23
+ * JSON Grid Action
24
+ *
25
+ */
26
+ public function gridAction ()
27
+ {
28
+ $this->loadLayout();
29
+ $grid = $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_subscriber_grid')
30
+ ->toHtml();
31
+ $this->getResponse()->setBody($grid);
32
+ }
33
+ public function massUnsubscribeAction()
34
+ {
35
+ $this->_isAllowed();
36
+ $subscribersIds = $this->getRequest()->getParam('subscriber');
37
+ if (!is_array($subscribersIds)) {
38
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('magentokey_newsletter')->__('Please select subscriber(s)'));
39
+ }
40
+ else {
41
+ try {
42
+ foreach ($subscribersIds as $subscriberId) {
43
+ $subscriber = Mage::getModel('magentokey_newsletter/subscriber')->load($subscriberId);
44
+ $subscriber->setSubscriberStatus(Magentokey_Newsletter_Model_Subscriber::STATUS_UNSUBSCRIBED);
45
+ $subscriber->save();
46
+ }
47
+ Mage::getSingleton('adminhtml/session')->addSuccess(
48
+ Mage::helper('adminhtml')->__(
49
+ 'Total of %d record(s) were unsubscribed', count($subscribersIds)
50
+ )
51
+ );
52
+ } catch (Exception $e) {
53
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
54
+ }
55
+ }
56
+
57
+ $this->_redirect('*/*/index');
58
+ }
59
+
60
+ public function massActiveAction()
61
+ {
62
+ $this->_isAllowed();
63
+ $subscribersIds = $this->getRequest()->getParam('subscriber');
64
+ if (!is_array($subscribersIds)) {
65
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('magentokey_newsletter')->__('Please select subscriber(s)'));
66
+ }
67
+ else {
68
+ try {
69
+ foreach ($subscribersIds as $subscriberId) {
70
+ $subscriber = Mage::getModel('magentokey_newsletter/subscriber')->load($subscriberId);
71
+ $subscriber->setSubscriberStatus(Magentokey_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED);
72
+ $subscriber->save();
73
+ }
74
+ Mage::getSingleton('adminhtml/session')->addSuccess(
75
+ Mage::helper('adminhtml')->__(
76
+ 'Total of %d record(s) were Actived', count($subscribersIds)
77
+ )
78
+ );
79
+ } catch (Exception $e) {
80
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
81
+ }
82
+ }
83
+
84
+ $this->_redirect('*/*/index');
85
+ }
86
+
87
+ public function massDeleteAction()
88
+ {
89
+ $this->_isAllowed();
90
+ $subscribersIds = $this->getRequest()->getParam('subscriber');
91
+ if (!is_array($subscribersIds)) {
92
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('magentokey_newsletter')->__('Please select subscriber(s)'));
93
+ }
94
+ else {
95
+ try {
96
+ foreach ($subscribersIds as $subscriberId) {
97
+ $subscriber = Mage::getModel('magentokey_newsletter/subscriber')->load($subscriberId);
98
+ $subscriber->delete();
99
+ }
100
+ Mage::getSingleton('adminhtml/session')->addSuccess(
101
+ Mage::helper('adminhtml')->__(
102
+ 'Total of %d record(s) were deleted', count($subscribersIds)
103
+ )
104
+ );
105
+ } catch (Exception $e) {
106
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
107
+ }
108
+ }
109
+
110
+ $this->_redirect('*/*/index');
111
+ }
112
+ protected function _isAllowed()
113
+ {
114
+ return Mage::getSingleton('admin/session')
115
+ ->isAllowed('magentokey_newsletter/subscriber');
116
+ }
117
+ }
app/code/community/Magentokey/Newsletter/controllers/Adminhtml/Productnewsletter/TemplateController.php ADDED
@@ -0,0 +1,340 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_Adminhtml_Productnewsletter_TemplateController extends Mage_Adminhtml_Controller_Action
8
+ {
9
+
10
+ /**
11
+ * Check is allowed access
12
+ *
13
+ * @return bool
14
+ */
15
+ protected function _isAllowed ()
16
+ {
17
+ return Mage::getSingleton('admin/session')
18
+ ->isAllowed('magentokey_newsletter/template');
19
+ }
20
+ /**
21
+ * View Templates list
22
+ *
23
+ */
24
+ public function indexAction ()
25
+ {
26
+ $this->_isAllowed ();
27
+ $this->_title($this->__('Magentokey Newsletter'))->_title($this->__('Magentokey Newsletter Templates'));
28
+ if ($this->getRequest()->getQuery('ajax')) {
29
+ $this->_forward('grid');
30
+ }
31
+ $this->loadLayout();
32
+ $this->_setActiveMenu('magentokey_newsletter/template');
33
+ $this->_addContent($this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_template', 'newsletter.product.template'));
34
+ $this->renderLayout();
35
+ }
36
+
37
+ /**
38
+ * JSON Grid Action
39
+ *
40
+ */
41
+ public function gridAction ()
42
+ {
43
+
44
+ if ($this->getRequest()->getQuery('ajax') && $this->getRequest()->getParam('level') == 'category') {
45
+
46
+ $this->_forward('categorygrid');
47
+ return;
48
+ } elseif ($this->getRequest()->getQuery('ajax') && $this->getRequest()->getParam('level') == 'product') {
49
+ $this->_forward('productgrid');
50
+ return;
51
+ }
52
+ $this->loadLayout();
53
+ $grid = $this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_template_grid')
54
+ ->toHtml();
55
+ $this->getResponse()->setBody($grid);
56
+ }
57
+ public function categorygridAction()
58
+ {
59
+ $this->loadLayout();
60
+ $this->getResponse()->setBody($this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_template_edit_category')->toHtml());
61
+ }
62
+ public function productgridAction()
63
+ {
64
+ $this->loadLayout();
65
+ $this->getResponse()->setBody($this->getLayout()->createBlock('magentokey_newsletter/adminhtml_newsletter_template_edit_product')->toHtml());
66
+ }
67
+ /**
68
+ * Create new Newsletter Template
69
+ *
70
+ */
71
+ public function newAction ()
72
+ {
73
+ $this->_forward('edit');
74
+ }
75
+
76
+ /**
77
+ * Edit Newsletter Template
78
+ *
79
+ */
80
+ public function editAction ()
81
+ {
82
+ //$this->_isAllowed ();
83
+ if ($this->getRequest()->getQuery('ajax') && $this->getRequest()->getParam('level') == 'category') {
84
+ $this->_forward('categorygrid');
85
+ return;
86
+ } elseif ($this->getRequest()->getQuery('ajax') && $this->getRequest()->getParam('level') == 'product') {
87
+ $this->_forward('productgrid');
88
+ return;
89
+ }
90
+ $model = Mage::getModel('magentokey_newsletter/template');
91
+ if ($id = $this->getRequest()->getParam('id')) {
92
+ $model->load($id);
93
+ }
94
+
95
+ Mage::register('_current_product_template', $model);
96
+
97
+ $this->loadLayout();
98
+ $this->_setActiveMenu('magentokey_newsletter/template');
99
+
100
+ $this->_title($model->getId() ? $model->getTemplateCode() : $this->__('New Template'));
101
+
102
+ // restore data
103
+ if ($values = $this->_getSession()->getData('newsletter_template_form_data', true)) {
104
+ $model->addData($values);
105
+ }
106
+
107
+ if ($editBlock = $this->getLayout()->getBlock('product_template_edit')) {
108
+ $editBlock->setEditMode($model->getId() > 0);
109
+ }
110
+ $this->renderLayout();
111
+ }
112
+
113
+ /**
114
+ * Drop Newsletter Template
115
+ *
116
+ */
117
+ public function dropAction ()
118
+ {
119
+ $this->_isAllowed ();
120
+ $this->loadLayout('magentokey_newsletter_template_preview');
121
+ $this->renderLayout();
122
+ }
123
+
124
+ /**
125
+ * Save Newsletter Template
126
+ *
127
+ */
128
+ public function saveAction ()
129
+ {
130
+ $this->_isAllowed ();
131
+ $request = $this->getRequest();
132
+ if (!$request->isPost()) {
133
+ $this->getResponse()->setRedirect($this->getUrl('*/newsletter_template'));
134
+ }
135
+
136
+ $data = $request->getParams();
137
+ if ($data['start_at'] || $data['end_at']) {
138
+ $data = $this->_filterPostData($data);
139
+ }
140
+ try {
141
+ if ($id = (int)$request->getParam('id')) {
142
+ $template = Mage::getModel('magentokey_newsletter/template');
143
+ $template->load($id);
144
+ $template->addData($data)
145
+ ->setTemplateSubject($data['subject'])
146
+ ->setTemplateCode($data['code'])
147
+ ->setTemplateSubscriberType($data['template_subscriber_type'])
148
+ ->setStartAt($data['start_at'])
149
+ ->setEndAt($data['end_at'])
150
+ ->setTemplateSenderEmail($data['sender_email'])
151
+ ->setTemplateSenderName($data['sender_name'])
152
+ ->setTemplateText($data['text'])
153
+ ->setTemplateStyles($data['styles'])
154
+ ->setTemplatePosition((int)$data['template_position']);
155
+ if ($this->getRequest()->getParam('_change_type_flag')) {
156
+ $template->setTemplateType(Magentokey_Newsletter_Model_Template::TYPE_TEXT);
157
+ $template->setTemplateStyles('');
158
+ }
159
+ $template->save();
160
+ } else {
161
+
162
+ $level = $this->getRequest()->getParam('level');
163
+ if ($level) {
164
+ if ($level == 'category') {
165
+ $idArray = $data['category_id'];
166
+ } elseif ($level == 'product') {
167
+ $idArray = $data['product_id'];
168
+ }
169
+ if (count($idArray)) {
170
+
171
+ foreach ($idArray as $id) {
172
+ $template = Mage::getModel('magentokey_newsletter/template');
173
+ $template->setTemplateSubject($data['subject'])
174
+ ->setTemplateCode($data['code'])
175
+ ->setTemplateSubscriberType($data['template_subscriber_type'])
176
+ ->setStartAt($data['start_at'])
177
+ ->setEndAt($data['end_at'])
178
+ ->setTemplateSenderEmail($data['sender_email'])
179
+ ->setTemplateSenderName($data['sender_name'])
180
+ ->setTemplateText($data['text'])
181
+ ->setTemplateType($data['_change_type_flag']==Magentokey_Newsletter_Model_Template::TYPE_TEXT ? $data['_change_type_flag'] : Magentokey_Newsletter_Model_Template::TYPE_HTML)
182
+ ->setTemplateStyles($data['styles'])
183
+ ->setTemplatePosition((int)$data['template_position']);
184
+ if ($level == 'category') {
185
+ $template->setTemplateCategoryId($id);
186
+ } elseif ($level == 'product') {
187
+ $template->setTemplateProductId($id);
188
+ }
189
+ if ($this->getRequest()->getParam('_change_type_flag')) {
190
+ $template->setTemplateType(Magentokey_Newsletter_Model_Template::TYPE_TEXT);
191
+ $template->setTemplateStyles('');
192
+ }
193
+ $template->save();
194
+ }
195
+ } else {
196
+ if ($level == 'category') {
197
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('magentokey_newsletter')->__('Please select category(s)'));
198
+ } elseif ($level == 'product') {
199
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('magentokey_newsletter')->__('Please select product(s)'));
200
+ }
201
+
202
+ }
203
+ }
204
+ }
205
+
206
+
207
+ }
208
+ catch (Mage_Core_Exception $e) {
209
+ $this->_getSession()->addError(nl2br($e->getMessage()));
210
+ $this->_getSession()->setData('newsletter_template_form_data',
211
+ $this->getRequest()->getParams());
212
+ }
213
+ catch (Exception $e) {
214
+ $this->_getSession()->addException($e, Mage::helper('magentokey_newsletter')->__('An error occurred while saving this template.'));
215
+ $this->_getSession()->setData('newsletter_template_form_data', $this->getRequest()->getParams());
216
+ }
217
+ $this->_redirect('*/*');
218
+ }
219
+
220
+ /**
221
+ * Delete newsletter Template
222
+ *
223
+ */
224
+ public function deleteAction ()
225
+ {
226
+ $template = Mage::getModel('magentokey_newsletter/template')
227
+ ->load($this->getRequest()->getParam('id'));
228
+ if ($template->getId()) {
229
+ try {
230
+ $template->delete();
231
+ }
232
+ catch (Mage_Core_Exception $e) {
233
+ $this->_getSession()->addError($e->getMessage());
234
+ }
235
+ catch (Exception $e) {
236
+ $this->_getSession()->addException($e, Mage::helper('magentokey_newsletter')->__('An error occurred while deleting this template.'));
237
+ }
238
+ }
239
+ $this->_redirect('*/*');
240
+ }
241
+
242
+ /**
243
+ * Preview Newsletter template
244
+ *
245
+ */
246
+ public function previewAction ()
247
+ {
248
+ $this->loadLayout();
249
+
250
+ $data = $this->getRequest()->getParams();
251
+ if (empty($data) || !isset($data['id'])) {
252
+ $this->_forward('noRoute');
253
+ return $this;
254
+ }
255
+ // set default value for selected store
256
+ $data['preview_store_id'] = Mage::app()->getDefaultStoreView()->getId();
257
+
258
+ $this->getLayout()->getBlock('preview_form')->setFormData($data);
259
+ $this->renderLayout();
260
+ }
261
+ public function massEnableAction()
262
+ {
263
+ $templateIds = $this->getRequest()->getParam('template');
264
+ if (!is_array($templateIds)) {
265
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('magentokey_newsletter')->__('Please select template(s)'));
266
+ }
267
+ else {
268
+ try {
269
+ foreach ($templateIds as $templateId) {
270
+ $template = Mage::getModel('magentokey_newsletter/template')->load($templateId);
271
+ $template->setTemplateStatus(Magentokey_Newsletter_Model_Template::STATUS_ENABLE);
272
+ $template->save();
273
+ }
274
+ Mage::getSingleton('adminhtml/session')->addSuccess(
275
+ Mage::helper('adminhtml')->__(
276
+ 'Total of %d record(s) were updated', count($templateId)
277
+ )
278
+ );
279
+ } catch (Exception $e) {
280
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
281
+ }
282
+ }
283
+
284
+ $this->_redirect('*/*/index');
285
+ }
286
+ public function massDisableAction()
287
+ {
288
+ $templateIds = $this->getRequest()->getParam('template');
289
+ if (!is_array($templateIds)) {
290
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('magentokey_newsletter')->__('Please select template(s)'));
291
+ }
292
+ else {
293
+ try {
294
+ foreach ($templateIds as $templateId) {
295
+ $template = Mage::getModel('magentokey_newsletter/template')->load($templateId);
296
+ $template->setTemplateStatus(Magentokey_Newsletter_Model_Template::STATUS_DISABLE);
297
+ $template->save();
298
+ }
299
+ Mage::getSingleton('adminhtml/session')->addSuccess(
300
+ Mage::helper('adminhtml')->__(
301
+ 'Total of %d record(s) were updated', count($templateId)
302
+ )
303
+ );
304
+ } catch (Exception $e) {
305
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
306
+ }
307
+ }
308
+
309
+ $this->_redirect('*/*/index');
310
+ }
311
+ public function massDeleteAction()
312
+ {
313
+ $templateIds = $this->getRequest()->getParam('template');
314
+ if (!is_array($templateIds)) {
315
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('magentokey_newsletter')->__('Please select template(s)'));
316
+ }
317
+ else {
318
+ try {
319
+ foreach ($templateIds as $templateId) {
320
+ $template = Mage::getModel('magentokey_newsletter/template')->load($templateId);
321
+ $template->delete();
322
+ }
323
+ Mage::getSingleton('adminhtml/session')->addSuccess(
324
+ Mage::helper('adminhtml')->__(
325
+ 'Total of %d record(s) were deleted', count($templateIds)
326
+ )
327
+ );
328
+ } catch (Exception $e) {
329
+ Mage::getSingleton('adminhtml/session')->addError($e->getMessage());
330
+ }
331
+ }
332
+
333
+ $this->_redirect('*/*/index');
334
+ }
335
+ protected function _filterPostData($data)
336
+ {
337
+ $data = $this->_filterDates($data, array('start_at', 'end_at'));
338
+ return $data;
339
+ }
340
+ }
app/code/community/Magentokey/Newsletter/controllers/SubscribeController.php ADDED
@@ -0,0 +1,202 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ class Magentokey_Newsletter_SubscribeController extends Mage_Core_Controller_Front_Action
8
+ {
9
+
10
+ protected function _getSession()
11
+ {
12
+ return Mage::getSingleton('core/session');
13
+ }
14
+ public function indexAction()
15
+ {
16
+ $this->loadLayout();
17
+ $type = $this->getRequest()->getParam('type');
18
+ $title = Mage::helper('magentokey_newsletter')->getTitleByType($type);
19
+ if (Mage::helper('magentokey_newsletter')->isProduct($type)) {
20
+ $model = Mage::getSingleton('catalog/product')->load((int)$this->getRequest()->getParam('id'));
21
+ }
22
+ if (Mage::helper('magentokey_newsletter')->isCategory($type)) {
23
+ $model = Mage::getSingleton('catalog/category')->load((int)$this->getRequest()->getParam('id'));
24
+ }
25
+ $this->getLayout()->getBlock('root')->setTitle($title.(is_object($model) ? Mage::helper('magentokey_newsletter')->__(' of ').$model->getName() : ''));
26
+ $this->renderLayout();
27
+ }
28
+ public function addAction()
29
+ {
30
+ $this->loadLayout();
31
+ $this->renderLayout();
32
+ }
33
+
34
+ public function amountAction()
35
+ {
36
+ $this->loadLayout();
37
+ $data = $this->getRequest()->getParams();
38
+ $flag = false;
39
+ if (isset($data['type'])) {
40
+ $type = $data['type'];
41
+ if ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION) {
42
+ if (Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_PRODUCT_PRICE_REDUCTION_AMOUNT)) {
43
+ $flag = true;
44
+ }
45
+ } elseif ($type == Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE) {
46
+ if (Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_PRODUCT_STOCK_AVAILABLE_AMOUNT)) {
47
+ $flag = true;;
48
+ }
49
+ }
50
+ }
51
+ $this->getResponse()->setBody($flag);
52
+ }
53
+ public function saveAction()
54
+ {
55
+ $this->loadLayout();
56
+ $data = $this->getRequest()->getParam('newsletter');
57
+ $data = $this->_filterPostData($data);
58
+ $ajax = isset($data['ajax']) ? $data['ajax'] : NULL;
59
+ $email = (string)$data['email'];
60
+ $customerId = isset($data['customer_id']) && $data['customer_id'] ? (int)$data['customer_id'] : 0;
61
+ $categoryId = isset($data['category_id']) && $data['category_id'] ? (int)$data['category_id'] : 0;
62
+ $productId = isset($data['product_id']) && $data['product_id'] ? (int)$data['product_id'] : 0;
63
+ $productType = $productId ? Mage::getSingleton('catalog/product')->load($productId)->getTypeId() : NULL;
64
+ $typeValid = array(Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE,
65
+ Magentokey_Newsletter_Model_Subscriber::TYPE_PRICE_REDUCTION,
66
+ Magentokey_Newsletter_Model_Subscriber::TYPE_STOCK_AVAILABLE,
67
+ Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_NEW,
68
+ Magentokey_Newsletter_Model_Subscriber::TYPE_CATEGORY_PRICE);
69
+ $type = in_array((int)$data['type'], $typeValid) ? (int)$data['type'] : Magentokey_Newsletter_Model_Subscriber::TYPE_UPDATE;
70
+ $amount = isset($data['amount']) ? (int)$data['amount'] : NULL;
71
+ $storeId = Mage::app()->getStore()->getId();
72
+ $from = isset($data['date_from']) ? (string)$data['date_from'] : NULL;
73
+ $to = isset($data['date_to']) ? (string)$data['date_to'] : NULL;
74
+ $duction = isset($data['duration']) ? (int)$data['duration'] : NULL;
75
+ $msg = '';
76
+ $error = false;
77
+ $customerSession = Mage::getSingleton('customer/session');
78
+ if (Mage::getStoreConfig(Magentokey_Newsletter_Model_Subscriber::XML_PATH_ALLOW_GUEST_SUBSCRIBE_FLAG) != 1 && !$customerSession->isLoggedIn())
79
+ {
80
+ $msg = Mage::helper('magentokey_newsletter')->__('Sorry, but administrator denied subscription for guests. Please <a href="%s">register</a>.', Mage::helper('customer')->getRegisterUrl());
81
+ $error = true;
82
+ } else {
83
+ if(Zend_Validate::is($email, 'EmailAddress')) {
84
+ $subscriber = Mage::getModel('magentokey_newsletter/subscriber');
85
+ $emailAvailable = $subscriber->isEmailAvailable($email);
86
+ if ($emailAvailable) {
87
+ $flag = $subscriber->isSubscribed($email, $categoryId, $productId, $type, $storeId, $customerId);
88
+ if ($duction) {
89
+ $from = Mage::helper('magentokey_newsletter')->getCurrentDate();
90
+ $to = Mage::helper('magentokey_newsletter')->getDefaultDuration($duction);
91
+ } else {
92
+ $from = $from>=Mage::helper('magentokey_newsletter')->getCurrentDate() ? $from : Mage::helper('magentokey_newsletter')->getCurrentDate();
93
+ $to = $to>$from ? $to : Mage::helper('magentokey_newsletter')->getPageDateDefault();
94
+ }
95
+ if ($flag) {
96
+ $subscriber = $flag;
97
+ $subscriber->updateSubscriber($amount, $from, $to);
98
+ $msg = Mage::helper('magentokey_newsletter')->__('You subscription has already been updated.');
99
+ $error = false;
100
+ } else {
101
+ $status = $subscriber->subscribe($email,$customerId,$categoryId,$productId,$productType,$type,$amount,$storeId,$from,$to);
102
+
103
+ if ($status == Magentokey_Newsletter_Model_Subscriber::STATUS_UNCONFIRMED) {
104
+ $msg = Mage::helper('magentokey_newsletter')->__('Confirmation request has been sent.');
105
+ $error = false;
106
+ } elseif ($status == Magentokey_Newsletter_Model_Subscriber::STATUS_SUBSCRIBED) {
107
+ $msg = Mage::helper('magentokey_newsletter')->__('Thank you for your subscription.');
108
+ $error = false;
109
+ } else {
110
+ $msg = Mage::helper('magentokey_newsletter')->__('There was a problem with the subscription.');
111
+ $error = true;
112
+ }
113
+ }
114
+ } else {
115
+ $msg = Mage::helper('magentokey_newsletter')->__('This email address is already assigned to another user.');
116
+ $error = true;
117
+ }
118
+
119
+ } else {
120
+ $msg = Mage::helper('magentokey_newsletter')->__('Please enter a valid email address.');
121
+ $error = true;
122
+ }
123
+ }
124
+
125
+ if (!$error) {
126
+ $msg = "<span class='n-success'>".$msg."</span>";
127
+ } else {
128
+ $msg = "<span class='n-error'>".$msg."</span>";
129
+ }
130
+ $json = array('success'=>!$error, 'content'=>$msg);
131
+ $this->getResponse()->setBody(json_encode($json));
132
+ }
133
+ /**
134
+ * Subscription confirm action
135
+ */
136
+ public function confirmAction()
137
+ {
138
+ $id = (int) $this->getRequest()->getParam('id');
139
+ $code = (string) $this->getRequest()->getParam('code');
140
+ $url = Mage::getBaseUrl();
141
+ if ($id && $code) {
142
+ $subscriber = Mage::getModel('magentokey_newsletter/subscriber')->load($id);
143
+ $session = Mage::getSingleton('core/session');
144
+
145
+ if($subscriber->getId() && $subscriber->getCode()) {
146
+ if($subscriber->confirm($code)) {
147
+ $session->addSuccess($this->__('Your subscription has been confirmed.'));
148
+ if($productId = $subscriber->getProductId()) {
149
+ $url = Mage::getModel('catalog/product')->load($productId)->getProductUrl();
150
+ } elseif ($categoryId = $subscriber->getCategoryId()) {
151
+ $category = Mage::getModel('catalog/category')->load($categoryId);
152
+ $url = Mage::getBlockSingleton('catalog/navigation')->getCategoryUrl($category);
153
+ }
154
+ } else {
155
+ $session->addError($this->__('Invalid subscription confirmation code.'));
156
+ }
157
+ } else {
158
+ $session->addError($this->__('Invalid subscription ID.'));
159
+ }
160
+ }
161
+
162
+ $this->_redirectUrl($url);
163
+ }
164
+
165
+ /**
166
+ * Unsubscribe newsletter
167
+ */
168
+ public function unsubscribeAction()
169
+ {
170
+ $id = (int) $this->getRequest()->getParam('id');
171
+ $code = (string) $this->getRequest()->getParam('code');
172
+ $url = Mage::getBaseUrl();
173
+ if ($id && $code) {
174
+ $session = Mage::getSingleton('core/session');
175
+ try {
176
+
177
+ $subscriber = Mage::getModel('magentokey_newsletter/subscriber')->load($id);
178
+ $subscriber->setCheckCode($code)
179
+ ->unsubscribe();
180
+ $session->addSuccess($this->__('You have been unsubscribed.'));
181
+ if($productId = $subscriber->getProductId()) {
182
+ $url = Mage::getModel('catalog/product')->load($productId)->getProductUrl();
183
+ } elseif ($categoryId = $subscriber->getCategoryId()) {
184
+ $category = Mage::getModel('catalog/category')->load($categoryId);
185
+ $url = Mage::getBlockSingleton('catalog/navigation')->getCategoryUrl($category);
186
+ }
187
+ }
188
+ catch (Mage_Core_Exception $e) {
189
+ $session->addException($e, $e->getMessage());
190
+ }
191
+ catch (Exception $e) {
192
+ $session->addException($e, $this->__('There was a problem with the un-subscription.'));
193
+ }
194
+ }
195
+ $this->_redirectUrl($url);
196
+ }
197
+ protected function _filterPostData($data)
198
+ {
199
+ $data = $this->_filterDates($data, array('date_from', 'date_to'));
200
+ return $data;
201
+ }
202
+ }
app/code/community/Magentokey/Newsletter/etc/adminhtml.xml ADDED
@@ -0,0 +1,108 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
5
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentkey.com, http://www.hifasion.org)
6
+ * @version 1.0.0
7
+ */
8
+ -->
9
+ <config>
10
+ <menu>
11
+ <magentokey_newsletter>
12
+ <title>Magentokey Newsletter</title>
13
+ <sort_order>59</sort_order>
14
+ <children>
15
+ <queue translate="title" module="magentokey_newsletter">
16
+ <title>Magentokey Newsletter Queue</title>
17
+ <action>adminhtml/productnewsletter_queue/index</action>
18
+ <sort_order>1</sort_order>
19
+ </queue>
20
+ <add_new_to_queue translate="title" module="magentokey_newsletter">
21
+ <title>Add Product(s) To New Product(s) Queue</title>
22
+ <action>adminhtml/productnewsletter_manage/addQueue</action>
23
+ <sort_order>5</sort_order>
24
+ </add_new_to_queue>
25
+ <template translate="title" module="magentokey_newsletter">
26
+ <title>Magentokey Newsletter Templates</title>
27
+ <action>adminhtml/productnewsletter_template/index</action>
28
+ <sort_order>10</sort_order>
29
+ </template>
30
+ <subscriber translate="title" module="magentokey_newsletter">
31
+ <title>Magentokey Newsletter Subscriber</title>
32
+ <action>adminhtml/productnewsletter_subscriber/index</action>
33
+ <sort_order>20</sort_order>
34
+ </subscriber>
35
+ <problem translate="title" module="magentokey_newsletter">
36
+ <title>Magentokey Newsletter Problem Reports</title>
37
+ <action>adminhtml/productnewsletter_problem/index</action>
38
+ <sort_order>30</sort_order>
39
+ </problem>
40
+ <report translate="title" module="magentokey_newsletter">
41
+ <title>Magentokey Newsletter Reports</title>
42
+ <!--<action>adminhtml/productnewsletter_report/index</action>-->
43
+ <sort_order>40</sort_order>
44
+ <children>
45
+ <product translate="title" module="magentokey_newsletter">
46
+ <title>Magentokey Newsletter Product Reports</title>
47
+ <action>adminhtml/productnewsletter_report/index</action>
48
+ <sort_order>5</sort_order>
49
+ </product>
50
+ <category translate="title" module="magentokey_newsletter">
51
+ <title>Magentokey Newsletter Category Reports</title>
52
+ <action>adminhtml/productnewsletter_report/category</action>
53
+ <sort_order>10</sort_order>
54
+ </category>
55
+ <subscriber_type translate="title" module="magentokey_newsletter">
56
+ <title>Magentokey Newsletter Subscriber Type Reports</title>
57
+ <action>adminhtml/productnewsletter_report/subscriberType</action>
58
+ <sort_order>20</sort_order>
59
+ </subscriber_type>
60
+ </children>
61
+ </report>
62
+
63
+ </children>
64
+ </magentokey_newsletter>
65
+ </menu>
66
+ <acl>
67
+ <resources>
68
+ <admin>
69
+ <children>
70
+ <magentokey_newsletter translate="title">
71
+ <title>Magentokey Newsletter</title>
72
+ <children>
73
+ <queue translate="title">
74
+ <title>Magentokey Newsletter Queue</title>
75
+ </queue>
76
+ <add_new_to_queue translate="title">
77
+ <title>Add Product(s) To New Product(s) Queue</title>
78
+ </add_new_to_queue>
79
+ <template translate="title">
80
+ <title>Magentokey Newsletter Templates</title>
81
+ </template>
82
+ <subscriber translate="title">
83
+ <title>Magentokey Newsletter Subscriber</title>
84
+ </subscriber>
85
+ <problem translate="title">
86
+ <title>Magentokey Newsletter Problem Reports</title>
87
+ </problem>
88
+ <report translate="title">
89
+ <title>Magentokey Newsletter Subscriber</title>
90
+ <children>
91
+ <product translate="title">
92
+ <title>Magentokey Newsletter Product Reports</title>
93
+ </product>
94
+ <category translate="title">
95
+ <title>Magentokey Newsletter Product Reports</title>
96
+ </category>
97
+ <subscriber_type translate="title">
98
+ <title>Magentokey Newsletter Subscriber Type Reports</title>
99
+ </subscriber_type>
100
+ </children>
101
+ </report>
102
+ </children>
103
+ </magentokey_newsletter>
104
+ </children>
105
+ </admin>
106
+ </resources>
107
+ </acl>
108
+ </config>
app/code/community/Magentokey/Newsletter/etc/config.xml ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
5
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
6
+ * @version 1.1.0
7
+ */
8
+ -->
9
+ <config>
10
+ <modules>
11
+ <Magentokey_Newsletter>
12
+ <version>1.1.0</version>
13
+ </Magentokey_Newsletter>
14
+ </modules>
15
+ <global>
16
+ <blocks>
17
+ <magentokey_newsletter>
18
+ <class>Magentokey_Newsletter_Block</class>
19
+ </magentokey_newsletter>
20
+ </blocks>
21
+ <helpers>
22
+ <magentokey_newsletter>
23
+ <class>Magentokey_Newsletter_Helper</class>
24
+ </magentokey_newsletter>
25
+ </helpers>
26
+ <models>
27
+ <magentokey_newsletter>
28
+ <class>Magentokey_Newsletter_Model</class>
29
+ <resourceModel>magentokey_newsletter_mysql4</resourceModel>
30
+ </magentokey_newsletter>
31
+ <magentokey_newsletter_mysql4>
32
+ <class>Magentokey_Newsletter_Model_Mysql4</class>
33
+ <entities>
34
+ <subscriber>
35
+ <table>newsletter_product_subscriber</table>
36
+ </subscriber>
37
+ <queue>
38
+ <table>newsletter_product_queue</table>
39
+ </queue>
40
+ <queue_link>
41
+ <table>newsletter_product_queue_link</table>
42
+ </queue_link>
43
+ <queue_store_link>
44
+ <table>newsletter_product_queue_store_link</table>
45
+ </queue_store_link>
46
+ <template>
47
+ <table>newsletter_product_template</table>
48
+ </template>
49
+ <problem>
50
+ <table>newsletter_product_problem</table>
51
+ </problem>
52
+ </entities>
53
+ </magentokey_newsletter_mysql4>
54
+ </models>
55
+ <resources>
56
+ <magentokey_newsletter_setup>
57
+ <setup>
58
+ <module>Magentokey_Newsletter</module>
59
+ </setup>
60
+ </magentokey_newsletter_setup>
61
+ </resources>
62
+ <template>
63
+ <email>
64
+ <magentokey_newsletter_subscription_confirm_email_template translate="label" module="magentokey_newsletter">
65
+ <label>Newsletter subscription confirmation</label>
66
+ <file>magentokey_newsletter_subscr_confirm.html</file>
67
+ <type>html</type>
68
+ </magentokey_newsletter_subscription_confirm_email_template>
69
+ <magentokey_newsletter_subscription_success_email_template translate="label" module="magentokey_newsletter">
70
+ <label>Newsletter subscription success</label>
71
+ <file>magentokey_newsletter_subscr_success.html</file>
72
+ <type>html</type>
73
+ </magentokey_newsletter_subscription_success_email_template>
74
+ <magentokey_newsletter_subscription_un_email_template translate="label" module="magentokey_newsletter">
75
+ <label>Newsletter unsubscription success</label>
76
+ <file>magentokey_newsletter_unsub_success.html</file>
77
+ <type>html</type>
78
+ </magentokey_newsletter_subscription_un_email_template>
79
+ </email>
80
+ </template>
81
+ </global>
82
+ <frontend>
83
+ <routers>
84
+ <magentokey_newsletter module="Magentokey_Newsletter">
85
+ <use>standard</use>
86
+ <args>
87
+ <module>Magentokey_Newsletter</module>
88
+ <frontName>newsletters</frontName>
89
+ </args>
90
+ </magentokey_newsletter>
91
+ </routers>
92
+ <translate>
93
+ <modules>
94
+ <magentokey_newsletter>
95
+ <files>
96
+ <default>Magentokey_Newsletter.csv</default>
97
+ </files>
98
+ </magentokey_newsletter>
99
+ </modules>
100
+ </translate>
101
+ <layout>
102
+ <updates>
103
+ <magentokey_newsletter>
104
+ <file>magentokey_newsletter.xml</file>
105
+ </magentokey_newsletter>
106
+ </updates>
107
+ </layout>
108
+ </frontend>
109
+ <admin>
110
+ <routers>
111
+ <adminhtml>
112
+ <args>
113
+ <modules>
114
+ <Magentokey_Newsletter before="Mage_Adminhtml">Magentokey_Newsletter_Adminhtml</Magentokey_Newsletter>
115
+ </modules>
116
+ </args>
117
+ </adminhtml>
118
+ </routers>
119
+ </admin>
120
+ <adminhtml>
121
+ <translate>
122
+ <modules>
123
+ <magentokey_newsletter>
124
+ <files>
125
+ <default>Magentokey_Newsletter.csv</default>
126
+ </files>
127
+ </magentokey_newsletter>
128
+ </modules>
129
+ </translate>
130
+ <events>
131
+ <catalog_product_prepare_save>
132
+ <observers>
133
+ <magentokey_newsletter_subscribe_observer>
134
+ <class>magentokey_newsletter/observer</class>
135
+ <method>productUpdate</method>
136
+ </magentokey_newsletter_subscribe_observer>
137
+ </observers>
138
+ </catalog_product_prepare_save>
139
+ <sales_order_item_cancel>
140
+ <observers>
141
+ <inventory>
142
+ <class>magentokey_newsletter/observer</class>
143
+ <method>cancelOrderItem</method>
144
+ </inventory>
145
+ </observers>
146
+ </sales_order_item_cancel>
147
+ <!--return creditmemo items qty to stock-->
148
+ <sales_order_creditmemo_save_after>
149
+ <observers>
150
+ <magentokey_newsletter_subscribe_observer>
151
+ <class>magentokey_newsletter/observer</class>
152
+ <method>refundOrderInventory</method>
153
+ </magentokey_newsletter_subscribe_observer>
154
+ </observers>
155
+ </sales_order_creditmemo_save_after>
156
+ </events>
157
+ <layout>
158
+ <updates>
159
+ <magentokey_newsletter>
160
+ <file>magentokey_newsletter.xml</file>
161
+ </magentokey_newsletter>
162
+ </updates>
163
+ </layout>
164
+
165
+ <acl>
166
+ <resources>
167
+ <admin>
168
+ <children>
169
+ <system>
170
+ <children>
171
+ <config>
172
+ <children>
173
+ <magentokey_newsletter>
174
+ <title>Magentokey Newsletter</title>
175
+ </magentokey_newsletter>
176
+ </children>
177
+ </config>
178
+ </children>
179
+ </system>
180
+ </children>
181
+ </admin>
182
+ </resources>
183
+ </acl>
184
+ </adminhtml>
185
+ <crontab>
186
+ <jobs>
187
+ <magentokey_newsletter_send_all>
188
+ <schedule>
189
+ <cron_expr>*/5 * * * *</cron_expr>
190
+ </schedule>
191
+ <run>
192
+ <model>magentokey_newsletter/observer::scheduledSend</model>
193
+ </run>
194
+ </magentokey_newsletter_send_all>
195
+ </jobs>
196
+ </crontab>
197
+ </config>
app/code/community/Magentokey/Newsletter/etc/system.xml ADDED
@@ -0,0 +1,466 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
5
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
6
+ * @version 1.0.0
7
+ */
8
+ -->
9
+ <config>
10
+ <sections>
11
+ <magentokey_newsletter translate="label" module="magentokey_newsletter">
12
+ <label>Magentokey Newsletter</label>
13
+ <tab>catalog</tab>
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
+ <groups>
20
+ <backend translate="label">
21
+ <label>Admin Options</label>
22
+ <frontend_type>text</frontend_type>
23
+ <sort_order>1</sort_order>
24
+ <show_in_default>1</show_in_default>
25
+ <show_in_website>1</show_in_website>
26
+ <show_in_store>1</show_in_store>
27
+ <fields>
28
+ <enable translate="label">
29
+ <label>Enable Magentokey Newsletter</label>
30
+ <frontend_type>select</frontend_type>
31
+ <source_model>adminhtml/system_config_source_yesno</source_model>
32
+ <sort_order>1</sort_order>
33
+ <show_in_default>1</show_in_default>
34
+ <show_in_website>1</show_in_website>
35
+ <show_in_store>1</show_in_store>
36
+ </enable>
37
+ <enable_update translate="label">
38
+ <label>Enable Product Update Newsletter</label>
39
+ <frontend_type>select</frontend_type>
40
+ <source_model>adminhtml/system_config_source_yesno</source_model>
41
+ <sort_order>10</sort_order>
42
+ <show_in_default>1</show_in_default>
43
+ <show_in_website>1</show_in_website>
44
+ <show_in_store>1</show_in_store>
45
+ </enable_update>
46
+ <enable_price translate="label">
47
+ <label>Enable Price Reduction Newsletter</label>
48
+ <frontend_type>select</frontend_type>
49
+ <source_model>adminhtml/system_config_source_yesno</source_model>
50
+ <sort_order>20</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
+ </enable_price>
55
+ <enable_stock translate="label">
56
+ <label>Enable Stock Available Newsletter</label>
57
+ <frontend_type>select</frontend_type>
58
+ <source_model>adminhtml/system_config_source_yesno</source_model>
59
+ <sort_order>30</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ </enable_stock>
64
+ <order_cancel translate="label">
65
+ <label>Set Items' Status to be In Stock When Order is Cancelled</label>
66
+ <frontend_type>select</frontend_type>
67
+ <source_model>adminhtml/system_config_source_yesno</source_model>
68
+ <sort_order>32</sort_order>
69
+ <show_in_default>1</show_in_default>
70
+ <show_in_website>1</show_in_website>
71
+ <show_in_store>1</show_in_store>
72
+ </order_cancel>
73
+ </fields>
74
+ </backend>
75
+ <subscription translate="label">
76
+ <label>Subscription Options</label>
77
+ <frontend_type>text</frontend_type>
78
+ <sort_order>1</sort_order>
79
+ <show_in_default>1</show_in_default>
80
+ <show_in_website>1</show_in_website>
81
+ <show_in_store>1</show_in_store>
82
+ <fields>
83
+ <allow_guest_subscribe translate="label">
84
+ <label>Allow Guest Subscription</label>
85
+ <frontend_type>select</frontend_type>
86
+ <source_model>adminhtml/system_config_source_yesno</source_model>
87
+ <sort_order>1</sort_order>
88
+ <show_in_default>1</show_in_default>
89
+ <show_in_website>1</show_in_website>
90
+ <show_in_store>1</show_in_store>
91
+ </allow_guest_subscribe>
92
+ <confirm translate="label">
93
+ <label>Need to Confirm</label>
94
+ <frontend_type>select</frontend_type>
95
+ <source_model>adminhtml/system_config_source_yesno</source_model>
96
+ <sort_order>1</sort_order>
97
+ <show_in_default>1</show_in_default>
98
+ <show_in_website>1</show_in_website>
99
+ <show_in_store>1</show_in_store>
100
+ </confirm>
101
+ <confirm_email_identity translate="label">
102
+ <label>Confirmation Email Sender</label>
103
+ <frontend_type>select</frontend_type>
104
+ <source_model>adminhtml/system_config_source_email_identity</source_model>
105
+ <sort_order>1</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>1</show_in_store>
109
+ </confirm_email_identity>
110
+ <confirm_email_template translate="label">
111
+ <label>Confirmation Email Template</label>
112
+ <frontend_type>select</frontend_type>
113
+ <source_model>adminhtml/system_config_source_email_template</source_model>
114
+ <sort_order>1</sort_order>
115
+ <show_in_default>1</show_in_default>
116
+ <show_in_website>1</show_in_website>
117
+ <show_in_store>1</show_in_store>
118
+ </confirm_email_template>
119
+ <success_email_identity translate="label">
120
+ <label>Success Email Sender</label>
121
+ <frontend_type>select</frontend_type>
122
+ <source_model>adminhtml/system_config_source_email_identity</source_model>
123
+ <sort_order>1</sort_order>
124
+ <show_in_default>1</show_in_default>
125
+ <show_in_website>1</show_in_website>
126
+ <show_in_store>1</show_in_store>
127
+ </success_email_identity>
128
+ <success_email_template translate="label">
129
+ <label>Success Email Template</label>
130
+ <frontend_type>select</frontend_type>
131
+ <source_model>adminhtml/system_config_source_email_template</source_model>
132
+ <sort_order>1</sort_order>
133
+ <show_in_default>1</show_in_default>
134
+ <show_in_website>1</show_in_website>
135
+ <show_in_store>1</show_in_store>
136
+ </success_email_template>
137
+ <un_email_identity translate="label">
138
+ <label>Unsubscription Email Sender</label>
139
+ <frontend_type>select</frontend_type>
140
+ <source_model>adminhtml/system_config_source_email_identity</source_model>
141
+ <sort_order>1</sort_order>
142
+ <show_in_default>1</show_in_default>
143
+ <show_in_website>1</show_in_website>
144
+ <show_in_store>1</show_in_store>
145
+ </un_email_identity>
146
+ <un_email_template translate="label">
147
+ <label>Unsubscription Email Template</label>
148
+ <frontend_type>select</frontend_type>
149
+ <source_model>adminhtml/system_config_source_email_template</source_model>
150
+ <sort_order>1</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
+ </un_email_template>
155
+ </fields>
156
+ </subscription>
157
+ <product_type translate="label">
158
+ <label>Allowed Product Types</label>
159
+ <frontend_type>text</frontend_type>
160
+ <sort_order>2</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
+ <fields>
165
+ <simple_enable translate="label">
166
+ <label>Enable Simple Product</label>
167
+ <frontend_type>select</frontend_type>
168
+ <source_model>adminhtml/system_config_source_yesno</source_model>
169
+ <sort_order>1</sort_order>
170
+ <show_in_default>1</show_in_default>
171
+ <show_in_website>1</show_in_website>
172
+ <show_in_store>1</show_in_store>
173
+ </simple_enable>
174
+ <configurable_enable translate="label">
175
+ <label>Enable Configurable Product</label>
176
+ <frontend_type>select</frontend_type>
177
+ <source_model>adminhtml/system_config_source_yesno</source_model>
178
+ <sort_order>1</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
+ </configurable_enable>
183
+ <virtual_enable translate="label">
184
+ <label>Enable Virtual Product</label>
185
+ <frontend_type>select</frontend_type>
186
+ <source_model>adminhtml/system_config_source_yesno</source_model>
187
+ <sort_order>1</sort_order>
188
+ <show_in_default>1</show_in_default>
189
+ <show_in_website>1</show_in_website>
190
+ <show_in_store>1</show_in_store>
191
+ </virtual_enable>
192
+ </fields>
193
+ </product_type>
194
+ <date translate="label">
195
+ <label>Date Options</label>
196
+ <frontend_type>text</frontend_type>
197
+ <sort_order>2</sort_order>
198
+ <show_in_default>1</show_in_default>
199
+ <show_in_website>1</show_in_website>
200
+ <show_in_store>1</show_in_store>
201
+ <fields>
202
+ <duration_enable translate="label">
203
+ <label>Enable Subscription Date(use in popup)</label>
204
+ <frontend_type>select</frontend_type>
205
+ <source_model>adminhtml/system_config_source_yesno</source_model>
206
+ <sort_order>100</sort_order>
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
+ </duration_enable>
211
+ <duration_day translate="label">
212
+ <label>Subscription Default Days(use in popup)</label>
213
+ <frontend_type>text</frontend_type>
214
+ <sort_order>110</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
+ </duration_day>
219
+ <date_enable translate="label">
220
+ <label>Enlable Subscription Date(use in new page)</label>
221
+ <frontend_type>select</frontend_type>
222
+ <source_model>adminhtml/system_config_source_yesno</source_model>
223
+ <sort_order>114</sort_order>
224
+ <show_in_default>1</show_in_default>
225
+ <show_in_website>1</show_in_website>
226
+ <show_in_store>1</show_in_store>
227
+ </date_enable>
228
+ <date_default translate="label">
229
+ <label>Subscription Default End Date(use in new page)</label>
230
+ <frontend_type>text</frontend_type>
231
+ <sort_order>117</sort_order>
232
+ <show_in_default>1</show_in_default>
233
+ <show_in_website>1</show_in_website>
234
+ <show_in_store>1</show_in_store>
235
+ </date_default>
236
+ <timeout_enable translate="label">
237
+ <label>Enable Newsletter When Beyond Subscription Date</label>
238
+ <frontend_type>select</frontend_type>
239
+ <source_model>adminhtml/system_config_source_yesno</source_model>
240
+ <sort_order>120</sort_order>
241
+ <show_in_default>1</show_in_default>
242
+ <show_in_website>1</show_in_website>
243
+ <show_in_store>1</show_in_store>
244
+ </timeout_enable>
245
+ <timeout_day translate="label">
246
+ <label>Default Days When Beyond Subscription Date</label>
247
+ <frontend_type>text</frontend_type>
248
+ <sort_order>130</sort_order>
249
+ <show_in_default>1</show_in_default>
250
+ <show_in_website>1</show_in_website>
251
+ <show_in_store>1</show_in_store>
252
+ </timeout_day>
253
+ </fields>
254
+ </date>
255
+ <product translate="label">
256
+ <label>Product Options</label>
257
+ <frontend_type>text</frontend_type>
258
+ <sort_order>3</sort_order>
259
+ <show_in_default>1</show_in_default>
260
+ <show_in_website>1</show_in_website>
261
+ <show_in_store>1</show_in_store>
262
+ <fields>
263
+ <enable translate="label">
264
+ <label>Enable Product Subscription</label>
265
+ <frontend_type>select</frontend_type>
266
+ <source_model>adminhtml/system_config_source_yesno</source_model>
267
+ <sort_order>1</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
+ </enable>
272
+ <popup translate="label">
273
+ <label>Enable Dialog On Popup Window</label>
274
+ <frontend_type>select</frontend_type>
275
+ <source_model>adminhtml/system_config_source_yesno</source_model>
276
+ <sort_order>5</sort_order>
277
+ <show_in_default>1</show_in_default>
278
+ <show_in_website>1</show_in_website>
279
+ <show_in_store>1</show_in_store>
280
+ </popup>
281
+ <update translate="label">
282
+ <label>Enable Product Update Subscription</label>
283
+ <frontend_type>select</frontend_type>
284
+ <source_model>adminhtml/system_config_source_yesno</source_model>
285
+ <sort_order>10</sort_order>
286
+ <show_in_default>1</show_in_default>
287
+ <show_in_website>1</show_in_website>
288
+ <show_in_store>1</show_in_store>
289
+ </update>
290
+ <price_reduction translate="label">
291
+ <label>Enable Product Price Reduction Subscription</label>
292
+ <frontend_type>select</frontend_type>
293
+ <source_model>adminhtml/system_config_source_yesno</source_model>
294
+ <sort_order>20</sort_order>
295
+ <show_in_default>1</show_in_default>
296
+ <show_in_website>1</show_in_website>
297
+ <show_in_store>1</show_in_store>
298
+ </price_reduction>
299
+ <price_reduction_amount translate="label">
300
+ <label>Enable Product Price Reduction Amount</label>
301
+ <frontend_type>select</frontend_type>
302
+ <source_model>adminhtml/system_config_source_yesno</source_model>
303
+ <sort_order>30</sort_order>
304
+ <show_in_default>1</show_in_default>
305
+ <show_in_website>1</show_in_website>
306
+ <show_in_store>1</show_in_store>
307
+ </price_reduction_amount>
308
+ <price_reduction_match translate="label">
309
+ <label>Send When Price Match</label>
310
+ <frontend_type>select</frontend_type>
311
+ <source_model>adminhtml/system_config_source_yesno</source_model>
312
+ <sort_order>40</sort_order>
313
+ <show_in_default>1</show_in_default>
314
+ <show_in_website>1</show_in_website>
315
+ <show_in_store>1</show_in_store>
316
+ </price_reduction_match>
317
+ <stock_available translate="label">
318
+ <label>Enable Product Stock Available Subscription</label>
319
+ <frontend_type>select</frontend_type>
320
+ <source_model>adminhtml/system_config_source_yesno</source_model>
321
+ <sort_order>50</sort_order>
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
+ </stock_available>
326
+ <stock_available_amount translate="label">
327
+ <label>Enable Product Stock Available Amount</label>
328
+ <frontend_type>select</frontend_type>
329
+ <source_model>adminhtml/system_config_source_yesno</source_model>
330
+ <sort_order>60</sort_order>
331
+ <show_in_default>1</show_in_default>
332
+ <show_in_website>1</show_in_website>
333
+ <show_in_store>1</show_in_store>
334
+ </stock_available_amount>
335
+ <title_price translate="label">
336
+ <label>Price Reduction Title</label>
337
+ <frontend_type>text</frontend_type>
338
+ <sort_order>100</sort_order>
339
+ <show_in_default>1</show_in_default>
340
+ <show_in_website>1</show_in_website>
341
+ <show_in_store>1</show_in_store>
342
+ </title_price>
343
+ <notice_price translate="label">
344
+ <label>Price Reduction Bottom Notice</label>
345
+ <frontend_type>text</frontend_type>
346
+ <sort_order>101</sort_order>
347
+ <show_in_default>1</show_in_default>
348
+ <show_in_website>1</show_in_website>
349
+ <show_in_store>1</show_in_store>
350
+ </notice_price>
351
+ <title_stock translate="label">
352
+ <label>Stock Available Title</label>
353
+ <frontend_type>text</frontend_type>
354
+ <sort_order>110</sort_order>
355
+ <show_in_default>1</show_in_default>
356
+ <show_in_website>1</show_in_website>
357
+ <show_in_store>1</show_in_store>
358
+ </title_stock>
359
+ <notice_stock translate="label">
360
+ <label>Stock Available Bottom Notice</label>
361
+ <frontend_type>text</frontend_type>
362
+ <sort_order>111</sort_order>
363
+ <show_in_default>1</show_in_default>
364
+ <show_in_website>1</show_in_website>
365
+ <show_in_store>1</show_in_store>
366
+ </notice_stock>
367
+ <title_update translate="label">
368
+ <label>Product Update Title</label>
369
+ <frontend_type>text</frontend_type>
370
+ <sort_order>120</sort_order>
371
+ <show_in_default>1</show_in_default>
372
+ <show_in_website>1</show_in_website>
373
+ <show_in_store>1</show_in_store>
374
+ </title_update>
375
+ <notice_update translate="label">
376
+ <label>Product Update Bottom Notice</label>
377
+ <frontend_type>text</frontend_type>
378
+ <sort_order>121</sort_order>
379
+ <show_in_default>1</show_in_default>
380
+ <show_in_website>1</show_in_website>
381
+ <show_in_store>1</show_in_store>
382
+ </notice_update>
383
+ </fields>
384
+ </product>
385
+ <category translate="label">
386
+ <label>Category Options</label>
387
+ <frontend_type>text</frontend_type>
388
+ <sort_order>4</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
+ <fields>
393
+ <enable translate="label">
394
+ <label>Enable Category Subscription</label>
395
+ <frontend_type>select</frontend_type>
396
+ <source_model>adminhtml/system_config_source_yesno</source_model>
397
+ <sort_order>1</sort_order>
398
+ <show_in_default>1</show_in_default>
399
+ <show_in_website>1</show_in_website>
400
+ <show_in_store>1</show_in_store>
401
+ </enable>
402
+ <popup translate="label">
403
+ <label>Enable Dialog On Popup Window</label>
404
+ <frontend_type>select</frontend_type>
405
+ <source_model>adminhtml/system_config_source_yesno</source_model>
406
+ <sort_order>5</sort_order>
407
+ <show_in_default>1</show_in_default>
408
+ <show_in_website>1</show_in_website>
409
+ <show_in_store>1</show_in_store>
410
+ </popup>
411
+ <new translate="label">
412
+ <label>Enable New Product Subscription</label>
413
+ <frontend_type>select</frontend_type>
414
+ <source_model>adminhtml/system_config_source_yesno</source_model>
415
+ <sort_order>10</sort_order>
416
+ <show_in_default>1</show_in_default>
417
+ <show_in_website>1</show_in_website>
418
+ <show_in_store>1</show_in_store>
419
+ </new>
420
+ <price translate="label">
421
+ <label>Enable Product Price Reduction Subscription</label>
422
+ <frontend_type>select</frontend_type>
423
+ <source_model>adminhtml/system_config_source_yesno</source_model>
424
+ <sort_order>20</sort_order>
425
+ <show_in_default>1</show_in_default>
426
+ <show_in_website>1</show_in_website>
427
+ <show_in_store>1</show_in_store>
428
+ </price>
429
+ <title_price translate="label">
430
+ <label>Price Reduction Title</label>
431
+ <frontend_type>text</frontend_type>
432
+ <sort_order>30</sort_order>
433
+ <show_in_default>1</show_in_default>
434
+ <show_in_website>1</show_in_website>
435
+ <show_in_store>1</show_in_store>
436
+ </title_price>
437
+ <notice_price translate="label">
438
+ <label>Price Reduction Bottom Notice</label>
439
+ <frontend_type>text</frontend_type>
440
+ <sort_order>31</sort_order>
441
+ <show_in_default>1</show_in_default>
442
+ <show_in_website>1</show_in_website>
443
+ <show_in_store>1</show_in_store>
444
+ </notice_price>
445
+ <title_new translate="label">
446
+ <label>New Product Title</label>
447
+ <frontend_type>text</frontend_type>
448
+ <sort_order>40</sort_order>
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
+ </title_new>
453
+ <notice_new translate="label">
454
+ <label>New Product Bottom Notice</label>
455
+ <frontend_type>text</frontend_type>
456
+ <sort_order>41</sort_order>
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
+ </notice_new>
461
+ </fields>
462
+ </category>
463
+ </groups>
464
+ </magentokey_newsletter>
465
+ </sections>
466
+ </config>
app/code/community/Magentokey/Newsletter/etc/widget.xml ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
5
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
6
+ * @version 1.0.0
7
+ */
8
+ -->
9
+ <widgets>
10
+ <magentokey_newsletter_product type="magentokey_newsletter/widget_product" translate="name description" module="magentokey_newsletter">
11
+ <name>Magentokey Newsletter Template</name>
12
+ <description>Magentokey Newsletter Template</description>
13
+ <is_email_compatible>1</is_email_compatible>
14
+ <parameters>
15
+ <template>
16
+ <required>1</required>
17
+ <visible>1</visible>
18
+ <label>Template</label>
19
+ <type>select</type>
20
+ <value>magentokey/newsletter/widget/price.phtml</value>
21
+ <values>
22
+ <price translate="label">
23
+ <value>magentokey/newsletter/widget/price.phtml</value>
24
+ <label>Price Reduction Subscription Template</label>
25
+ </price>
26
+ <stock translate="label">
27
+ <value>magentokey/newsletter/widget/stock.phtml</value>
28
+ <label>Stock Available Subscription Template</label>
29
+ </stock>
30
+ <update translate="label">
31
+ <value>magentokey/newsletter/widget/update.phtml</value>
32
+ <label>Product Update Subscription Template</label>
33
+ </update>
34
+ <new translate="label">
35
+ <value>magentokey/newsletter/widget/new.phtml</value>
36
+ <label>New Product Subscription Template</label>
37
+ </new>
38
+ </values>
39
+ </template>
40
+ <cache_lifetime translate="label description">
41
+ <label>Cache Lifetime (Seconds)</label>
42
+ <description>86400 by default, if not set. To refresh instantly, Clear the Blocks HTML Output Cache.</description>
43
+ <visible>1</visible>
44
+ <type>text</type>
45
+ </cache_lifetime>
46
+ </parameters>
47
+ </magentokey_newsletter_product>
48
+ </widgets>
app/code/community/Magentokey/Newsletter/sql/magentokey_newsletter_setup/mysql4-install-1.0.0.php ADDED
@@ -0,0 +1,119 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.1.0
6
+ */
7
+ $installer = $this;
8
+ $installer->startSetup();
9
+ $installer->run("
10
+ DROP TABLE IF EXISTS `{$installer->getTable('newsletter_product_problem')}`;
11
+ CREATE TABLE `{$installer->getTable('newsletter_product_problem')}` (
12
+ `problem_id` int(7) unsigned NOT NULL auto_increment,
13
+ `subscriber_id` int(7) unsigned default NULL,
14
+ `queue_id` int(7) unsigned NOT NULL default '0',
15
+ `problem_error_code` int(3) unsigned default '0',
16
+ `problem_error_text` varchar(200) default NULL,
17
+ PRIMARY KEY (`problem_id`),
18
+ KEY `FK_PRODUCT_PROBLEM_SUBSCRIBER` (`subscriber_id`),
19
+ KEY `FK_PRODUCT_PROBLEM_QUEUE` (`queue_id`),
20
+ CONSTRAINT `FK_PRODUCT_PROBLEM_QUEUE` FOREIGN KEY (`queue_id`) REFERENCES `{$installer->getTable('newsletter_product_queue')}` (`queue_id`) ON DELETE CASCADE,
21
+ CONSTRAINT `FK_PRODUCT_PROBLEM_SUBSCRIBER` FOREIGN KEY (`subscriber_id`) REFERENCES `{$installer->getTable('newsletter_product_subscriber')}` (`subscriber_id`) ON DELETE CASCADE
22
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Newsletter product problems';
23
+
24
+ DROP TABLE IF EXISTS `{$installer->getTable('newsletter_product_queue')}`;
25
+ CREATE TABLE `{$installer->getTable('newsletter_product_queue')}` (
26
+ `queue_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
27
+ `product_id` int(10) unsigned NOT NULL,
28
+ `subscriber_type` int(3) unsigned DEFAULT '0',
29
+ `template_id` int(7) unsigned NOT NULL DEFAULT '0',
30
+ `newsletter_text` text COMMENT 'Newsletter Text',
31
+ `newsletter_styles` text COMMENT 'Newsletter Styles',
32
+ `newsletter_subject` varchar(200) DEFAULT NULL COMMENT 'Newsletter Subject',
33
+ `newsletter_sender_name` varchar(200) DEFAULT NULL COMMENT 'Newsletter Sender Name',
34
+ `newsletter_sender_email` varchar(200) DEFAULT NULL COMMENT 'Newsletter Sender Email',
35
+ `queue_status` int(3) unsigned NOT NULL DEFAULT '0',
36
+ `queue_num` int(10) NOT NULL DEFAULT '0',
37
+ `sent_at` datetime DEFAULT NULL,
38
+ `added_at` datetime DEFAULT NULL,
39
+ PRIMARY KEY (`queue_id`),
40
+ KEY `FK_PRODUCT_QUEUE_TEMPLATE` (`template_id`),
41
+ CONSTRAINT `FK_PRODUCT_QUEUE_TEMPLATE` FOREIGN KEY (`template_id`) REFERENCES `{$installer->getTable('newsletter_product_template')}` (`template_id`) ON DELETE CASCADE,
42
+ CONSTRAINT `FK_PRODUCT_QUEUE_TEMPLATE_PRODUCT` FOREIGN KEY (`product_id`) REFERENCES `{$installer->getTable('catalog_product_entity')}` (`entity_id`) ON DELETE CASCADE
43
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Newsletter product queue';
44
+
45
+ DROP TABLE IF EXISTS `{$installer->getTable('newsletter_product_queue_link')}`;
46
+ CREATE TABLE `{$installer->getTable('newsletter_product_queue_link')}` (
47
+ `queue_link_id` int(10) unsigned NOT NULL auto_increment,
48
+ `queue_id` int(10) unsigned NOT NULL default '0',
49
+ `subscriber_id` int(10) unsigned NOT NULL default '0',
50
+ `letter_sent_at` datetime default NULL,
51
+ PRIMARY KEY (`queue_link_id`),
52
+ KEY `FK_PRODUCT_QUEUE_LINK_SUBSCRIBER` (`subscriber_id`),
53
+ KEY `FK_PRODUCT_QUEUE_LINK_QUEUE` (`queue_id`),
54
+ CONSTRAINT `FK_PRODUCT_QUEUE_LINK_QUEUE` FOREIGN KEY (`queue_id`) REFERENCES `{$installer->getTable('newsletter_product_queue')}` (`queue_id`) ON DELETE CASCADE,
55
+ CONSTRAINT `FK_PRODUCT_QUEUE_LINK_SUBSCRIBER` FOREIGN KEY (`subscriber_id`) REFERENCES `{$installer->getTable('newsletter_product_subscriber')}` (`subscriber_id`) ON DELETE CASCADE
56
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Newsletter queue to subscriber link';
57
+
58
+ DROP TABLE IF EXISTS `{$installer->getTable('newsletter_product_queue_store_link')}`;
59
+ CREATE TABLE `{$installer->getTable('newsletter_product_queue_store_link')}` (
60
+ `queue_id` int(10) unsigned NOT NULL default '0',
61
+ `store_id` smallint(5) unsigned NOT NULL default '0',
62
+ PRIMARY KEY (`queue_id`,`store_id`),
63
+ KEY `FK_PRODUCT_NEWSLETTER_QUEUE_STORE_LINK_STORE` (`store_id`),
64
+ CONSTRAINT `FK_PRODUCT_NEWSLETTER_QUEUE_STORE_LINK_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$installer->getTable('core_store')}` (`store_id`) ON DELETE CASCADE ON UPDATE CASCADE,
65
+ CONSTRAINT `FK_PRODUCT_LINK_QUEUE` FOREIGN KEY (`queue_id`) REFERENCES `{$installer->getTable('newsletter_product_queue')}` (`queue_id`) ON DELETE CASCADE
66
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
67
+
68
+ DROP TABLE IF EXISTS `{$installer->getTable('newsletter_product_subscriber')}`;
69
+ CREATE TABLE `{$installer->getTable('newsletter_product_subscriber')}` (
70
+ `subscriber_id` int(10) unsigned NOT NULL auto_increment,
71
+ `store_id` smallint(5) unsigned default '0',
72
+ `category_id` int(7) unsigned default NULL,
73
+ `product_id` int(10) unsigned default NULL,
74
+ `product_type` varchar(50) default NULL,
75
+ `subscriber_type` int(3) NOT NULL default '0',
76
+ `subscriber_type_amount` int(10) DEFAULT '0',
77
+ `date_from` date DEFAULT NULL,
78
+ `date_to` date DEFAULT NULL,
79
+ `added_at` datetime default NULL,
80
+ `change_status_at` datetime default NULL,
81
+ `customer_id` int(11) unsigned NOT NULL default '0',
82
+ `subscriber_email` varchar(150) character set latin1 collate latin1_general_ci NOT NULL default '',
83
+ `subscriber_status` int(3) NOT NULL default '0',
84
+ `subscriber_confirm_code` varchar(32) default 'NULL',
85
+ PRIMARY KEY (`subscriber_id`),
86
+ KEY `FK_PRODUCT_SUBSCRIBER_CUSTOMER` (`customer_id`),
87
+ KEY `FK_PRODUCT_NEWSLETTER_SUBSCRIBER_STORE` (`store_id`),
88
+ CONSTRAINT `FK_PRODUCT_NEWSLETTER_SUBSCRIBER_STORE` FOREIGN KEY (`store_id`) REFERENCES `{$installer->getTable('core_store')}` (`store_id`) ON DELETE SET NULL ON UPDATE CASCADE
89
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Newsletter product subscribers';
90
+
91
+ DROP TABLE IF EXISTS `{$installer->getTable('newsletter_product_template')}`;
92
+ CREATE TABLE `{$installer->getTable('newsletter_product_template')}` (
93
+ `template_id` int(7) unsigned NOT NULL auto_increment,
94
+ `template_code` varchar(150) default NULL,
95
+ `template_category_id` int(10) unsigned default 0,
96
+ `template_product_id` int(10) unsigned default 0,
97
+ `template_subscriber_type` int(3) default 0,
98
+ `template_memo` varchar(150) default NULL,
99
+ `template_text` text,
100
+ `template_text_preprocessed` text,
101
+ `template_styles` text COMMENT 'Template Styles',
102
+ `template_type` int(3) unsigned default 0,
103
+ `template_position` int(7) unsigned default 0,
104
+ `template_status` int(3) unsigned default 0,
105
+ `template_subject` varchar(200) default NULL,
106
+ `template_sender_name` varchar(200) default NULL,
107
+ `template_sender_email` varchar(200) character set latin1 collate latin1_general_ci default NULL,
108
+ `template_actual` tinyint(1) unsigned default '1',
109
+ `added_at` datetime default NULL,
110
+ `modified_at` datetime default NULL,
111
+ `start_at` date DEFAULT NULL,
112
+ `end_at` date DEFAULT NULL,
113
+ PRIMARY KEY (`template_id`),
114
+ KEY `template_actual` (`template_actual`),
115
+ KEY `added_at` (`added_at`),
116
+ KEY `modified_at` (`modified_at`)
117
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Newsletter product templates';
118
+ ");
119
+ $installer->endSetup();
app/design/adminhtml/default/default/layout/magentokey_newsletter.xml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
5
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
6
+ * @version 1.1.0
7
+ */
8
+ -->
9
+ <layout>
10
+ <adminhtml_productnewsletter_template_edit>
11
+ <update handle="editor"/>
12
+ <reference name="content">
13
+ <block type="magentokey_newsletter/adminhtml_newsletter_template_edit" name="product_template_edit" as="product_template_edit" template="magentokey/newsletter/template/edit.phtml" />
14
+ </reference>
15
+ </adminhtml_productnewsletter_template_edit>
16
+ <adminhtml_productnewsletter_template_preview>
17
+ <reference name="root">
18
+ <action method="setTemplate"><template>magentokey/newsletter/preview/iframeswitcher.phtml</template></action>
19
+ <block type="magentokey_newsletter/adminhtml_newsletter_template_preview_form" name="preview_form" />
20
+ <block type="adminhtml/store_switcher" name="store_switcher" template="magentokey/newsletter/preview/store.phtml" />
21
+ </reference>
22
+ </adminhtml_productnewsletter_template_preview>
23
+ <magentokey_newsletter_template_preview>
24
+ <block type="core/template" name="root" output="toHtml" template="magentokey/newsletter/template/preview.phtml">
25
+ <block type="magentokey_newsletter/adminhtml_newsletter_template_preview" name="content" as="content"></block>
26
+ </block>
27
+ </magentokey_newsletter_template_preview>
28
+ <adminhtml_productnewsletter_queue_preview>
29
+ <reference name="root">
30
+ <action method="setTemplate"><template>magentokey/newsletter/preview/iframeswitcher.phtml</template></action>
31
+ <block type="magentokey_newsletter/adminhtml_newsletter_queue_preview_form" name="preview_form" />
32
+ <block type="adminhtml/store_switcher" name="store_switcher" template="magentokey/newsletter/preview/store.phtml" />
33
+ </reference>
34
+ </adminhtml_productnewsletter_queue_preview>
35
+ <magentokey_newsletter_queue_preview>
36
+ <block type="core/template" name="root" output="toHtml" template="magentokey/newsletter/queue/preview.phtml">
37
+ <block type="magentokey_newsletter/adminhtml_newsletter_queue_preview" name="content" as="content"></block>
38
+ </block>
39
+ </magentokey_newsletter_queue_preview>
40
+ </layout>
app/design/adminhtml/default/default/template/magentokey/newsletter/manage/index.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magenotkey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ ?>
8
+ <div class="content-header">
9
+ <table cellspacing="0">
10
+ <tr>
11
+ <td style="width:50%;"><h3 class="icon-head head-newsletter-list"><?php echo $this->getHeaderText() ?></h3></td>
12
+ </tr>
13
+ </table>
14
+ </div>
15
+ <div>
16
+ <?php echo $this->getChildHtml('grid') ?>
17
+ </div>
app/design/adminhtml/default/default/template/magentokey/newsletter/preview/iframeswitcher.phtml ADDED
@@ -0,0 +1,70 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magenotkey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ ?>
8
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
9
+ <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="<?php echo $this->getLang() ?>" lang="<?php echo $this->getLang() ?>">
10
+ <head>
11
+ <?php echo $this->getChildHtml('head') ?>
12
+ <style type="text/css">
13
+ html,body { height:100%; }
14
+ </style>
15
+ </head>
16
+ <body id="html-body" style="background:#fff;">
17
+ <div id="preview" class="cms-revision-preview">
18
+ <div class="toolbar">
19
+ <?php if (!Mage::app()->isSingleStoreMode()) :?>
20
+ <p class="switcher">
21
+ <?php echo $this->getChildHtml('store_switcher') ?>
22
+ <button class="button" onclick="preview();"><span><?php echo $this->__('Preview'); ?></span></button>
23
+ </p>
24
+ <?php endif;?>
25
+ </div>
26
+ <iframe name="preview_iframe" id="preview_iframe" frameborder="0"></iframe>
27
+
28
+ <?php echo $this->getChildHtml('preview_form'); ?>
29
+ </div>
30
+ <div id="loading-mask" style="display:none">
31
+ <p class="loader" id="loading_mask_loader"><img src="<?php echo $this->getSkinUrl('images/ajax-loader-tr.gif') ?>" alt="<?php echo Mage::helper('adminhtml')->__('Loading...') ?>"/><br/><?php echo Mage::helper('adminhtml')->__('Please wait...') ?></p>
32
+ </div>
33
+
34
+ <script type="text/javascript">
35
+ //<![CDATA[
36
+ var previewForm = $('preview_form');
37
+ var loadingMask = $('loading-mask');
38
+ var previewIframe = $('preview_iframe');
39
+
40
+ function preview() {
41
+ previewForm.writeAttribute('target', previewIframe.readAttribute('id'));
42
+ blockPreview();
43
+ previewForm.submit();
44
+ }
45
+
46
+ function blockPreview() {
47
+ var cumulativeOffset = $('preview').cumulativeOffset();
48
+ $('loading-mask').setStyle({
49
+ top: ( cumulativeOffset.top ) + 'px',
50
+ left: ( cumulativeOffset.left ) + 'px',
51
+ width: $('preview').getWidth() + 'px',
52
+ height: $('preview').getHeight() + 'px'
53
+ });
54
+
55
+ toggleSelectsUnderBlock($('loading-mask'), false);
56
+ Element.show('loading-mask');
57
+ setLoaderPosition();
58
+ }
59
+
60
+ function unBlockPreview() {
61
+ toggleSelectsUnderBlock(loadingMask, true);
62
+ Element.hide(loadingMask);
63
+ }
64
+
65
+ Event.observe(window, 'load', preview);
66
+ Event.observe(previewIframe, 'load', unBlockPreview);
67
+ //]]>
68
+ </script>
69
+ </body>
70
+ </html>
app/design/adminhtml/default/default/template/magentokey/newsletter/preview/store.phtml ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magenotkey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ ?>
8
+ <?php if ($websites = $this->getWebsites()): ?>
9
+ <label for="store_switcher"><?php echo $this->__('Choose Store View') ?>:</label>
10
+ <select name="store_switcher" id="store_switcher">
11
+ <?php foreach ($websites as $website): ?>
12
+ <?php $showWebsite=false; ?>
13
+ <?php foreach ($website->getGroups() as $group): ?>
14
+ <?php $showGroup=false; ?>
15
+ <?php foreach ($this->getStores($group) as $store): ?>
16
+ <?php if ($showWebsite == false): ?>
17
+ <?php $showWebsite = true; ?>
18
+ <optgroup label="<?php echo $website->getName() ?>"></optgroup>
19
+ <?php endif; ?>
20
+ <?php if ($showGroup == false): ?>
21
+ <?php $showGroup = true; ?>
22
+ <optgroup label="&nbsp;&nbsp;&nbsp;<?php echo $group->getName() ?>">
23
+ <?php endif; ?>
24
+ <option value="<?php echo $store->getId() ?>"<?php if($this->getStoreId() == $store->getId()): ?> selected="selected"<?php endif; ?>>&nbsp;&nbsp;&nbsp;&nbsp;<?php echo $store->getName() ?></option>
25
+ <?php endforeach; ?>
26
+ <?php if ($showGroup): ?>
27
+ </optgroup>
28
+ <?php endif; ?>
29
+ <?php endforeach; ?>
30
+ <?php endforeach; ?>
31
+ </select>
32
+ <script type="text/javascript">
33
+ //<![CDATA[
34
+ Event.observe($('store_switcher'), 'change', function(event) {
35
+ var element = Event.element(event);
36
+ $('preview_store_id').value = element.value;
37
+ });
38
+ //]]>
39
+ </script>
40
+ <?php endif; ?>
app/design/adminhtml/default/default/template/magentokey/newsletter/problem/list.phtml ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magentokey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ ?>
8
+ <div class="content-header">
9
+ <table cellspacing="0">
10
+ <tr>
11
+ <td style="width:50%;"><h3 class="icon-head head-newsletter-report"><?php echo Mage::helper('magentokey_newsletter')->__('Magentokey Newsletter Problem Reports') ?></h3></td>
12
+ <td class="form-buttons">
13
+
14
+ </td>
15
+ </tr>
16
+ </table>
17
+ </div>
18
+ <div>
19
+ <?php echo $this->getChildHtml('grid') ?>
20
+ </div>
21
+ <?php if($this->getShowButtons()): ?>
22
+ <div class="form-buttons">
23
+ <?php echo $this->getUnsubscribeButtonHtml(); ?>
24
+ <?php echo $this->getDeleteButtonHtml(); ?>
25
+ </div>
26
+ <?php endif ?>
app/design/adminhtml/default/default/template/magentokey/newsletter/queue/edit.phtml ADDED
@@ -0,0 +1,79 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magenotkey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ ?>
8
+ <div class="content-header">
9
+ <table cellspacing="0">
10
+ <tr>
11
+ <td><h3><?php echo $this->getHeaderText() ?></h3></td>
12
+ <td class="form-buttons">
13
+ <?php echo $this->getBackButtonHtml() ?>
14
+ <?php echo $this->getPreviewButtonHtml(); ?>
15
+ <?php if(!$this->getIsPreview()): ?>
16
+ <?php echo $this->getResetButtonHtml() ?>
17
+ <?php echo $this->getSaveButtonHtml() ?>
18
+ <?php endif ?>
19
+ <?php if($this->getCanResume()): ?>
20
+ <?php echo $this->getResumeButtonHtml() ?>
21
+ <?php endif ?>
22
+ </td>
23
+ </tr>
24
+ </table>
25
+ </div>
26
+ <form action="<?php echo $this->getSaveUrl() ?>" method="post" id="queue_edit_form">
27
+ <?php echo $this->getBlockHtml('formkey')?>
28
+ <div class="no-display">
29
+ <input type="hidden" name="_resume" id="_resume_flag" value="" />
30
+ </div>
31
+ <?php echo $this->getChildHtml('form') ?>
32
+ </form>
33
+ <form action="<?php echo $this->getPreviewUrl() ?>" method="post" id="newsletter_queue_preview_form" target="_blank">
34
+ <?php echo $this->getBlockHtml('formkey')?>
35
+ <div class="no-display">
36
+ <input type="hidden" id="preview_type" name="type" value="<?php echo $this->getIsTextType()?1:2 ?>" />
37
+ <input type="hidden" id="preview_text" name="text" value="" />
38
+ <input type="hidden" id="preview_styles" name="styles" value="" />
39
+ <input type="hidden" id="preview_id" name="id" value="" />
40
+ </div>
41
+ </form>
42
+ <script type="text/javascript">
43
+ //<![CDATA[
44
+ var queueForm = new varienForm('queue_edit_form');
45
+ var newsletterPreviewForm = new varienForm('newsletter_queue_preview_form');
46
+
47
+ var queueControl = {
48
+ id: 'text',
49
+ save: function() {
50
+ $('_resume_flag').value = '';
51
+ queueForm.submit();
52
+ },
53
+ preview: function() {
54
+ if (this.isEditor() && tinyMCE.get(this.id)) {
55
+ tinyMCE.triggerSave();
56
+ $('preview_text').value = $(this.id).value;
57
+ tinyMCE.triggerSave();
58
+ } else {
59
+ $('preview_text').value = $(this.id).value;
60
+ }
61
+ if ($('styles') != undefined) {
62
+ $('preview_styles').value = $('styles').value;
63
+ }
64
+ if ($('id') != undefined) {
65
+ $('preview_id').value = $('id').value;
66
+ }
67
+ newsletterPreviewForm.submit();
68
+ return false;
69
+ },
70
+ isEditor: function() {
71
+ return (typeof tinyMceEditors != 'undefined' && tinyMceEditors.get(this.id) != undefined)
72
+ },
73
+ resume: function() {
74
+ $('_resume_flag').value = '1';
75
+ queueForm.submit();
76
+ }
77
+ };
78
+ //]]>
79
+ </script>
app/design/adminhtml/default/default/template/magentokey/newsletter/queue/list.phtml ADDED
@@ -0,0 +1,20 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magenotkey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ ?>
8
+ <div class="content-header">
9
+ <table cellspacing="0">
10
+ <tr>
11
+ <td style="width:50%;"><h3 class="icon-head head-newsletter-queue"><?php echo $this->__('Magentokey Newsletter Queue') ?></h3></td>
12
+ <td class="form-buttons">
13
+
14
+ </td>
15
+ </tr>
16
+ </table>
17
+ </div>
18
+ <div>
19
+ <?php echo $this->getChildHtml('grid') ?>
20
+ </div>
app/design/adminhtml/default/default/template/magentokey/newsletter/queue/preview.phtml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magenotkey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ ?>
8
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
9
+ <html lang="en">
10
+ <head>
11
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
12
+ <title><?php echo Mage::helper('newsletter')->__('Magentokey Newsletter Preview'); ?></title>
13
+ </head>
14
+
15
+ <?php $data = $this->getFormData(); ?>
16
+ <?php if($data['styles']):
17
+ $html = "<style type=\"text/css\">\n%s\n</style>";
18
+ echo sprintf($html, $data['styles']);
19
+ endif; ?>
20
+ <body>
21
+ <?php echo $this->getChildHtml('content') ?>
22
+ <?php echo $this->getChildHtml('profiler') ?>
23
+ </body>
24
+ </html>
app/design/adminhtml/default/default/template/magentokey/newsletter/report/grid.phtml ADDED
@@ -0,0 +1,206 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magenotkey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+
8
+ $numColumns = sizeof($this->getColumns());
9
+ ?>
10
+ <?php if($this->getCollection()): ?>
11
+ <?php if($this->canDisplayContainer()): ?>
12
+ <?php if($this->getGridHeader()): ?>
13
+ <div class="content-header">
14
+ <table cellspacing="0">
15
+ <tr>
16
+ <td style="width:50%;"><h2><?php echo $this->getGridHeader(); ?></h2></td>
17
+ </tr>
18
+ </table>
19
+ </div>
20
+ <?php endif ?>
21
+ <div id="<?php echo $this->getId() ?>">
22
+ <?php else: ?>
23
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
24
+ <?php endif; ?>
25
+ <?php if($this->getStoreSwitcherVisibility() || $this->getDateFilterVisibility()): ?>
26
+ <?php if($this->getStoreSwitcherVisibility()): ?>
27
+ <?php echo $this->getStoreSwitcherHtml() ?>
28
+ <?php endif ?>
29
+ <table cellspacing="0" class="actions">
30
+ <tr>
31
+ <?php if($this->getDateFilterVisibility()): ?>
32
+ <td class="a-left filter">
33
+ <div class="f-left">
34
+ <div><?php echo $this->__('From') ?>:&nbsp;<input class="input-text no-changes required-entry" type="text" id="period_date_from" name="report_from" value="<?php echo $this->getFilter('report_from') ?>" style="width:5em" /> <img src="<?php echo $this->getSkinUrl('images/grid-cal.gif') ?>" title="<?php echo $this->__('Select Date') ?>" id="period_date_from_trig" alt="<?php echo $this->__('Select Date') ?>" class="v-middle"/>&nbsp;&nbsp;</div>
35
+ <div id="period_date_from_advaice"></div>
36
+ </div>
37
+
38
+ <div class="f-left">
39
+ <div><?php echo $this->__('To') ?>:&nbsp;<input class="input-text no-changes required-entry" type="text" id="period_date_to" name="report_to" value="<?php echo $this->getFilter('report_to') ?>" style="width:5em" /> <img src="<?php echo $this->getSkinUrl('images/grid-cal.gif') ?>" class="v-middle" title="<?php echo $this->__('Select Date') ?>"id="period_date_to_trig" alt="<?php echo $this->__('Select Date') ?>"/>&nbsp;&nbsp;</div>
40
+ <div id="period_date_to_advaice"></div>
41
+ </div>
42
+
43
+ <div class="f-left">
44
+ <?php echo $this->__('Show By') ?>:
45
+ <select name="report_period" id="report_period" style="width:6em;">
46
+ <?php foreach ($this->getPeriods() as $_value=>$_label): ?>
47
+ <option value="<?php echo $_value ?>" <?php if($this->getFilter('report_period')==$_value): ?> selected<?php endif; ?>><?php echo $_label ?></option>
48
+ <?php endforeach; ?>
49
+ </select>
50
+ <?php echo $this->getRefreshButtonHtml() ?>
51
+ </div>
52
+ <script type="text/javascript">
53
+ <!--
54
+ Calendar.setup({
55
+ inputField : 'period_date_from',
56
+ ifFormat : '<?php echo $this->getDateFormat() ?>',
57
+ button : 'period_date_from_trig',
58
+ align : 'Bl',
59
+ singleClick : true
60
+ });
61
+ Calendar.setup({
62
+ inputField : 'period_date_to',
63
+ ifFormat : '<?php echo $this->getDateFormat() ?>',
64
+ button : 'period_date_to_trig',
65
+ align : 'Bl',
66
+ singleClick : true
67
+ });
68
+ //-->
69
+ </script>
70
+ </td>
71
+ <?php endif; ?>
72
+ <?php if($this->getExportVisibility()): ?>
73
+ <td class="a-right">
74
+ <img src="<?php echo $this->getSkinUrl('images/icon_export.gif') ?>" alt="" class="v-middle"/>&nbsp; <?php echo $this->__('Export to:') ?>
75
+ <select name="<?php echo $this->getId() ?>_export" id="<?php echo $this->getId() ?>_export" style="width:8em;">
76
+ <?php foreach ($this->getExportTypes() as $_type): ?>
77
+ <option value="<?php echo $_type->getUrl() ?>"><?php echo $_type->getLabel() ?></option>
78
+ <?php endforeach; ?>
79
+ </select>
80
+ <?php echo $this->getExportButtonHtml() ?>
81
+ </td>
82
+ <?php endif; ?>
83
+ </tr>
84
+ </table>
85
+ <?php endif; ?>
86
+ <div class="grid">
87
+ <table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
88
+ <col/>
89
+ <?php foreach ($this->getColumns() as $_column): ?>
90
+ <col <?php echo $_column->getHtmlProperty() ?>/>
91
+ <?php endforeach; ?>
92
+ <?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
93
+ <thead>
94
+ <?php if ($this->getHeadersVisibility()): ?>
95
+ <tr class="headings">
96
+ <th class="no-link" style="width:100px"><span class="no-br"><?php echo $this->getPeriodText() ?></span></th>
97
+ <?php foreach ($this->getColumns() as $_column): ?>
98
+ <th <?php echo $_column->getHeaderHtmlProperty() ?>><span class="no-br"><?php echo $_column->getHeaderHtml() ?></span></th>
99
+ <?php endforeach; ?>
100
+ </tr>
101
+ <?php endif; ?>
102
+ </thead>
103
+ <?php endif; ?>
104
+ <tbody>
105
+ <?php if ($this->getCollection()->getSize()): ?>
106
+ <?php foreach ($this->getCollection()->getIntervals() as $_index => $_item): ?>
107
+ <tr>
108
+ <?php $report = $this->getReport($_item['start'], $_item['end']) ?>
109
+ <?php $rows=count($report) ?>
110
+ <?php if ($rows > 0 ): ?>
111
+ <td rowspan="<?php echo $rows + ($this->getCountTotals() && $this->getSubtotalVisibility()?1:0) ?>"><?php echo $_index ?></td>
112
+ <?php $i=0;foreach ($report as $_subIndex=>$_subItem): ?>
113
+ <?php if($i>0): ?>
114
+ <tr>
115
+ <?php endif; ?>
116
+ <?php $i++; ?>
117
+ <?php $j=0;foreach ($this->getColumns() as $_column): ?>
118
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$j==$numColumns?'last':'' ?>">
119
+ <?php echo (($_html = $_column->getRowField($_subItem)) != '' ? $_html : '&nbsp;') ?>
120
+ </td>
121
+ <?php endforeach; ?>
122
+ </tr>
123
+ <?php endforeach; ?>
124
+ <?php if($this->getCountTotals() && $rows > 0 && $this->getSubtotalVisibility()): ?>
125
+ <tr>
126
+ <?php $j=0;foreach ($this->getColumns() as $_column): ?>
127
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$j==$numColumns?'last':'' ?> subtotal">
128
+ <?php echo ($j==1)?$this->getSubtotalText():$_column->getRowField($this->getTotals()) ?>
129
+ </td>
130
+ <?php endforeach; ?>
131
+ </tr>
132
+ <?php endif; ?>
133
+ <?php else: ?>
134
+ <td><?php echo $_index ?></td>
135
+ <td colspan="<?php echo $numColumns ?>" class="empty-text <?php echo $this->getEmptyTextClass() ?> last"><?php echo $this->getEmptyText() ?></td>
136
+ <?php endif; ?>
137
+ </tr>
138
+ <?php endforeach; ?>
139
+ <?php elseif ($this->getEmptyText()): ?>
140
+ <tr>
141
+ <td class="empty-text <?php echo $this->getEmptyTextClass() ?>" colspan="<?php echo $numColumns + 1 ?>"><?php echo $this->getEmptyText() ?></td>
142
+ </tr>
143
+ <?php endif; ?>
144
+ </tbody>
145
+ <?php if ($this->getCountTotals() && $this->getCollection()->getSize()): ?>
146
+ <tfoot>
147
+ <tr><th><?php echo $this->getTotalText() ?></th>
148
+ <?php $j=0;foreach ($this->getColumns() as $_column): ?>
149
+ <th class="<?php echo $_column->getCssProperty() ?> <?php echo ++$j==$numColumns?'last':'' ?>"><?php echo $_column->getRowField($this->getGrandTotals()) ?></th>
150
+ <?php endforeach; ?>
151
+ </tr>
152
+ </tfoot>
153
+ <?php endif; ?>
154
+ </table>
155
+ </div>
156
+ <?php if($this->canDisplayContainer()): ?>
157
+ </div>
158
+ <script type="text/javascript">
159
+ //<![CDATA[
160
+ <?php echo $this->getJsObjectName() ?> = new varienGrid('<?php echo $this->getId() ?>', '<?php echo $this->getGridUrl() ?>', '<?php echo $this->getVarNamePage() ?>', '<?php echo $this->getVarNameSort() ?>', '<?php echo $this->getVarNameDir() ?>', '<?php echo $this->getVarNameFilter() ?>');
161
+ <?php echo $this->getJsObjectName() ?>.useAjax = '<?php echo $this->getUseAjax() ?>';
162
+ <?php if($this->getDateFilterVisibility()):?>
163
+ <?php echo $this->getJsObjectName() ?>.doFilterCallback = validateFilterDate;
164
+ var period_date_from = $('period_date_from');
165
+ var period_date_to = $('period_date_to');
166
+ period_date_from.advaiceContainer = $('period_date_from_advaice');
167
+ period_date_to.advaiceContainer = $('period_date_to_advaice');
168
+
169
+ function validateFilterDate()
170
+ {
171
+ if (period_date_from && period_date_to) {
172
+ return Validation.validate(period_date_from) && Validation.validate(period_date_to);
173
+ }
174
+ else {
175
+ return true;
176
+ }
177
+ }
178
+ <?php endif;?>
179
+ /* Overwrite function from switcher.phtml widget*/
180
+ function switchStore(obj){
181
+ if (obj.options[obj.selectedIndex].getAttribute('website') == 'true') {
182
+ var selectionType = 'website';
183
+ } else if (obj.options[obj.selectedIndex].getAttribute('group') == 'true') {
184
+ var selectionType = 'group';
185
+ } else {
186
+ var selectionType = 'store';
187
+ }
188
+ var storeParam = obj.value ? selectionType + '/' + obj.value + '/' : '';
189
+ if(obj.switchParams){
190
+ storeParam+= obj.switchParams;
191
+ }
192
+ var formParam = new Array('period_date_from', 'period_date_to', 'report_period');
193
+ var paramURL = '';
194
+ var switchURL = '<?php echo $this->getAbsoluteGridUrl(array('_current' => false)); ?>'.replace(/(store|group|website)\/\d+\//,'');
195
+
196
+ for(var i=0;i<formParam.length;i++){
197
+ if ($(formParam[i]).value && $(formParam[i]).name) {
198
+ paramURL+= $(formParam[i]).name + '=' + escape($(formParam[i]).value) + '&';
199
+ }
200
+ }
201
+ setLocation(switchURL + storeParam + '?' + paramURL);
202
+ }
203
+ //]]>
204
+ </script>
205
+ <?php endif; ?>
206
+ <?php endif; ?>
app/design/adminhtml/default/default/template/magentokey/newsletter/subscriber/index.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magenotkey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ ?>
8
+ <div class="content-header">
9
+ <table cellspacing="0">
10
+ <tr>
11
+ <td style="width:50%;"><h3 class="icon-head head-newsletter-list"><?php echo $this->getHeaderText() ?></h3></td>
12
+ </tr>
13
+ </table>
14
+ </div>
15
+ <div>
16
+ <?php echo $this->getChildHtml('grid') ?>
17
+ </div>
app/design/adminhtml/default/default/template/magentokey/newsletter/template/edit.phtml ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magenotkey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ ?>
8
+ <div class="content-header">
9
+ <h3 class="icon-head head-message-list"><?php echo $this->getHeaderText() ?></h3>
10
+ <p class="content-buttons form-buttons">
11
+ <?php echo $this->getBackButtonHtml(); ?>
12
+ <?php echo $this->getResetButtonHtml(); ?>
13
+ <?php if(!$this->isTextType()): ?>
14
+ <?php echo $this->getToPlainButtonHtml(); ?>
15
+ <?php echo $this->getToHtmlButtonHtml(); ?>
16
+ <?php endif ?>
17
+ <?php echo $this->getPreviewButtonHtml(); ?>
18
+ <?php if($this->getEditMode()): ?>
19
+ <?php echo $this->getDeleteButtonHtml(); ?>
20
+ <?php endif ?>
21
+ <?php echo $this->getSaveButtonHtml(); ?>
22
+ </p>
23
+ </div>
24
+ <form action="<?php echo $this->getSaveUrl() ?>" method="post" id="newsletter_template_edit_form">
25
+ <?php echo $this->getBlockHtml('formkey')?>
26
+ <div class="no-display">
27
+ <input type="hidden" id="change_flag_element" name="_change_type_flag" value="" />
28
+ </div>
29
+
30
+ <div class="entry-edit">
31
+ <div class="entry-edit-head">
32
+ <h4 class="icon-head head-edit-form fieldset-legend"><?php echo $this->getSubHeaderText(); ?></h4>
33
+ <div class="form-buttons"></div>
34
+ </div>
35
+ <?php if ($this->isLevel()): ?>
36
+ <?php echo $this->getChildHtml('subgrid'); ?>
37
+ <?php else: ?>
38
+ <div class="fieldset fieldset-wide">
39
+ <div class="hor-scroll">
40
+ <table class="form-list">
41
+ <tr>
42
+ <td class="label"><label><?php echo $this->getFieldHeadLabel(); ?></label></td>
43
+ <td class="value"><?php echo $this->getFieldHeadText(); ?></td>
44
+ </tr>
45
+ </table>
46
+ </div>
47
+ </div>
48
+ <?php endif; ?>
49
+ </div>
50
+
51
+
52
+ <?php echo $this->getForm() ?>
53
+ </form>
54
+
55
+ <form action="<?php echo $this->getPreviewUrl() ?>" method="post" id="newsletter_template_preview_form" target="_blank">
56
+ <?php echo $this->getBlockHtml('formkey')?>
57
+ <div class="no-display">
58
+ <input type="hidden" id="preview_type" name="type" value="<?php echo $this->isTextType()?1:2 ?>" />
59
+ <input type="hidden" id="preview_text" name="text" value="" />
60
+ <input type="hidden" id="preview_styles" name="styles" value="" />
61
+ <input type="hidden" id="preview_id" name="id" value="" />
62
+ <?php if($this->isLevel()): ?>
63
+ <?php if($this->isCategoryLevel()): ?>
64
+ <input type="hidden" id="preview_category_id" name="preview_category_id" value="" />
65
+ <?php else: ?>
66
+ <input type="hidden" id="preview_product_id" name="preview_product_id" value="" />
67
+ <?php endif; ?>
68
+ <?php endif; ?>
69
+ </div>
70
+ </form>
71
+
72
+ <script type="text/javascript">
73
+ //<![CDATA[
74
+ var templateForm = new varienForm('newsletter_template_edit_form');
75
+ var templatePreviewForm = new varienForm('newsletter_template_preview_form');
76
+ var templateControl = {
77
+
78
+ unconvertedText: '',
79
+ typeChange: false,
80
+ templateName: false,
81
+ id: 'text',
82
+
83
+ init: function () {
84
+ if ($('convert_button_back')) {
85
+ $('convert_button_back').hide();
86
+ }
87
+ },
88
+
89
+ stripTags: function () {
90
+ if(!window.confirm("<?php echo Mage::helper('magentokey_newsletter')->__('Are you sure that you want to strip all tags?') ?>")) {
91
+ return false;
92
+ }
93
+ if(this.isEditor()) {
94
+ this.getEditor().turnOff();
95
+ this.getEditor().getToggleButton().hide();
96
+ }
97
+ this.unconvertedText = $(this.id).value;
98
+ $('convert_button').hide();
99
+ $('convert_button_back').show();
100
+ $(this.id).value = $(this.id).value.stripScripts().stripTags();
101
+ $('field_template_styles').hide();
102
+ this.typeChange = true;
103
+ return false;
104
+ },
105
+
106
+ unStripTags: function () {
107
+ $('convert_button').show();
108
+ $('convert_button_back').hide();
109
+ $(this.id).value = this.unconvertedText;
110
+ if(this.isEditor()) {
111
+ this.getEditor().turnOn();
112
+ this.getEditor().getToggleButton().show();
113
+ }
114
+ this.typeChange = false;
115
+ $('field_template_styles').show();
116
+ return false;
117
+ },
118
+
119
+ save: function() {
120
+ if (this.typeChange) {
121
+ $('change_flag_element').value = '1';
122
+ }
123
+ if(this.isEditor()) {
124
+ tinyMCE.triggerSave();
125
+ }
126
+ <?php if($this->isLevel()): ?>
127
+ if ($$('input.massaction-checkbox:checked').length==0) {
128
+ var levelCategory = <?php echo $this->isCategoryLevel(); ?>;
129
+ if(levelCategory) {
130
+ alert('<?php echo Mage::helper('magentokey_newsletter')->__('Please select category(s).') ?>')
131
+ } else {
132
+ alert('<?php echo Mage::helper('magentokey_newsletter')->__('Please select product(s).') ?>')
133
+ }
134
+
135
+ return false;
136
+ }
137
+ <?php endif; ?>
138
+ templateForm.submit();
139
+ return false;
140
+ },
141
+ preview: function() {
142
+ if (this.typeChange) {
143
+ $('preview_type').value = 1;
144
+ } else {
145
+ $('preview_type').value = 2;
146
+ }
147
+ if (this.isEditor() && tinyMCE.get(this.id)) {
148
+ tinyMCE.triggerSave();
149
+ $('preview_text').value = $(this.id).value;
150
+ tinyMCE.triggerSave();
151
+ } else {
152
+ $('preview_text').value = $(this.id).value;
153
+ }
154
+ if ($('template_styles') != undefined) {
155
+ $('preview_styles').value = $('template_styles').value;
156
+ }
157
+ if ($('id') != undefined) {
158
+ $('preview_id').value = $('id').value;
159
+ }
160
+ <?php if($this->isLevel()): ?>
161
+ if ($$('input.massaction-checkbox:checked').length==0) {
162
+ var levelCategory = <?php echo $this->isCategoryLevel(); ?>;
163
+ if(levelCategory) {
164
+ alert('<?php echo Mage::helper('magentokey_newsletter')->__('Please select category(s).') ?>')
165
+ } else {
166
+ alert('<?php echo Mage::helper('magentokey_newsletter')->__('Please select product(s).') ?>')
167
+ }
168
+
169
+ return false;
170
+ } else {
171
+ var levelCategory = <?php echo $this->isCategoryLevel(); ?>;
172
+ if(levelCategory) {
173
+ $('preview_category_id').value = $$('input.massaction-checkbox:checked').first().value;
174
+ } else {
175
+ $('preview_product_id').value = $$('input.massaction-checkbox:checked').first().value;
176
+ }
177
+ }
178
+ <?php endif; ?>
179
+ templatePreviewForm.submit();
180
+ return false;
181
+ },
182
+
183
+ deleteTemplate: function() {
184
+ if(window.confirm("<?php echo Mage::helper('magentokey_newsletter')->__('Are you sure that you want to delete this template?') ?>")) {
185
+ window.location.href = '<?php echo $this->getDeleteUrl() ?>';
186
+ }
187
+ },
188
+
189
+ isEditor: function() {
190
+ return (typeof tinyMceEditors != 'undefined' && tinyMceEditors.get(this.id) != undefined)
191
+ },
192
+
193
+ getEditor: function() {
194
+ return tinyMceEditors.get(this.id);
195
+ }
196
+ };
197
+
198
+ templateControl.init();
199
+ templateControl.templateName = "<?php echo $this->getJsTemplateName() ?>";
200
+ //]]>
201
+ </script>
app/design/adminhtml/default/default/template/magentokey/newsletter/template/list.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magenotkey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ ?>
8
+ <div class="content-header">
9
+ <table cellspacing="0">
10
+ <tr>
11
+ <td style="width:50%;"><h3 class="icon-head head-newsletter-list"><?php echo $this->getHeaderText() ?></h3></td>
12
+ <td class="form-buttons">
13
+ <button class="scalable add" onclick="window.location='<?php echo $this->getCategoryCreateUrl() ?>'"><span><?php echo Mage::helper('magentokey_newsletter')->__('Add New Template [category]'); ?></span></button>
14
+ <button class="scalable add" onclick="window.location='<?php echo $this->getProductCreateUrl() ?>'"><span><?php echo Mage::helper('magentokey_newsletter')->__('Add New Template [product]'); ?></span></button>
15
+ </td>
16
+ </tr>
17
+ </table>
18
+ </div>
19
+ <div>
20
+ <?php echo $this->getChildHtml('grid') ?>
21
+ </div>
app/design/adminhtml/default/default/template/magentokey/newsletter/template/preview.phtml ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magenotkey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ ?>
8
+ <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
9
+ <html lang="en">
10
+ <head>
11
+ <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
12
+ <title><?php echo Mage::helper('magentokey_newsletter')->__('Magentokey Newsletter Preview'); ?></title>
13
+ </head>
14
+
15
+ <?php $data = $this->getFormData(); ?>
16
+ <?php if($data['styles']):
17
+ $html = "<style type=\"text/css\">\n%s\n</style>";
18
+ echo sprintf($html, $data['styles']);
19
+ endif; ?>
20
+ <body>
21
+ <?php echo $this->getChildHtml('content') ?>
22
+ <?php echo $this->getChildHtml('profiler') ?>
23
+ </body>
24
+ </html>
app/design/adminhtml/default/default/template/magentokey/newsletter/widget/grid.phtml ADDED
@@ -0,0 +1,201 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magenotkey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ ?>
8
+ <?php
9
+ $numColumns = sizeof($this->getColumns());
10
+ ?>
11
+ <?php if($this->getCollection()): ?>
12
+ <?php if($this->canDisplayContainer()): ?>
13
+ <?php if($this->getGridHeader()): ?>
14
+ <div class="content-header">
15
+ <table cellspacing="0">
16
+ <tr>
17
+ <td style="width:50%;"><h2><?php echo $this->getGridHeader(); ?></h2></td>
18
+ </tr>
19
+ </table>
20
+ </div>
21
+ <?php endif ?>
22
+
23
+ <div id="<?php echo $this->getId() ?>">
24
+ <?php else: ?>
25
+ <?php echo $this->getMessagesBlock()->getGroupedHtml() ?>
26
+ <?php endif; ?>
27
+ <?php if($this->getPagerVisibility() || $this->getExportTypes() || $this->getFilterVisibility()): ?>
28
+ <table cellspacing="0" class="actions">
29
+ <tr>
30
+ <?php if($this->getPagerVisibility()): ?>
31
+ <td class="pager">
32
+ <?php echo $this->__('Page') ?>
33
+
34
+ <?php $_curPage = $this->getCollection()->getCurPage() ?>
35
+ <?php $_lastPage = $this->getCollection()->getLastPageNumber() ?>
36
+ <?php if($_curPage>1): ?>
37
+ <a href="#" title="<?php echo $this->__('Previous page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage-1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_left.gif') ?>" alt="Go to Previous page" class="arrow"/></a>
38
+ <?php else: ?>
39
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_left_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
40
+ <?php endif; ?>
41
+
42
+ <input type="text" name="<?php echo $this->getVarNamePage() ?>" value="<?php echo $_curPage ?>" class="input-text page" onkeypress="<?php echo $this->getJsObjectName() ?>.inputPage(event, '<?php echo $_lastPage ?>')"/>
43
+
44
+ <?php if($_curPage < $_lastPage): ?>
45
+ <a href="#" title="<?php echo $this->__('Next page') ?>" onclick="<?php echo $this->getJsObjectName() ?>.setPage('<?php echo ($_curPage+1) ?>');return false;"><img src="<?php echo $this->getSkinUrl('images/pager_arrow_right.gif') ?>" alt="Go to Next page" class="arrow"/></a>
46
+ <?php else: ?>
47
+ <img src="<?php echo $this->getSkinUrl('images/pager_arrow_right_off.gif') ?>" alt="Go to Previous page" class="arrow"/>
48
+ <?php endif; ?>
49
+
50
+ <?php echo $this->__('of %s pages', $this->getCollection()->getLastPageNumber()) ?>
51
+ <span class="separator">|</span>
52
+ <?php echo $this->__('View') ?>
53
+ <select name="<?php echo $this->getVarNameLimit() ?>" onchange="<?php echo $this->getJsObjectName() ?>.loadByElement(this)">
54
+ <option value="20"<?php if($this->getCollection()->getPageSize()==20): ?> selected="selected"<?php endif; ?>>20</option>
55
+ <option value="30"<?php if($this->getCollection()->getPageSize()==30): ?> selected="selected"<?php endif; ?>>30</option>
56
+ <option value="50"<?php if($this->getCollection()->getPageSize()==50): ?> selected="selected"<?php endif; ?>>50</option>
57
+ <option value="100"<?php if($this->getCollection()->getPageSize()==100): ?> selected="selected"<?php endif; ?>>100</option>
58
+ <option value="200"<?php if($this->getCollection()->getPageSize()==200): ?> selected="selected"<?php endif; ?>>200</option>
59
+ </select>
60
+ <?php echo $this->__('per page') ?><span class="separator">|</span>
61
+ <?php echo $this->__('Total %d records found', $this->getCollection()->getSize()) ?>
62
+ <span id="<?php echo $this->getHtmlId() ?>-total-count" class="no-display"><?php echo $this->getCollection()->getSize() ?></span>
63
+ <?php if($this->getRssLists()): ?>
64
+ <?php foreach ($this->getRssLists() as $_rss): ?>
65
+ <span class="separator">|</span><a href="<?php echo $_rss->getUrl() ?>" class="link-feed"><?php echo $_rss->getLabel() ?></a>
66
+ <?php endforeach ?>
67
+ <?php endif; ?>
68
+ </td>
69
+ <?php endif ?>
70
+ <?php if($this->getExportTypes()): ?>
71
+ <td class="export a-right">
72
+ <img src="<?php echo $this->getSkinUrl('images/icon_export.gif') ?>" alt="" class="v-middle"/>&nbsp; <?php echo $this->__('Export to:') ?>
73
+ <select name="<?php echo $this->getId() ?>_export" id="<?php echo $this->getId() ?>_export" style="width:8em;">
74
+ <?php foreach ($this->getExportTypes() as $_type): ?>
75
+ <option value="<?php echo $_type->getUrl() ?>"><?php echo $_type->getLabel() ?></option>
76
+ <?php endforeach; ?>
77
+ </select>
78
+ <?php echo $this->getExportButtonHtml() ?>
79
+ </td>
80
+ <?php endif; ?>
81
+ <td class="filter-actions a-right">
82
+ <?php echo $this->getMainButtonsHtml() ?>
83
+ </td>
84
+ </tr>
85
+ </table>
86
+ <?php endif; ?>
87
+ <?php if($this->getMassactionBlock()->isAvailable()): ?>
88
+ <?php echo $this->getMassactionBlockHtml() ?>
89
+ <?php endif ?>
90
+ <div class="grid">
91
+ <div class="hor-scroll">
92
+ <table cellspacing="0" class="data" id="<?php echo $this->getId() ?>_table">
93
+ <?php foreach ($this->getColumns() as $_column): ?>
94
+ <col <?php echo $_column->getHtmlProperty() ?> />
95
+ <?php endforeach; ?>
96
+ <?php if ($this->getHeadersVisibility() || $this->getFilterVisibility()): ?>
97
+ <thead>
98
+ <?php if ($this->getHeadersVisibility()): ?>
99
+ <tr class="headings">
100
+ <?php foreach ($this->getColumns() as $_column): ?>
101
+ <th<?php echo $_column->getHeaderHtmlProperty() ?>><span class="nobr"><?php echo $_column->getHeaderHtml() ?></span></th>
102
+ <?php endforeach; ?>
103
+ </tr>
104
+ <?php endif; ?>
105
+ <?php if ($this->getFilterVisibility()): ?>
106
+ <tr class="filter">
107
+ <?php $i=0;foreach ($this->getColumns() as $_column): ?>
108
+ <th <?php if($i==0): ?>style="width:80px;"<?php else: ?><?php echo $_column->getHeaderHtmlProperty() ?><?php endif; ?>><?php if($i!=0): ?><?php echo $_column->getFilterHtml() ?><?php else: ?><?php //echo $this->__('Please Select Item(s)'); ?><?php endif; ?></th>
109
+ <?php $i++ ?>
110
+ <?php endforeach; ?>
111
+ </tr>
112
+ <?php endif ?>
113
+ </thead>
114
+ <?php endif; ?>
115
+ <?php if ($this->getCountTotals()): ?>
116
+ <tfoot>
117
+ <tr class="totals">
118
+ <?php foreach ($this->getColumns() as $_column): ?>
119
+ <th class="<?php echo $_column->getCssProperty() ?>"><?php echo ($_column->hasTotalsLabel()) ? $_column->getTotalsLabel() : $_column->getRowField($_column->getGrid()->getTotals()) ?>&nbsp;</th>
120
+ <?php endforeach; ?>
121
+ </tr>
122
+ </tfoot>
123
+ <?php endif; ?>
124
+
125
+ <tbody>
126
+ <?php if (($this->getCollection()->getSize()>0) && (!$this->getIsCollapsed())): ?>
127
+ <?php foreach ($this->getCollection() as $_index=>$_item): ?>
128
+ <tr title="<?php echo $this->getRowUrl($_item) ?>"<?php if ($_class = $this->getRowClass($_item)):?> class="<?php echo $_class; ?>"<?php endif;?> >
129
+ <?php $i=0;foreach ($this->getColumns() as $_column): ?>
130
+
131
+ <?php if ($this->shouldRenderCell($_item, $_column)):?>
132
+ <?php $_rowspan = $this->getRowspan($_item, $_column);?>
133
+ <td <?php echo ($_rowspan ? 'rowspan="' . $_rowspan . '" ' : '') ?>class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i==$numColumns?'last':'' ?>">
134
+ <?php echo (($_html = $_column->getRowField($_item)) != '' ? $_html : '&nbsp;') ?>
135
+ </td>
136
+ <?php if ($this->shouldRenderEmptyCell($_item, $_column)):?>
137
+ <td colspan="<?php echo $this->getEmptyCellColspan($_item)?>" class="last"><?php echo $this->getEmptyCellLabel()?></td>
138
+ <?php endif;?>
139
+ <?php endif;?>
140
+
141
+ <?php endforeach; ?>
142
+ </tr>
143
+ <?php if ($_multipleRows = $this->getMultipleRows($_item)):?>
144
+ <?php foreach ($_multipleRows as $_i):?>
145
+ <tr>
146
+ <?php $i=0;foreach ($this->getMultipleRowColumns($_i) as $_column): ?>
147
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i==$numColumns-1?'last':'' ?>">
148
+ <?php echo (($_html = $_column->getRowField($_i)) != '' ? $_html : '&nbsp;') ?>
149
+ </td>
150
+ <?php endforeach; ?>
151
+ </tr>
152
+ <?php endforeach;?>
153
+ <?php endif;?>
154
+
155
+ <?php if ($this->shouldRenderSubTotal($_item)): ?>
156
+ <tr class="subtotals">
157
+ <?php $i = 0; foreach ($this->getSubTotalColumns() as $_column): ?>
158
+ <td class="<?php echo $_column->getCssProperty() ?> <?php echo ++$i == $numColumns ? 'last' : '' ?>">
159
+ <?php echo ($_column->hasSubtotalsLabel() ? $_column->getSubtotalsLabel() :
160
+ $_column->getRowField($this->getSubTotalItem($_item))
161
+ );
162
+ ?>
163
+ </td>
164
+ <?php endforeach; ?>
165
+ </tr>
166
+ <?php endif; ?>
167
+ <?php endforeach; ?>
168
+ <?php elseif ($this->getEmptyText()): ?>
169
+ <tr>
170
+ <td class="empty-text <?php echo $this->getEmptyTextClass() ?>" colspan="<?php echo $numColumns ?>"><?php echo $this->getEmptyText() ?></td>
171
+ </tr>
172
+ <?php endif; ?>
173
+ </tbody>
174
+
175
+ </table>
176
+ </div>
177
+ </div>
178
+ <?php if($this->canDisplayContainer()): ?>
179
+ </div>
180
+ <script type="text/javascript">
181
+ //<![CDATA[
182
+ <?php echo $this->getJsObjectName() ?> = new varienGrid('<?php echo $this->getId() ?>', '<?php echo $this->getGridUrl() ?>', '<?php echo $this->getVarNamePage() ?>', '<?php echo $this->getVarNameSort() ?>', '<?php echo $this->getVarNameDir() ?>', '<?php echo $this->getVarNameFilter() ?>');
183
+ <?php echo $this->getJsObjectName() ?>.useAjax = '<?php echo $this->getUseAjax() ?>';
184
+ <?php if($this->getRowClickCallback()): ?>
185
+ <?php echo $this->getJsObjectName() ?>.rowClickCallback = <?php echo $this->getRowClickCallback() ?>;
186
+ <?php endif; ?>
187
+ <?php if($this->getCheckboxCheckCallback()): ?>
188
+ <?php echo $this->getJsObjectName() ?>.checkboxCheckCallback = <?php echo $this->getCheckboxCheckCallback() ?>;
189
+ <?php endif; ?>
190
+ <?php if($this->getRowInitCallback()): ?>
191
+ <?php echo $this->getJsObjectName() ?>.initRowCallback = <?php echo $this->getRowInitCallback() ?>;
192
+ <?php echo $this->getJsObjectName() ?>.initGridRows();
193
+ <?php endif; ?>
194
+ <?php if($this->getMassactionBlock()->isAvailable()): ?>
195
+ <?php echo $this->getMassactionBlock()->getJavaScript() ?>
196
+ <?php endif ?>
197
+ <?php echo $this->getAdditionalJavaScript(); ?>
198
+ //]]>
199
+ </script>
200
+ <?php endif; ?>
201
+ <?php endif ?>
app/design/adminhtml/default/default/template/magentokey/newsletter/widget/grid/massaction.phtml ADDED
@@ -0,0 +1,63 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.magenotkey.com, http://www.hifasion.org)
5
+ * @version 1.0.0
6
+ */
7
+ ?>
8
+ <div id="<?php echo $this->getHtmlId() ?>">
9
+ <table cellspacing="0" cellpadding="0" class="massaction">
10
+ <tr>
11
+ <td><?php if ($this->getUseSelectAll()):?>
12
+ <a href="#" onclick="return <?php echo $this->getJsObjectName() ?>.selectAll()"><?php echo $this->__('Select All') ?></a>
13
+ <span class="separator">|</span>
14
+ <a href="#" onclick="return <?php echo $this->getJsObjectName() ?>.unselectAll()"><?php echo $this->__('Unselect All') ?></a>
15
+ <span class="separator">|</span>
16
+ <?php endif; ?>
17
+ <a href="#" onclick="return <?php echo $this->getJsObjectName() ?>.selectVisible()"><?php echo $this->__('Select Visible') ?></a>
18
+ <span class="separator">|</span>
19
+ <a href="#" onclick="return <?php echo $this->getJsObjectName() ?>.unselectVisible()"><?php echo $this->__('Unselect Visible') ?></a>
20
+ <span class="separator">|</span>
21
+ <strong id="<?php echo $this->getHtmlId() ?>-count">0</strong> <?php echo $this->__('items selected') ?>
22
+ </td>
23
+ <td>
24
+ <div class="right">
25
+ <div class="entry-edit">
26
+ <form action="" id="<?php echo $this->getHtmlId() ?>-form" method="post">
27
+ <?php echo $this->getBlockHtml('formkey')?>
28
+ <fieldset style="display:none;">
29
+ <span class="field-row">
30
+ <label><?php echo $this->__('Actions') ?></label>
31
+ <select id="<?php echo $this->getHtmlId() ?>-select" class="required-entry select absolute-advice local-validation">
32
+ <option value=""></option>
33
+ <?php foreach($this->getItems() as $_item): ?>
34
+ <option value="<?php echo $_item->getId() ?>"<?php echo ($_item->getSelected() ? ' selected="selected"' : '')?>><?php echo $_item->getLabel() ?></option>
35
+ <?php endforeach; ?>
36
+ </select>
37
+ </span>
38
+ <span class="outer-span" id="<?php echo $this->getHtmlId() ?>-form-hiddens"></span>
39
+ <span class="outer-span" id="<?php echo $this->getHtmlId() ?>-form-additional"></span>
40
+ <span class="field-row">
41
+ <?php echo $this->getApplyButtonHtml() ?>
42
+ </span>
43
+ </fieldset>
44
+ </form>
45
+ </div>
46
+
47
+ <div class="no-display">
48
+ <?php foreach($this->getItems() as $_item): ?>
49
+ <div id="<?php echo $this->getHtmlId() ?>-item-<?php echo $_item->getId() ?>-block">
50
+ <?php echo $_item->getAdditionalActionBlockHtml() ?>
51
+ </div>
52
+ <?php endforeach; ?>
53
+ </div>
54
+ </div>
55
+ </td>
56
+ </tr>
57
+ </table>
58
+ <?php if(!$this->getParentBlock()->canDisplayContainer()): ?>
59
+ <script type="text/javascript">
60
+ <?php echo $this->getJsObjectName() ?>.setGridIds('<?php echo $this->getGridIdsJson() ?>');
61
+ </script>
62
+ <?php endif; ?>
63
+ </div>
app/design/frontend/default/default/layout/magentokey_newsletter.xml ADDED
@@ -0,0 +1,62 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <!--
3
+ /**
4
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
5
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
6
+ * @version 1.1.0
7
+ */
8
+ -->
9
+ <layout>
10
+ <catalog_product_view translate="label">
11
+ <reference name="product.info">
12
+ <block type="magentokey_newsletter/link" name="newsletter_product_js" as="newsletter_product_js" template="magentokey/newsletter/js.phtml"/>
13
+ <block type="magentokey_newsletter/link" name="newsletter_product_price" as="newsletter_product_price" template="magentokey/newsletter/price.phtml"/>
14
+ <block type="magentokey_newsletter/link" name="newsletter_product_stock" as="newsletter_product_stock" template="magentokey/newsletter/stock.phtml"/>
15
+ <block type="magentokey_newsletter/link" name="newsletter_product_update" as="newsletter_product_update" template="magentokey/newsletter/update.phtml"/>
16
+ </reference>
17
+ </catalog_product_view>
18
+ <catalog_category_default translate="label">
19
+ <reference name="breadcrumbs">
20
+ <block type="magentokey_newsletter/link" name="newsletter_category_js" as="newsletter_category_js" template="magentokey/newsletter/js_clone.phtml"/>
21
+ <block type="magentokey_newsletter/link" name="newsletter_category_new" as="newsletter_category_new" template="magentokey/newsletter/category_new.phtml"/>
22
+ <block type="magentokey_newsletter/link" name="newsletter_category_price" as="newsletter_category_price" template="magentokey/newsletter/category_price.phtml"/>
23
+ </reference>
24
+ </catalog_category_default>
25
+ <catalog_category_layered translate="label">
26
+ <reference name="breadcrumbs">
27
+ <block type="magentokey_newsletter/link" name="newsletter_category_js" as="newsletter_category_js" template="magentokey/newsletter/js_clone.phtml"/>
28
+ <block type="magentokey_newsletter/link" name="newsletter_category_new" as="newsletter_category_new" template="magentokey/newsletter/category_new.phtml"/>
29
+ <block type="magentokey_newsletter/link" name="newsletter_category_price" as="newsletter_category_price" template="magentokey/newsletter/category_price.phtml"/>
30
+ </reference>
31
+ </catalog_category_layered>
32
+ <magentokey_newsletter_subscribe_index translate="label">
33
+ <remove name="header"/>
34
+ <remove name="footer"/>
35
+ <remove name="right"/>
36
+ <remove name="left"/>
37
+
38
+ <reference name="root">
39
+ <action method="setTemplate"><template>magentokey/newsletter/page.phtml</template></action>
40
+ <block type="core/html_calendar" name="calendar" as="calendar" template="page/js/calendar.phtml" />
41
+ <block type="core/text_list" name="content" as="content"/>
42
+ </reference>
43
+ <reference name="content">
44
+ <block type="magentokey_newsletter/link" name="newsletter_product_form" as="newsletter_product_form" template="magentokey/newsletter/form_clone.phtml"/>
45
+ </reference>
46
+ </magentokey_newsletter_subscribe_index>
47
+ <magentokey_newsletter_subscribe_add>
48
+ <remove name="header"/>
49
+ <remove name="footer"/>
50
+ <remove name="right"/>
51
+ <remove name="left"/>
52
+
53
+ <reference name="root">
54
+ <action method="setTemplate"><template>magentokey/newsletter/popup.phtml</template></action>
55
+ <block type="core/text_list" name="content" as="content"/>
56
+ <!---->
57
+ </reference>
58
+ <reference name="content">
59
+ <block type="magentokey_newsletter/link" name="newsletter_product_form" as="newsletter_product_form" template="magentokey/newsletter/form.phtml"/>
60
+ </reference>
61
+ </magentokey_newsletter_subscribe_add>
62
+ </layout>
app/design/frontend/default/default/template/magentokey/newsletter/category_new.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
5
+ * @version 1.1.0
6
+ */
7
+ ?>
8
+ <?php if($this->isCategoryAvailable()): ?>
9
+ <?php $category = $this->getCategory(); ?>
10
+ <?php if($this->isCategoryPopUp()): ?>
11
+ <a id="magentokey_newsletter_new" class="magentokey_newsletter_links" href="javascript:void(0)" onclick="MagentokeyDialogUtility.openDialog('<?php echo $this->getCategoryPopNewUrl($category->getId()); ?>',520,380,'<?php echo $this->__('New products notification'); ?>')"><?php echo $this->__('New products notification') ?></a>
12
+ <?php else: ?>
13
+ <a id="magentokey_newsletter_new" class="magentokey_newsletter_links" href="<?php echo $this->getCategoryNewUrl($category->getId()); ?>"><?php echo $this->__('New products notification') ?></a>
14
+ <?php endif; ?>
15
+ <?php endif; ?>
app/design/frontend/default/default/template/magentokey/newsletter/category_price.phtml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
5
+ * @version 1.1.0
6
+ */
7
+ ?>
8
+ <?php if($this->isCategoryAvailable()): ?>
9
+ <?php $category = $this->getCategory(); ?>
10
+ <?php if($this->isCategoryPopUp()): ?>
11
+ <a id="magentokey_newsletter_new" class="magentokey_newsletter_links" href="javascript:void(0)" onclick="MagentokeyDialogUtility.openDialog('<?php echo $this->getCategoryPopPriceUrl($category->getId()); ?>',520,380,'<?php echo $this->__('Products price reduction notification'); ?>')"><?php echo $this->__('Products price reduction notification') ?></a>
12
+ <?php else: ?>
13
+ <a id="magentokey_newsletter_new" class="magentokey_newsletter_links" href="<?php echo $this->getCategoryPriceUrl($category->getId()); ?>"><?php echo $this->__('Products price reduction notification') ?></a>
14
+ <?php endif; ?>
15
+ <?php endif; ?>
app/design/frontend/default/default/template/magentokey/newsletter/form.phtml ADDED
@@ -0,0 +1,135 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
5
+ * @version 1.1.0
6
+ */
7
+ ?>
8
+ <link href="<?php echo $this->getSkinUrl('css/magentokey/popup/newsletter.css'); ?>" type="text/css" rel="stylesheet">
9
+ <div id="magentokey_newsletter_container">
10
+ <div class="tBar">
11
+ <p><?php echo $this->getTitle(); ?></p>
12
+ </div>
13
+ <div class="form-box" id="form-box">
14
+ <form id="magentokey_newsletter_form" name="magentokey_newsletter_form" onsubmit="return false;">
15
+ <div class="no-display">
16
+ <input type="hidden" value="" name="key">
17
+ <input type="hidden" value="<?php echo $this->getCurrentType(); ?>" name="newsletter[type]" />
18
+ <?php if($this->isProduct()):?>
19
+ <?php $_product = $this->getProduct(); ?>
20
+ <input type="hidden" name="newsletter[product_id]" value="<?php echo $_product->getId(); ?>" />
21
+ <?php endif; ?>
22
+ <?php if($this->isCategory()): ?>
23
+ <?php $_category = $this->getCategory(); ?>
24
+ <input type="hidden" name="newsletter[category_id]" value="<?php echo $_category->getId(); ?>" />
25
+ <?php endif; ?>
26
+ <input type="hidden" name="newsletter[customer_id]" value="<?php echo $this->getCustomerId(); ?>" />
27
+ </div>
28
+ <p id="newsletter_subscribe_message" class="message"></p>
29
+ <table width="92%" border="0" align="center">
30
+ <tbody>
31
+ <tr>
32
+ <td width="15%" height="30" align="right"><?php echo Mage::helper('magentokey_newsletter')->__('Email'); ?>:</td>
33
+ <td width="40%" align="left"><div><input type="text" id="email" class="input-text required-entry validate-email" name="newsletter[email]" value="<?php echo $this->getCustomerEmail(); ?>" size="50" maxlength="50" /></div></td>
34
+ <td width="45%"><em style="color:red;padding-left: 4px;">*</em>&nbsp;<div style="color:red; display: inline;font-size: 13px;" id="mail_error"></div></td>
35
+ </tr>
36
+ <?php if($this->isAmountAvailable()): ?>
37
+ <tr>
38
+ <td width="15%" height="30" align="right"><?php echo $this->getAmountTitle(); ?>:</td>
39
+ <td width="40%" align="left"><input class="input-text ipt-price" name="newsletter[amount]" id="magentokey_newsletter_amount"/></td>
40
+ <td width="45%"><label class="n-note"><?php echo $this->__('integer only'); ?></label></td>
41
+ </tr>
42
+ <?php endif; ?>
43
+ <?php if($this->isPopDateEnable()): ?>
44
+ <tr>
45
+ <td width="15%" height="30" align="right"><?php echo $this->__('Days'); ?>:</td>
46
+ <td width="40%" align="left">
47
+ <input class="input-text" name="newsletter[duration]" id="magentokey_newsletter_duration"/>
48
+ </td>
49
+ <td width="45%"><label class="n-note"><?php echo $this->__('1-365'); ?></label></td>
50
+ </tr>
51
+ <?php endif; ?>
52
+ <tr style="line-height: 28px;">
53
+ <td height="20" align="right"></td>
54
+ <td valign="top" align="left" colspan="2"><span style="color:#999;font-size:11px;"><?php echo $this->getNotice(); ?></span></td>
55
+ </tr>
56
+ <tr>
57
+ <td width="15%" height="35" align="right">
58
+ <div id="submit-loading" style="display:none;">
59
+
60
+ </div>
61
+ </td>
62
+ <td height="35" align="left" colspan="2">
63
+ <button class="n-btn" onclick="MagentokeyFormUtility.newsletterSubmit('<?php echo $this->getSubscribeUrl(); ?>')"><?php echo $this->__('Submit'); ?></button>
64
+ </td>
65
+ </tr>
66
+ </tbody>
67
+ </table>
68
+ </form>
69
+ </div>
70
+ </div>
71
+ <script type="text/javascript">
72
+ MagentokeyFormUtility = {
73
+ newsletterSubmit: function(url) {
74
+ var form = $('magentokey_newsletter_form');
75
+ var message = $('newsletter_subscribe_message');
76
+ var valid = MagentokeyFormUtility.checkform();
77
+ if (valid) {
78
+ new Ajax.Request(url, {
79
+ method: 'post',
80
+ parameters: Form.serialize(form),
81
+ onLoading: function(){
82
+ $('submit-loading').show();
83
+ },
84
+ onSuccess: function(transport) {
85
+ if (transport.responseText.isJSON()) {
86
+ $('submit-loading').hide();
87
+ var result = transport.responseText.evalJSON();
88
+ if(result.success) {
89
+ message = $('form-box');
90
+ var back = '<div class="success-back"><?php echo Mage::helper('magentokey_newsletter')->__('The dialog will be closed in ');?><span id="time-left" value="5">5</span><?php echo Mage::helper('magentokey_newsletter')->__(' seconds..'); ?></div>';
91
+ message.update(result.content+back);
92
+ setInterval(function(){ MagentokeyFormUtility.timeLeft() },1000);
93
+ setTimeout(function(){ MagentokeyDialogUtility.closeDialog() },5000);
94
+ } else {
95
+ form.reset()
96
+ var message = $('newsletter_subscribe_message');
97
+ message.update(result.content);
98
+ }
99
+ } else {
100
+ var message = $('newsletter_subscribe_message');
101
+ form.reset()
102
+ message.update(transport.responseText);
103
+ }
104
+ }
105
+ });
106
+ }
107
+ },
108
+ timeLeft: function()
109
+ {
110
+ var left = $('time-left').readAttribute('value');
111
+ //alert(left);
112
+ if (left>0) {
113
+ $('time-left').writeAttribute('value',(left-1));
114
+ $('time-left').update((left-1))
115
+ }
116
+ },
117
+ checkform: function() {
118
+ var email=$('email').value;
119
+ if(email.length==0){
120
+ $("mail_error").update("<?php echo $this->__('invalid email address'); ?>");
121
+ return false;
122
+ }else{
123
+ var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
124
+ if(!reg.test(email))
125
+ {
126
+ $("mail_error").update("<?php echo $this->__('invalid email address'); ?>");
127
+ return false;
128
+ } else {
129
+ $("mail_error").update("");
130
+ }
131
+ }
132
+ return true;
133
+ }
134
+ }
135
+ </script>
app/design/frontend/default/default/template/magentokey/newsletter/form_clone.phtml ADDED
@@ -0,0 +1,177 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
5
+ * @version 1.1.0
6
+ */
7
+ ?>
8
+ <div class="main-wrapper">
9
+ <div class="page-title">
10
+ <h2><?php echo $this->__('NEWSLETTER'); ?></h2>
11
+ <p class="desc"><?php echo $this->__('Sign Up for Our Newsletter'); ?></p>
12
+ </div>
13
+ <div id="newsletter_from" class="c-wrapper">
14
+ <div id="magentokey_newsletter_container" class="inner-wrapper">
15
+ <i class="iconMail"></i>
16
+ <div class="inner">
17
+ <div class="tBar">
18
+ <h2><?php echo $this->getTypeTitle(); ?></h2>
19
+ <p><?php echo $this->getTitle(); ?></p>
20
+ </div>
21
+ <div class="form-box">
22
+ <form id="magentokey_newsletter_form" name="magentokey_newsletter_form" onsubmit="return false;">
23
+ <div class="no-display">
24
+ <input type="hidden" value="" name="key">
25
+ <input type="hidden" value="<?php echo $this->getCurrentType(); ?>" name="newsletter[type]" />
26
+ <?php if($this->isProduct()):?>
27
+ <?php $_product = $this->getProduct(); ?>
28
+ <input type="hidden" name="newsletter[product_id]" value="<?php echo $_product->getId(); ?>" />
29
+ <?php endif; ?>
30
+ <?php if($this->isCategory()): ?>
31
+ <?php $_category = $this->getCategory(); ?>
32
+ <input type="hidden" name="newsletter[category_id]" value="<?php echo $_category->getId(); ?>" />
33
+ <?php endif; ?>
34
+ <input type="hidden" name="newsletter[customer_id]" value="<?php echo $this->getCustomerId(); ?>" />
35
+ </div>
36
+ <p id="newsletter_subscribe_message" class="message"></p>
37
+ <table width="90%" border="0" align="center">
38
+ <tbody>
39
+ <tr>
40
+ <td width="20%" height="30" align="right"><?php echo $this->__('Your email'); ?>:</td>
41
+ <td width="40%" align="left"><div><input type="text" id="email" class="input-text required-entry validate-email" name="newsletter[email]" value="<?php echo $this->getCustomerEmail(); ?>" size="50" maxlength="50" /></div></td>
42
+ <td width="40%"><em style="color:red;">*</em>&nbsp;<div style="color:red; display: inline;" id="mail_error"></div></td>
43
+ </tr>
44
+ <?php if($this->isAmountAvailable()): ?>
45
+ <tr>
46
+ <td width="20%" height="30" align="right"><?php echo $this->getAmountTitle(); ?>:</td>
47
+ <td width="40%" align="left"><input class="input-text ipt-price" name="newsletter[amount]" id="magentokey_newsletter_amount"/></td>
48
+ <td width="40%"><label class="n-note"><?php echo $this->__('integer only'); ?></label></td>
49
+ </tr>
50
+ <?php endif; ?>
51
+ <?php if($this->isPageDateEnable()): ?>
52
+
53
+ <tr>
54
+ <td width="20%" height="30" align="right"><?php echo $this->__('Date from'); ?>:</td>
55
+ <td width="80%" align="left" colspan="2">
56
+ <input name="newsletter[date_from]" id="newsletter_date_from" value="<?php echo $this->getCurrentDate(); ?>" class="input-text" style="width:110px !important;" type="text"> <img src="http://magento1610.com/skin/adminhtml/default/default/images/grid-cal.gif" alt="" class="v-middle" id="newsletter_date_from_trig" title="Select Date" style="">
57
+ <script type="text/javascript">
58
+ //<![CDATA[
59
+ Calendar.setup({
60
+ inputField: "newsletter_date_from",
61
+ ifFormat: "%Y-%m-%d",
62
+ showsTime: false,
63
+ button: "newsletter_date_from_trig",
64
+ align: "Bl",
65
+ singleClick : true
66
+ });
67
+ //]]>
68
+ </script>
69
+ </td>
70
+ </tr>
71
+ <tr>
72
+ <td width="20%" height="30" align="right"><?php echo $this->__('Date to'); ?>:</td>
73
+ <td width="80%" align="left" colspan="2">
74
+ <input name="newsletter[date_to]" id="newsletter_date_to" value="<?php echo $this->getPageDefaultDay(); ?>" class="input-text" style="width:110px !important;" type="text"> <img src="http://magento1610.com/skin/adminhtml/default/default/images/grid-cal.gif" alt="" class="v-middle" id="newsletter_date_to_trig" title="Select Date" style="">
75
+ <script type="text/javascript">
76
+ //<![CDATA[
77
+ Calendar.setup({
78
+ inputField: "newsletter_date_to",
79
+ ifFormat: "%Y-%m-%d",
80
+ showsTime: false,
81
+ button: "newsletter_date_to_trig",
82
+ align: "Bl",
83
+ singleClick : true
84
+ });
85
+ //]]>
86
+ </script>
87
+ </td>
88
+ </tr>
89
+ <?php endif; ?>
90
+ <tr style="line-height: 28px;">
91
+ <td height="20" align="right"></td>
92
+ <td valign="top" align="left" colspan="2"><span style="color:#999;font-size:11px;"><?php echo $this->getNotice(); ?></span></td>
93
+ </tr>
94
+ <tr>
95
+ <td width="20%" height="35" align="right">
96
+ <div id="submit-loading" style="display:none;">
97
+
98
+ </div>
99
+ </td>
100
+ <td height="35" align="left" colspan="2">
101
+ <button class="button" onclick="MagentokeyFormUtility.newsletterSubmit('<?php echo $this->getSubscribeUrl(); ?>')"><span><span><?php echo $this->__('Submit'); ?></span></span></button>
102
+ </td>
103
+ </tr>
104
+ </tbody>
105
+ </table>
106
+ </form>
107
+ </div>
108
+ </div>
109
+ </div>
110
+ </div>
111
+ </div>
112
+
113
+ <script type="text/javascript">
114
+ MagentokeyFormUtility = {
115
+ newsletterSubmit: function(url) {
116
+ var form = $('magentokey_newsletter_form');
117
+ var message = $('newsletter_subscribe_message');
118
+ var valid = MagentokeyFormUtility.checkform();
119
+ if (valid) {
120
+ new Ajax.Request(url, {
121
+ method: 'post',
122
+ parameters: Form.serialize(form),
123
+ onLoading: function(){
124
+ $('submit-loading').show();
125
+ },
126
+ onSuccess: function(transport) {
127
+ $('submit-loading').hide();
128
+ if (transport.responseText.isJSON()) {
129
+ var result = transport.responseText.evalJSON();
130
+ if(result.success) {
131
+ message = $('magentokey_newsletter_container');
132
+ var back = '<div class="success-back"><?php echo Mage::helper('magentokey_newsletter')->__('You will be redirected to previous page in ');?><span id="time-left" value="5">5</span><?php echo Mage::helper('magentokey_newsletter')->__(' seconds..'); ?></div>';
133
+ message.update(result.content+back);
134
+ setInterval(function(){ MagentokeyFormUtility.timeLeft() },1000);
135
+ setTimeout(function(){ location.href = '<?php echo $this->getPreUrl() ?>' },5000);
136
+ } else {
137
+ form.reset()
138
+ var message = $('newsletter_subscribe_message');
139
+ message.update(result.content);
140
+ }
141
+ } else {
142
+ var message = $('newsletter_subscribe_message');
143
+ form.reset()
144
+ message.update(transport.responseText);
145
+ }
146
+ }
147
+ });
148
+ }
149
+ },
150
+ timeLeft: function()
151
+ {
152
+ var left = $('time-left').readAttribute('value');
153
+ //alert(left);
154
+ if (left>0) {
155
+ $('time-left').writeAttribute('value',(left-1));
156
+ $('time-left').update((left-1))
157
+ }
158
+ },
159
+ checkform: function() {
160
+ var email=$('email').value;
161
+ if(email.length==0){
162
+ $("mail_error").update("<?php echo $this->__('invalid email address'); ?>");
163
+ return false;
164
+ }else{
165
+ var reg = /^\w+((-\w+)|(\.\w+))*\@[A-Za-z0-9]+((\.|-)[A-Za-z0-9]+)*\.[A-Za-z0-9]+$/;
166
+ if(!reg.test(email))
167
+ {
168
+ $("mail_error").update("<?php echo $this->__('invalid email address'); ?>");
169
+ return false;
170
+ } else {
171
+ $("mail_error").update("");
172
+ }
173
+ }
174
+ return true;
175
+ }
176
+ }
177
+ </script>
app/design/frontend/default/default/template/magentokey/newsletter/js.phtml ADDED
@@ -0,0 +1,14 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
5
+ * @version 1.1.0
6
+ */
7
+ ?>
8
+ <?php if($this->isProductTypeAvaible()): ?>
9
+ <?php if($this->isProductPopUp()): ?>
10
+ <script type="text/javascript" src="<?php echo $this->getJsUrl('prototype/window.js'); ?>"></script>
11
+ <script type="text/javascript" src="<?php echo $this->getSkinUrl('js/magentokey/MagentokeyUtility.js'); ?>"></script>
12
+ <link href="<?php echo $this->getSkinUrl('css/magentokey/popup/magento.css'); ?>" type="text/css" rel="stylesheet">
13
+ <?php endif; ?>
14
+ <?php endif; ?>
app/design/frontend/default/default/template/magentokey/newsletter/js_clone.phtml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
5
+ * @version 1.1.0
6
+ */
7
+ ?>
8
+ <?php if($this->isCategoryAvailable()): ?>
9
+ <script type="text/javascript" src="<?php echo $this->getJsUrl('prototype/window.js'); ?>"></script>
10
+ <script type="text/javascript" src="<?php echo $this->getSkinUrl('js/magentokey/MagentokeyUtility.js'); ?>"></script>
11
+ <link href="<?php echo $this->getSkinUrl('css/magentokey/popup/magento.css'); ?>" type="text/css" rel="stylesheet">
12
+ <?php endif; ?>
app/design/frontend/default/default/template/magentokey/newsletter/page.phtml ADDED
@@ -0,0 +1,37 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
5
+ * @version 1.1.0
6
+ */
7
+ ?>
8
+ <?php $head = Mage::getBlockSingleton('page/html_head'); ?>
9
+ <head>
10
+ <meta http-equiv="Content-Type" content="<?php echo $head->getContentType() ?>" />
11
+ <title><?php echo $this->getTitle() ?></title>
12
+ <meta name="description" content="<?php echo htmlspecialchars($head->getDescription()) ?>" />
13
+ <meta name="keywords" content="<?php echo htmlspecialchars($head->getKeywords()) ?>" />
14
+ <meta name="robots" content="<?php echo htmlspecialchars($head->getRobots()) ?>" />
15
+ <link rel="icon" href="<?php echo $this->getFaviconFile(); ?>" type="image/x-icon" />
16
+ <link rel="shortcut icon" href="<?php echo $head->getFaviconFile(); ?>" type="image/x-icon" />
17
+ <script type="text/javascript" src="<?php echo $this->getJsUrl('prototype/prototype.js'); ?>"></script>
18
+ <script type="text/javascript" src="<?php echo $this->getJsUrl('prototype/validation.js'); ?>"></script>
19
+ <script type="text/javascript" src="<?php echo $this->getJsUrl('varien/form.js'); ?>"></script>
20
+ <script type="text/javascript" src="<?php echo $this->getJsUrl('calendar/calendar.js'); ?>"></script>
21
+ <script type="text/javascript" src="<?php echo $this->getJsUrl('calendar/calendar-setup.js'); ?>"></script>
22
+ <link href="<?php echo $this->getJsUrl('calendar/calendar-win2k-1.css'); ?>" type="text/css" rel="stylesheet">
23
+ <?php echo $this->getChildHtml('calendar'); ?>
24
+ <link href="<?php echo $this->getSkinUrl('css/magentokey/newsletter.css'); ?>" type="text/css" rel="stylesheet">
25
+ </head>
26
+ <body>
27
+ <div class="magentokey-wrapper">
28
+ <div class="content">
29
+ <div class="logo">
30
+ <h1 id="logo">
31
+ <a title="" href=""><?php ?></a>
32
+ </h1>
33
+ </div>
34
+ <?php echo $this->getChildHtml('content') ?>
35
+ </div>
36
+ </div>
37
+ </div>
app/design/frontend/default/default/template/magentokey/newsletter/popup.phtml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
5
+ * @version 1.1.0
6
+ */
7
+ ?>
8
+ <div class="wrapper-popup">
9
+ <?php echo $this->getChildHtml('content') ?>
10
+ </div>
app/design/frontend/default/default/template/magentokey/newsletter/price.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
5
+ * @version 1.1.0
6
+ */
7
+ ?>
8
+ <?php if($this->isProductTypeAvaible()): ?>
9
+ <?php if($this->isPriceAvailable()): ?>
10
+ <?php $_product = $this->getProduct() ?>
11
+ <?php if($this->isProductPopUp()): ?>
12
+ <a id="magentokey_newsletter_price" class="magentokey_newsletter_links" href="javascript:void(0)" onclick="MagentokeyDialogUtility.openDialog('<?php echo $this->getProductPricePopUrl($_product->getId()); ?>',512,380,'<?php echo $this->__('Price reduction notification'); ?>')"><?php echo $this->__('Price reduction notification') ?></a>
13
+ <?php else: ?>
14
+ <a id="magentokey_newsletter_price" class="magentokey_newsletter_links" href="<?php echo $this->getProductPriceUrl($_product->getId()); ?>"><?php echo $this->__('Price reduction notification') ?></a>
15
+ <?php endif; ?>
16
+ <?php endif; ?>
17
+ <?php endif; ?>
app/design/frontend/default/default/template/magentokey/newsletter/stock.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
5
+ * @version 1.1.0
6
+ */
7
+ ?>
8
+ <?php if($this->isProductTypeAvaible()): ?>
9
+ <?php if($this->isStockAvailable()): ?>
10
+ <?php $_product = $this->getProduct() ?>
11
+ <?php if(!$this->isProductPopUp()): ?>
12
+ <a id="magentokey_newsletter_stock" class="magentokey_newsletter_links" href="javascript:void(0)" onclick="MagentokeyDialogUtility.openDialog('<?php echo $this->getProductStockPopUrl($_product->getId()); ?>',512,380,'<?php echo $this->__('Stock available notification'); ?>')"><?php echo $this->__('Stock available notification') ?></a>
13
+ <?php else: ?>
14
+ <a id="magentokey_newsletter_stock" class="magentokey_newsletter_links" href="<?php echo $this->getProductStockUrl($_product->getId()); ?>"><?php echo $this->__('Stock available notification') ?></a>
15
+ <?php endif; ?>
16
+ <?php endif; ?>
17
+ <?php endif; ?>
app/design/frontend/default/default/template/magentokey/newsletter/update.phtml ADDED
@@ -0,0 +1,17 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
5
+ * @version 1.1.0
6
+ */
7
+ ?>
8
+ <?php if($this->isProductTypeAvaible()): ?>
9
+ <?php if($this->isUpdateAvailable()): ?>
10
+ <?php $_product = $this->getProduct() ?>
11
+ <?php if($this->isProductPopUp()): ?>
12
+ <a id="magentokey_newsletter_update" class="magentokey_newsletter_links" href="javascript:void(0)" onclick="MagentokeyDialogUtility.openDialog('<?php echo $this->getProductUpdatePopUrl($_product->getId()); ?>',512,380,'<?php echo $this->__('Product update notification'); ?>')"><?php echo $this->__('Product update notification') ?></a>
13
+ <?php else: ?>
14
+ <a id="magentokey_newsletter_update" class="magentokey_newsletter_links" href="<?php echo $this->getProductUpdateUrl($_product->getId()); ?>"><?php echo $this->__('Product update notification') ?></a>
15
+ <?php endif; ?>
16
+ <?php endif; ?>
17
+ <?php endif; ?>
app/design/frontend/default/default/template/magentokey/newsletter/widget/default.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
5
+ * @version 1.1.0
6
+ */
7
+ ?>
8
+ <div class="main">
9
+ <?php $product = $this->getProduct(); ?>
10
+ <?php if(is_object($product)): ?>
11
+ <p><a href="<?php echo $product->getProductUrl(); ?>"><img src="<?php echo $product->getImageUrl(); ?>"/></a></p>
12
+ <h1><a href="<?php echo $product->getProductUrl(); ?>"><?php echo $product->getName(); ?></a></h1>
13
+ <?php $productBlock = Mage::getBlockSingleton('catalog/product_view'); ?>
14
+ <p><?php echo $productBlock->getPriceHtml($product); ?></p>
15
+ <h2><?php echo $this->__('Quick Overview') ?></h2>
16
+ <div class="std"><?php echo $product->getShortDescription();?></div>
17
+ <h2><?php echo $this->__('Detail') ?></h2>
18
+ <div class="std"><?php echo $product->getDescription();?></div>
19
+ <div class="product-images"></div>
20
+ <?php endif; ?>
21
+ </div>
app/design/frontend/default/default/template/magentokey/newsletter/widget/new.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
5
+ * @version 1.1.0
6
+ */
7
+ ?>
8
+ <div class="main">
9
+ <?php $product = $this->getProduct(); ?>
10
+ <?php if(is_object($product)): ?>
11
+ <p><a href="<?php echo $product->getProductUrl(); ?>"><img src="<?php echo $product->getImageUrl(); ?>"/></a></p>
12
+ <h1><a href="<?php echo $product->getProductUrl(); ?>"><?php echo $product->getName(); ?></a></h1>
13
+ <?php $productBlock = Mage::getBlockSingleton('catalog/product_view'); ?>
14
+ <p><?php echo $productBlock->getPriceHtml($product); ?></p>
15
+ <h2><?php echo $this->__('Quick Overview') ?></h2>
16
+ <div class="std"><?php echo $product->getShortDescription();?></div>
17
+ <h2><?php echo $this->__('Detail') ?></h2>
18
+ <div class="std"><?php echo $product->getDescription();?></div>
19
+ <div class="product-images"></div>
20
+ <?php endif; ?>
21
+ </div>
app/design/frontend/default/default/template/magentokey/newsletter/widget/price.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
5
+ * @version 1.1.0
6
+ */
7
+ ?>
8
+ <div class="main">
9
+ <?php $product = $this->getProduct(); ?>
10
+ <?php if(is_object($product)): ?>
11
+ <p><a href="<?php echo $product->getProductUrl(); ?>"><img src="<?php echo $product->getImageUrl(); ?>"/></a></p>
12
+ <h1><a href="<?php echo $product->getProductUrl(); ?>"><?php echo $product->getName(); ?></a></h1>
13
+ <?php $productBlock = Mage::getBlockSingleton('catalog/product_view'); ?>
14
+ <p><?php echo $productBlock->getPriceHtml($product); ?></p>
15
+ <h2><?php echo $this->__('Quick Overview') ?></h2>
16
+ <div class="std"><?php echo $product->getShortDescription();?></div>
17
+ <h2><?php echo $this->__('Detail') ?></h2>
18
+ <div class="std"><?php echo $product->getDescription();?></div>
19
+ <div class="product-images"></div>
20
+ <?php endif; ?>
21
+ </div>
app/design/frontend/default/default/template/magentokey/newsletter/widget/stock.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
5
+ * @version 1.1.0
6
+ */
7
+ ?>
8
+ <div class="main">
9
+ <?php $product = $this->getProduct(); ?>
10
+ <?php if(is_object($product)): ?>
11
+ <p><a href="<?php echo $product->getProductUrl(); ?>"><img src="<?php echo $product->getImageUrl(); ?>"/></a></p>
12
+ <h1><a href="<?php echo $product->getProductUrl(); ?>"><?php echo $product->getName(); ?></a>&nbsp;<?php echo $this->__('is available now.');?> </h1>
13
+ <?php $productBlock = Mage::getBlockSingleton('catalog/product_view'); ?>
14
+ <p><?php echo $productBlock->getPriceHtml($product); ?></p>
15
+ <h2><?php echo $this->__('Quick Overview') ?></h2>
16
+ <div class="std"><?php echo $product->getShortDescription();?></div>
17
+ <h2><?php echo $this->__('Detail') ?></h2>
18
+ <div class="std"><?php echo $product->getDescription();?></div>
19
+ <div class="product-images"></div>
20
+ <?php endif; ?>
21
+ </div>
app/design/frontend/default/default/template/magentokey/newsletter/widget/update.phtml ADDED
@@ -0,0 +1,21 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
4
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentokey.com)
5
+ * @version 1.1.0
6
+ */
7
+ ?>
8
+ <div class="main">
9
+ <?php $product = $this->getProduct(); ?>
10
+ <?php if(is_object($product)): ?>
11
+ <p><a href="<?php echo $product->getProductUrl(); ?>"><img src="<?php echo $product->getImageUrl(); ?>"/></a></p>
12
+ <h1><a href="<?php echo $product->getProductUrl(); ?>"><?php echo $product->getName(); ?></a></h1>
13
+ <?php $productBlock = Mage::getBlockSingleton('catalog/product_view'); ?>
14
+ <p><?php echo $productBlock->getPriceHtml($product); ?></p>
15
+ <h2><?php echo $this->__('Quick Overview') ?></h2>
16
+ <div class="std"><?php echo $product->getShortDescription();?></div>
17
+ <h2><?php echo $this->__('Detail') ?></h2>
18
+ <div class="std"><?php echo $product->getDescription();?></div>
19
+ <div class="product-images"></div>
20
+ <?php endif; ?>
21
+ </div>
app/etc/modules/Magentokey_Newsletter.xml ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Magentokey_Newsletter>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ <depends>
8
+ <Mage_Core />
9
+ </depends>
10
+ </Magentokey_Newsletter>
11
+ </modules>
12
+ </config>
package.xml ADDED
@@ -0,0 +1,32 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+ <package>
3
+ <name>advance-product-newsleter</name>
4
+ <version>1.3.0</version>
5
+ <stability>stable</stability>
6
+ <license>GPL</license>
7
+ <channel>community</channel>
8
+ <extends/>
9
+ <summary>Customer can subscribe for product price cut and stock available notification which they very interested </summary>
10
+ <description>Features&#xD;
11
+ &#xD;
12
+ support open subscribe dialog at new page or popup&#xD;
13
+ subscribe duration is availble&#xD;
14
+ subscribe confirmation is available&#xD;
15
+ support product price notification,stock available notification,new product notification&#xD;
16
+ support simple product,virtual product,configurable product&#xD;
17
+ newsletter templates for a special category or product&#xD;
18
+ newsletter templates preview is available&#xD;
19
+ newsletter auto add to sending queue when product price cut or stock status turn to available&#xD;
20
+ newsletter sending queue can be sent manual and by cron job&#xD;
21
+ manual add products to new product newsletter queue&#xD;
22
+ newsletter problem log is available&#xD;
23
+ product newsletter report is availble&#xD;
24
+ </description>
25
+ <notes>Customer can subscribe for product price cut and stock available notification which they very interested </notes>
26
+ <authors><author><name>iifire</name><user>yanggaojiao</user><email>yanggaojiao@qq.com</email></author></authors>
27
+ <date>2012-08-22</date>
28
+ <time>09:04:08</time>
29
+ <contents><target name="magecommunity"><dir name="Magentokey"><dir name="Newsletter"><dir name="Block"><dir name="Adminhtml"><dir name="Newsletter"><dir name="Manage"><file name="Grid.php" hash="12a61886dccdb645954d7c2b283d9e6e"/></dir><file name="Manage.php" hash="bff621f6297be1a9389dd8c365e4eac8"/><dir name="Problem"><file name="Grid.php" hash="67d584a0cd0496d59aa823050a2192af"/></dir><file name="Problem.php" hash="335d66bd446b3513a035c7a4d444d6de"/><dir name="Queue"><dir name="Grid"><dir name="Renderer"><file name="Action.php" hash="80ba3f5bf2efb93c5a8ec7b7916c42f2"/><file name="Name.php" hash="7e6e9a860e5705978ab7e765bb3b2038"/><file name="Type.php" hash="b649e96213972ec2ae27e7aa24306c00"/></dir></dir><file name="Grid.php" hash="4ad7a8b0cea5adb63051d2a396e26d9f"/><dir name="Preview"><file name="Form.php" hash="b37353fd2513cac506514cc70f6737ec"/></dir><file name="Preview.php" hash="8ff312388cff3a9064c3a6e2fe767ee8"/></dir><file name="Queue.php" hash="151cb5a77d721912f99c4a935b1f9dce"/><dir name="Report"><dir name="Categories"><file name="Grid.php" hash="cdad43d73c9eb09637e7e6d250774da7"/></dir><file name="Categories.php" hash="bd6d9d1ff0b1002380870160cacd5792"/><dir name="Category"><file name="Grid.php" hash="fe52f26b390fa60e7bd37079edddd4d2"/></dir><file name="Category.php" hash="4878f88c86c66cee313a18c58916dfc6"/><file name="Grid.php" hash="335c1122142d4f293033656b41cb99aa"/><dir name="Type"><file name="Grid.php" hash="4e2bad13f802654633e2d2c0f39a53bd"/></dir><file name="Type.php" hash="59b525febb53a57f47b9d6dea590e326"/></dir><file name="Report.php" hash="39d0ec05033e738ae65373991ec4108e"/><dir name="Subscriber"><dir name="Grid"><dir name="Filter"><file name="Checkbox.php" hash="a507938b6eee1487ffc8fd925e8b8e0b"/><file name="Website.php" hash="6a919c65df6c1066323a506958f39aa7"/></dir><dir name="Renderer"><file name="Type.php" hash="1fcefcb1e769889daf6ada4d225b4646"/></dir></dir><file name="Grid.php" hash="bf1a6eef23766a602d9ee4fc7c687ffa"/></dir><file name="Subscriber.php" hash="2048c744b79ca30068ee655de88a78c7"/><dir name="Template"><dir name="Edit"><file name="Category.php" hash="d145df3cffd6ca037383491fe7ad33f9"/><file name="Form.php" hash="3db3134f801daa0876ce14b526343c5d"/><file name="Product.php" hash="5822fd96f5c22e046f56a7b71aacced9"/></dir><file name="Edit.php" hash="10f9f9968eef0856efd37a1ead29105a"/><dir name="Grid"><dir name="Renderer"><file name="Action.php" hash="f62f7508aba7290d37289834b835702d"/><file name="Category.php" hash="5efb4601293b4150fd8e401b7e29b75a"/><file name="Product.php" hash="8a661edcb8b77489670e45ed2b92d659"/><file name="Sender.php" hash="0606fe39e8507db2b0f9b56d2c74db40"/><file name="Type.php" hash="29eae5495157e5c2227d99ec433836c1"/></dir></dir><file name="Grid.php" hash="64bcfa8a48ca3369030b1e5b1e000b15"/><dir name="Preview"><file name="Form.php" hash="7ffdb7909f76bd831be98e127dc6fa49"/></dir><file name="Preview.php" hash="c995137612c699d3dc1584cb14e003de"/></dir><file name="Template.php" hash="4840e28606979bf62526e51bdd646676"/></dir></dir><file name="Link.php" hash="e9a6394c695bad2fb3b6ef16971284cb"/><dir name="Widget"><file name="Product.php" hash="8240dc59bda850d9a097faa4a88f6d39"/></dir></dir><dir name="Helper"><file name="Data.php" hash="7674e16e29f9cc8ab6df8b43667006e0"/></dir><dir name="Model"><dir name="Mysql4"><dir name="Problem"><file name="Collection.php" hash="b8fd58b90707d1bb529756251d9e40d8"/></dir><file name="Problem.php" hash="ce72c00339e403f370ae20c4261f1250"/><dir name="Queue"><file name="Collection.php" hash="5ae33d022873d5f70c5d7687fc45ab5b"/></dir><file name="Queue.php" hash="d9d043fcb4cb5c32d213e746893e2136"/><dir name="Report"><file name="Categories.php" hash="b7b23b893329041f4e67803fc7c9b07b"/><file name="Category.php" hash="b2a828eaee93d9900303e5c0e87650a5"/><file name="Collection.php" hash="6e3c9e32696b5cc4b394322253042882"/><file name="Type.php" hash="9f084413d12723668d72187df6c44538"/></dir><dir name="Subscriber"><file name="Collection.php" hash="f43ae79c81946dae8aacc1829cf80ddb"/></dir><file name="Subscriber.php" hash="4630f2426b6b6a54c1ee486d027bfe78"/><dir name="Template"><file name="Collection.php" hash="77bae5aec5669312d04e58aecb3e67f7"/></dir><file name="Template.php" hash="5ea00ca267d4d0a6238852ce78612940"/></dir><file name="Observer.php" hash="921e19effb8b63418c2bd974c685465f"/><file name="Problem.php" hash="efc152cd526cc704be8d5145ebfbc05b"/><file name="Queue.php" hash="ff4047b6923d1297c5a3f7f7870e8440"/><file name="Session.php" hash="e76fb29905887b47a7eec23ebd0b7901"/><file name="Subscriber.php" hash="e07652d304989302e5e85ac77cdbd7a4"/><file name="Template.php" hash="92133e53e8146af2cdc6ebf481ccf77c"/></dir><dir name="controllers"><dir name="Adminhtml"><dir name="Productnewsletter"><file name="ManageController.php" hash="e5ceed17800bca47ccd34a23c2965665"/><file name="ProblemController.php" hash="171a12bc67464bd2da00e3bc6e34f764"/><file name="QueueController.php" hash="e2814d50819b9c2f31a9e9b2a8b7bd6d"/><file name="ReportController.php" hash="e5433bd635daa149f81c1fb6cf01fea2"/><file name="SubscriberController.php" hash="b5bffe63eea73015b80b3543f35d3a0f"/><file name="TemplateController.php" hash="95b588885f3bcaea68278dcf21dbb037"/></dir></dir><file name="SubscribeController.php" hash="6bc57c1baf1177751d2eb81c7b6374bd"/></dir><dir name="etc"><file name="adminhtml.xml" hash="6843a57a74bed1c6fed30e1c9754e553"/><file name="config.xml" hash="b49efb21db0d96abcc073a32914ab2d9"/><file name="system.xml" hash="b036f022cec10340374e3968254b9824"/><file name="widget.xml" hash="c85286d23229561c4d0fb9fb7ba545f8"/></dir><dir name="sql"><dir name="magentokey_newsletter_setup"><file name="mysql4-install-1.0.0.php" hash="a2be7a76cce282972e4341481019ff36"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Magentokey_Newsletter.xml" hash="f69dcc33288bb19f7d3a2f01f2146988"/></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="magentokey"><dir name="newsletter"><dir name="manage"><file name="index.phtml" hash="76792a2024dca21a1a5f4e43daa01222"/></dir><dir name="preview"><file name="iframeswitcher.phtml" hash="0b9bb7e11c1d56e430ac479680a7c9ba"/><file name="store.phtml" hash="3de7e582480f885a938f41b7d654bee7"/></dir><dir name="problem"><file name="list.phtml" hash="29de96fac667589b19b07db5fcc60e4f"/></dir><dir name="queue"><file name="edit.phtml" hash="0d793289316d1c7f2e5b3508db205aa6"/><file name="list.phtml" hash="9bb23c7219d55e342c8c71f14a1ebc59"/><file name="preview.phtml" hash="6bcdec9c96a32e7795732aeaf9780491"/></dir><dir name="report"><file name="grid.phtml" hash="1e1a1e4188805cd9d8367819373f1315"/></dir><dir name="subscriber"><file name="index.phtml" hash="76792a2024dca21a1a5f4e43daa01222"/></dir><dir name="template"><file name="edit.phtml" hash="ae4a29dd6b2aae79516697ecd441737e"/><file name="list.phtml" hash="be7610e0de7adac493471f7d3058d127"/><file name="preview.phtml" hash="eaa6752a7f24fb2e5dcc694b63c4aef0"/></dir><dir name="widget"><dir name="grid"><file name="massaction.phtml" hash="bfaa3552e660ff0c4bc54801757f0507"/></dir><file name="grid.phtml" hash="c55202b6277570f6783783ce9491d3b2"/></dir></dir></dir></dir><dir name="layout"><file name="magentokey_newsletter.xml" hash="c429bf2acb30078194e4242b0c564b38"/></dir></dir></dir></dir><dir name="frontend"><dir name="default"><dir name="default"><dir name="layout"><file name="magentokey_newsletter.xml" hash="a7beaf64710b103654bd3a6c1f6f8527"/></dir><dir name="template"><dir name="magentokey"><dir name="newsletter"><file name="category_new.phtml" hash="41ad4b0f0a8a5b26b7df7e226daf6a55"/><file name="category_price.phtml" hash="f6c8737e2d2bf298138649f6f0460870"/><file name="form.phtml" hash="a4731131b6e647464d175f3b0c4a7875"/><file name="form_clone.phtml" hash="e4a0176af4779f94cc08bc8408317b1e"/><file name="js.phtml" hash="47c004c7ed06d0c3f77ee71a147ef3d7"/><file name="js_clone.phtml" hash="5df3f08869b5abbb00efde8e12c82eab"/><file name="page.phtml" hash="f70184fb31bb3546c22b07eb6799233a"/><file name="popup.phtml" hash="bbc5d924b922e6b603285a8c0b44903a"/><file name="price.phtml" hash="3e38398b17bc436baa098f177c1a671f"/><file name="stock.phtml" hash="6cb9a71f418a05386e0a8bdc70292439"/><file name="update.phtml" hash="55aac721e236766f391125c1d3e22e28"/><dir name="widget"><file name="default.phtml" hash="5aa4ea3e8884ce616dc88c6de343abc7"/><file name="new.phtml" hash="5aa4ea3e8884ce616dc88c6de343abc7"/><file name="price.phtml" hash="5aa4ea3e8884ce616dc88c6de343abc7"/><file name="stock.phtml" hash="2090907f547fc81f7ef392a8214f0265"/><file name="update.phtml" hash="5aa4ea3e8884ce616dc88c6de343abc7"/></dir></dir></dir></dir></dir></dir></dir></target><target name="mageskin"><dir name="frontend"><dir name="default"><dir name="default"><dir name="css"><dir name="magentokey"><dir name="newsletter"><file name="arrow-1.png" hash="ecfa92f87dec0f29685a87e9bab35d48"/><file name="bg.png" hash="258eaa3f481bf3ac7b552e5fff0319f0"/><file name="bg2.png" hash="b6db76654b3f7dddc1d03b7b64e0baf2"/><file name="body_bg.jpg" hash="ef2be9dc4c67b377f2346079ce5dbb4f"/><file name="delete.png" hash="094aa29bfd676053e86e8d077cdeb3e1"/><file name="line_bg.png" hash="3da11690e9724a521397a7a7f74505ba"/><file name="logo.png" hash="99e07b9d05fd518f60d46463f7207642"/><file name="sprites.png" hash="2625b60272299c3bf7f81c388e0ef8c7"/></dir><file name="newsletter.css" hash="31a95b95a897cb02ea8ef2bf8402de72"/><dir name="popup"><dir name="magento"><file name="btn_bg.gif" hash="37c51a4d48a92da9648dcd3ca011039f"/><file name="content_bg.gif" hash="21278ea0da2d4256f4ced96b6080ba2e"/><file name="loading.gif" hash="b256d80f54c1415d7a6a6fdec39769f4"/><file name="title.gif" hash="8690b4274b60e1c912485d62bd609801"/><file name="window_close.png" hash="458473205ea4b02da86e77fd71a8b831"/></dir><file name="magento.css" hash="1d7ae212bc366f76d06e438d9a18c30e"/><file name="newsletter.css" hash="d8ec57f634eb2768dc391ab9e8582af3"/></dir><file name="review.css" hash="d41d8cd98f00b204e9800998ecf8427e"/><file name="widgets.css" hash="f3a4bf95d08d1fdbda18b2fb701dfc9a"/></dir></dir><dir name="js"><dir name="magentokey"><file name="MagentokeyUtility.js" hash="55f2c0b0e95475ac706ce783289dd661"/></dir></dir></dir></dir></dir></target></contents>
30
+ <compatible/>
31
+ <dependencies><required><php><min>5.1.0</min><max>6.0.0</max></php></required></dependencies>
32
+ </package>
skin/frontend/default/default/css/magentokey/newsletter.css ADDED
@@ -0,0 +1,161 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ body {
2
+ background: url("newsletter/body_bg.jpg") no-repeat scroll center top #73CFF1;
3
+ color: #333333;
4
+ font: 12px/1.75 Tahoma,Arial,sans-serif;
5
+ height: 100%;
6
+ }
7
+ * {
8
+ margin: 0;
9
+ padding: 0;
10
+ }
11
+ .logo {
12
+ height: 88px;
13
+ margin: 0 auto;
14
+ position: relative;
15
+ width: 800px;
16
+ z-index: 2;
17
+ }
18
+ #logo {
19
+ background: url(newsletter/logo.png) no-repeat scroll 0 0 transparent;
20
+ cursor: pointer;
21
+ height: 46px;
22
+ overflow: hidden;
23
+ position: absolute;
24
+ top: 28px;
25
+ width: 212px;
26
+
27
+ }
28
+ #logo a {
29
+ display: block;
30
+ height: 46px;
31
+ text-indent: -9999em;
32
+ width: 212px;
33
+ }
34
+ .magentokey-wrapper {
35
+ margin: 0 auto;
36
+ width: 800px;
37
+ }
38
+ .main-wrapper {
39
+ position: relative;
40
+ width: 800px;
41
+ z-index: 1;
42
+ background: none repeat scroll 0 0 #FFFFFF;
43
+ border-radius: 0 0 0 0;
44
+ min-height: 300px;
45
+ margin-bottom: 48px;
46
+ }
47
+ #submit-loading {
48
+ background: url(popup/magento/loading.gif) no-repeat;
49
+ height: 32px;
50
+ margin-top: 3px;
51
+ width: 32px;
52
+ }
53
+ .page-title {
54
+ background-position: 0 0;
55
+ height: 56px;
56
+ padding: 25px 0 0 53px;
57
+ background-image: url("newsletter/sprites.png");
58
+ background-repeat: no-repeat;
59
+ }
60
+ .page-title h2 {
61
+ color: #1E85AE;
62
+ font-family: "Lucida Grande",Helvetica,Arial,Verdana,sans-serif;
63
+ font-size: 20px;
64
+ line-height: 20px;
65
+ margin-bottom: 3px;
66
+ font-weight: normal;
67
+ }
68
+ .page-title .desc {
69
+ color: #1E85AE;
70
+ }
71
+ .c-wrapper {
72
+ margin: 0 auto;
73
+ padding: 25px 0;
74
+ width: 720px;
75
+ }
76
+ .inner-wrapper {
77
+ border-bottom: 1px solid #DFDFDF;
78
+ margin-bottom: 25px;
79
+ padding: 0 0 25px 20px;
80
+ }
81
+ .inner {
82
+ overflow: hidden;
83
+ }
84
+ .iconMail {
85
+ background-image: url(newsletter/sprites.png);
86
+ background-repeat: no-repeat;
87
+ display: block;
88
+ float: left;
89
+ height: 40px;
90
+ margin: 0 28px 0 0;
91
+ width: 40px;
92
+ background-position: -42px -83px;
93
+ }
94
+ .inner .tBar h2 {
95
+ font-size: 14px;
96
+ font-weight: bold;
97
+ }
98
+ .inner .tBar p {
99
+ color: #666666;
100
+ margin-bottom: 5px;
101
+ }
102
+ .form-box {
103
+ width: 510px;
104
+ background: none repeat scroll 0 0 #FFFDDF;
105
+ border: 1px solid #F5ECBC;
106
+ min-height: 126px;
107
+ padding: 18px 0 25px;
108
+ }
109
+ .message {
110
+ font-size: 14px;
111
+ text-indent: 3.7em;
112
+ }
113
+ table {
114
+ margin: 15px auto 0;
115
+ }
116
+ tr {
117
+ line-height: 38px;
118
+ }
119
+ td {
120
+ font-size:14px;
121
+ }
122
+ button.button {
123
+ cursor: pointer;
124
+ font-size: 14px;
125
+ font-weight: bold;
126
+ padding: 2px 0;
127
+ width: 97px
128
+ }
129
+ td input {
130
+ border: 1px solid #7F9DB9;
131
+ font-size: 14px;
132
+ height: 27px;
133
+ outline: medium none;
134
+ padding: 4px 5px 6px;
135
+ vertical-align: middle;
136
+ width: 190px;
137
+ }
138
+ .n-error {
139
+ color: red;
140
+ }
141
+ .n-success {
142
+ color: green;
143
+ font-size: 14px;
144
+ }
145
+ .success-back {
146
+ font-size: 14px;
147
+ padding: 30px 50px;
148
+ }
149
+ .calendar {
150
+ z-index: 9999;
151
+ }
152
+ .calendar tr {
153
+ line-height: 18px;
154
+ }
155
+ .calendar td {
156
+ font-size: 11px;
157
+ }
158
+ .calendar table {
159
+ margin: 0;
160
+ padding: 0;
161
+ }
skin/frontend/default/default/css/magentokey/newsletter/arrow-1.png ADDED
Binary file
skin/frontend/default/default/css/magentokey/newsletter/bg.png ADDED
Binary file
skin/frontend/default/default/css/magentokey/newsletter/bg2.png ADDED
Binary file
skin/frontend/default/default/css/magentokey/newsletter/body_bg.jpg ADDED
Binary file
skin/frontend/default/default/css/magentokey/newsletter/delete.png ADDED
Binary file
skin/frontend/default/default/css/magentokey/newsletter/line_bg.png ADDED
Binary file
skin/frontend/default/default/css/magentokey/newsletter/logo.png ADDED
Binary file
skin/frontend/default/default/css/magentokey/newsletter/sprites.png ADDED
Binary file
skin/frontend/default/default/css/magentokey/popup/magento.css ADDED
@@ -0,0 +1,197 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .overlay_dialog {
2
+ background-color: #666666;
3
+ filter:alpha(opacity=60);
4
+ -moz-opacity: 0.6;
5
+ opacity: 0.6;
6
+ }
7
+
8
+ .overlay___invisible__ {
9
+ background-color: #666666;
10
+ filter:alpha(opacity=0);
11
+ -moz-opacity: 0;
12
+ opacity: 0;
13
+ }
14
+
15
+ .dialog_nw {
16
+ width: 9px;
17
+ height: 23px;
18
+ background: transparent url(default/top_left.gif) no-repeat 0 0;
19
+ }
20
+
21
+ .dialog_n {
22
+ background: transparent url(default/top_mid.gif) repeat-x 0 0;
23
+ height: 23px;
24
+ }
25
+
26
+ .dialog_ne {
27
+ width: 9px;
28
+ height: 23px;
29
+ background: transparent url(default/top_right.gif) no-repeat 0 0;
30
+ }
31
+
32
+ .dialog_e {
33
+ width: 2px;
34
+ background: transparent url(default/center_right.gif) repeat-y 0 0;
35
+ }
36
+
37
+ .dialog_w {
38
+ width: 2px;
39
+ background: transparent url(default/center_left.gif) repeat-y 0 0;
40
+ }
41
+
42
+ .dialog_sw {
43
+ width: 9px;
44
+ height: 19px;
45
+ background: transparent url(default/bottom_left.gif) no-repeat 0 0;
46
+ }
47
+
48
+ .dialog_s {
49
+ background: transparent url(default/bottom_mid.gif) repeat-x 0 0;
50
+ height: 19px;
51
+ }
52
+
53
+ .dialog_se {
54
+ width: 9px;
55
+ height: 19px;
56
+ background: transparent url(default/bottom_right.gif) no-repeat 0 0;
57
+ }
58
+
59
+ .dialog_sizer {
60
+ width: 9px;
61
+ height: 19px;
62
+ background: transparent url(default/sizer.gif) no-repeat 0 0;
63
+ cursor:se-resize;
64
+ }
65
+
66
+ .dialog_close {
67
+ width: 14px;
68
+ height: 14px;
69
+ background: transparent url(default/close.gif) no-repeat 0 0;
70
+ position:absolute;
71
+ top:5px;
72
+ left:8px;
73
+ cursor:pointer;
74
+ z-index:2000;
75
+ }
76
+
77
+ .dialog_minimize {
78
+ width: 14px;
79
+ height: 15px;
80
+ background: transparent url(default/minimize.gif) no-repeat 0 0;
81
+ position:absolute;
82
+ top:5px;
83
+ left:28px;
84
+ cursor:pointer;
85
+ z-index:2000;
86
+ }
87
+
88
+ .dialog_maximize {
89
+ width: 14px;
90
+ height: 15px;
91
+ background: transparent url(default/maximize.gif) no-repeat 0 0;
92
+ position:absolute;
93
+ top:5px;
94
+ left:49px;
95
+ cursor:pointer;
96
+ z-index:2000;
97
+ }
98
+
99
+ .dialog_title {
100
+ float:left;
101
+ height:14px;
102
+ font-family: Tahoma, Arial, sans-serif;
103
+ font-size:12px;
104
+ text-align:center;
105
+ width:100%;
106
+ color:#000;
107
+ }
108
+
109
+ .dialog_content {
110
+ overflow:auto;
111
+ color: #DDD;
112
+ font-family: Tahoma, Arial, sans-serif;
113
+ font-size: 10px;
114
+ background-color:#123;
115
+ }
116
+
117
+ .top_draggable, .bottom_draggable {
118
+ cursor:move;
119
+ }
120
+
121
+ .status_bar {
122
+ font-size:12px;
123
+ }
124
+ .status_bar input{
125
+ font-size:12px;
126
+ }
127
+
128
+ .wired_frame {
129
+ display: block;
130
+ position: absolute;
131
+ border: 1px #000 dashed;
132
+ }
133
+
134
+ /* DO NOT CHANGE THESE VALUES*/
135
+ .dialog {
136
+ display: block;
137
+ position: absolute;
138
+ }
139
+
140
+ .dialog table.table_window {
141
+ border-collapse: collapse;
142
+ border-spacing: 0;
143
+ width: 100%;
144
+ margin: 0px;
145
+ padding:0px;
146
+ }
147
+
148
+ .dialog table.table_window td , .dialog table.table_window th {
149
+ padding: 0;
150
+ }
151
+
152
+ .dialog .title_window {
153
+ -moz-user-select:none;
154
+ }
155
+
156
+
157
+
158
+ .dialog { border:1px solid #8E8E8E; }
159
+ .dialog .bot { display:none !important; }
160
+ .overlay_magento { background-color:#666666; filter:alpha(opacity=60); -moz-opacity:.6; opacity:.6; -webkit-opacity:.6; }
161
+ .top.table_window { color:#666666; border-bottom:1px solid #CDCDCD; background:#CCCCCC url(magento/title.gif) 0 100% repeat-x; }
162
+
163
+ .magento_nw { width:6px; height:35px; }
164
+ .magento_n { height:35px; }
165
+ .magento_ne { width:6px; height:35px; }
166
+
167
+ .magento_w { width:6px; }
168
+ .magento_e { width:6px; }
169
+ .magento_w,
170
+ .magento_e,
171
+ .magento_content { background: #fff; }
172
+
173
+ .magento_sw { background:#deebf0; width:5px; height:3px; }
174
+ .magento_s { background:#deebf0; height:3px; }
175
+ .magento_se,
176
+
177
+ .magento_sizer { background:#deebf0; width:5px; height:3px; }
178
+ .magento_sizer { cursor:se-resize; }
179
+
180
+ .magento_close { width:16px; height:16px; background:url(magento/window_close.png) no-repeat 0 0; position:absolute; top:10px; right:10px; cursor:pointer; z-index:1000; }
181
+ .magento_minimize { width:16px; height:16px; background:url(magento/window_minimize.png) 0 0 no-repeat; position:absolute; top:5px; right:28px; cursor:pointer; z-index:1000; }
182
+ .magento_maximize { width:16px; height:16px; background:url(magento/window_maximize.png)0 0 no-repeat; position:absolute; top:5px; right:49px; cursor:pointer; z-index:1000; }
183
+
184
+ .magento_title { float:left; width:100%; font:bold 14px/35px Arial, Helvetica, sans-serif; color:#333; text-align:left; padding-left: 6px; }
185
+ .magento_message { padding: 8px 6px; }
186
+ .magento_content { overflow:auto; font-size:12px; }
187
+ .magento_content,
188
+ .magento_content label { color:#333; font-family:Arial, sans-serif; }
189
+
190
+ .magento_buttons { padding:10px; text-align:right; }
191
+ .magento_buttons input.button { border-width:1px; border-style:solid; border-color:#ed6502 #a04300 #a04300 #ed6502; background:#ffac47 url(magento/btn_bg.gif) 0 100% repeat-x; padding:0 7px 1px 7px; font:bold 12px/18px Arial, Helvetica, sans-serif; color:#fff; cursor:pointer; text-align:center; white-space:nowrap; }
192
+
193
+ /* FOR IE */
194
+ * html .magento_close { background-image:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/magento/window_maximize.png", sizingMethod="crop"); }
195
+ * html .magento_minimize { background-image:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/magento/window_close.png", sizingMethod="crop");}
196
+ * html .magento_maximize { background-image:none; filter:progid:DXImageTransform.Microsoft.AlphaImageLoader(src="../themes/magento/window_minimize.png", sizingMethod="crop"); }
197
+
skin/frontend/default/default/css/magentokey/popup/magento/btn_bg.gif ADDED
Binary file
skin/frontend/default/default/css/magentokey/popup/magento/content_bg.gif ADDED
Binary file
skin/frontend/default/default/css/magentokey/popup/magento/loading.gif ADDED
Binary file
skin/frontend/default/default/css/magentokey/popup/magento/title.gif ADDED
Binary file
skin/frontend/default/default/css/magentokey/popup/magento/window_close.png ADDED
Binary file
skin/frontend/default/default/css/magentokey/popup/newsletter.css ADDED
@@ -0,0 +1,83 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .wrapper-popup p {
2
+ margin: 0;
3
+ }
4
+ #submit-loading {
5
+ background: url(magento/loading.gif) no-repeat;
6
+ height: 32px;
7
+ margin-top: 3px;
8
+ width: 32px;
9
+ }
10
+ .tBar p {
11
+ color: #666666;
12
+ font-size: 13px;
13
+ line-height: 35px;
14
+ }
15
+ .wrapper-popup .form-box {
16
+ background: none repeat scroll 0 0 #FFFDDF;
17
+ border: 1px solid #F5ECBC;
18
+ margin: 0 auto;
19
+ min-height: 126px;
20
+ padding: 12px 0 25px;
21
+ width: 450px;
22
+ }
23
+ .wrapper-popup .form-box input.input-text {
24
+ padding: 2px;
25
+ height: 24px;
26
+ }
27
+ .wrapper-popup .n-btn {
28
+ cursor: pointer;
29
+ font-size: 14px;
30
+ font-weight: normal;
31
+ padding: 4px 0;
32
+ width: 97px;
33
+ color: #2F2F2F;
34
+ }
35
+ .wrapper-popup .message {
36
+ font-size: 14px;
37
+ margin: 0;
38
+ text-indent: 20px;
39
+ }
40
+ .wrapper-popup table {
41
+ margin: 15px auto 0;
42
+ }
43
+
44
+ .wrapper-popup tr {
45
+ line-height: 38px;
46
+ }
47
+ .wrapper-popup td {
48
+ font-size:14px;
49
+ }
50
+ .wrapper-popup button.button {
51
+ cursor: pointer;
52
+ font-size: 14px;
53
+ font-weight: bold;
54
+ padding: 2px 0;
55
+ width: 97px
56
+ }
57
+ .wrapper-popup td input {
58
+ border: 1px solid #7F9DB9;
59
+ font-size: 14px;
60
+ height: 27px;
61
+ outline: medium none;
62
+ padding: 4px 5px 6px;
63
+ vertical-align: middle;
64
+ width: 190px;
65
+ }
66
+ .wrapper-popup .n-note {
67
+ color: #999999;
68
+ font-size: 12px;
69
+ padding-left: 6px;
70
+ }
71
+ .wrapper-popup .n-error {
72
+ color: red;
73
+ font-size: 14px;
74
+ }
75
+ .wrapper-popup .n-success {
76
+ color: green;
77
+ font-size: 14px;
78
+ padding-left: 20px;
79
+ }
80
+ .wrapper-popup .success-back {
81
+ font-size: 14px;
82
+ padding: 30px 50px;
83
+ }
skin/frontend/default/default/css/magentokey/review.css ADDED
File without changes
skin/frontend/default/default/css/magentokey/widgets.css ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * Magento
3
+ *
4
+ * NOTICE OF LICENSE
5
+ *
6
+ * This source file is subject to the Academic Free License (AFL 3.0)
7
+ * that is bundled with this package in the file LICENSE_AFL.txt.
8
+ * It is also available through the world-wide-web at this URL:
9
+ * http://opensource.org/licenses/afl-3.0.php
10
+ * If you did not receive a copy of the license and are unable to
11
+ * obtain it through the world-wide-web, please send an email
12
+ * to license@magentocommerce.com so we can send you a copy immediately.
13
+ *
14
+ * DISCLAIMER
15
+ *
16
+ * Do not edit or add to this file if you wish to upgrade Magento to newer
17
+ * versions in the future. If you wish to customize Magento for your
18
+ * needs please refer to http://www.magentocommerce.com for more information.
19
+ *
20
+ * @category design
21
+ * @package base_default
22
+ * @copyright Copyright (c) 2011 Magento Inc. (http://www.magentocommerce.com)
23
+ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0)
24
+ */
25
+
26
+ /* Widgets =============================================================================== */
27
+ .widget { display:inline; }
28
+ .widget .widget-title { clear:both; padding:15px 0 0; margin:0 0 7px; }
29
+ .widget .widget-title h2 { font-size:15px; font-weight:bold; color:#e25203; }
30
+
31
+ .widget .mini-products-images-list .product-image { display:block; width:76px; height:76px; border:1px solid #a9a9a9; margin:0 auto; }
32
+ .widget .mini-products-images-list li.item { float:left; width:77px; height:77px; }
33
+
34
+ /* Widget: Catalog New Proructs List */
35
+ .widget-new-products { display:block; }
36
+ .col-main .widget-new-products { margin:7px 0; }
37
+ .widget-new-products .products-grid .product-image,
38
+ .widget-new-products .products-list .product-image { width:85px; height:85px; }
39
+ .widget-new-products .products-list .product-shop { margin-left:100px; }
40
+ .sidebar .widget-new-products .block { font-size:11px; line-height:1.25; }
41
+ .sidebar .widget-new-products .block-title strong { background:url(../images/widgets/i_widget-new.gif) 0 1px no-repeat; padding-left:21px; color:#dc5033; }
42
+
43
+ /* Widget: Recently Viewed Proructs */
44
+ .widget-viewed { display:block; }
45
+ .col-main .widget-viewed { margin:7px 0; }
46
+ .widget-viewed .products-grid .product-image,
47
+ .widget-viewed .products-list .product-image { width:85px; height:85px; }
48
+ .widget-viewed .products-list .product-shop { margin-left:100px; }
49
+ .sidebar .widget-viewed .block { font-size:11px; line-height:1.25; }
50
+ .sidebar .widget-viewed .block-title strong { background:url(../images/widgets/i_block-list.gif) 0 0 no-repeat; padding-left:21px; }
51
+
52
+ /* Widget: Recently Compared Proructs */
53
+ .widget-compared { display:block;}
54
+ .col-main .widget-compared { margin:7px 0; }
55
+ .widget-compared .products-grid .product-image,
56
+ .widget-compared .products-list .product-image { width:85px; height:85px; }
57
+ .widget-compared .products-list .product-shop { margin-left:100px; }
58
+ .sidebar .widget-compared .block { font-size:11px; line-height:1.25; }
59
+ .sidebar .widget-compared .block-title strong { background:url(../images/widgets/i_block-list.gif) 0 0 no-repeat; padding-left:21px; }
60
+
61
+ /* Widget: CMS Static Block */
62
+ .widget-static-block {}
63
+ .sidebar .widget-static-block { display:block; margin:0 0 15px; }
64
+
65
+ /* Widgets: Links Common Styles */
66
+ .top-container .widget a { padding:0 0 0 7px; }
67
+
68
+ .bottom-container .widget a { padding:0 3px; }
69
+
70
+ /* Widget: Catalog Product Link */
71
+ .widget-product-link-inline { display:inline; }
72
+
73
+ .col-main .widget-product-link { display:block; text-align:right; margin:7px 0; }
74
+ .col-main .widget-product-link a { background:url(../images/widgets/i_widget-link.gif) 100% 4px no-repeat; padding-right:15px; }
75
+
76
+ .sidebar .widget-product-link { display:block; margin:0 0 15px; padding:0 10px; }
77
+ .sidebar .widget-product-link a { background:url(../images/widgets/i_widget-link.gif) 100% 4px no-repeat; padding:0 15px 0 0; }
78
+
79
+ /* Widget: Catalog Category Link */
80
+ .widget-category-link-inline { display:inline; }
81
+
82
+ .col-main .widget-category-link { display:block; text-align:right; margin:7px 0; }
83
+ .col-main .widget-category-link a { background:url(../images/widgets/i_widget-link.gif) 100% 4px no-repeat; padding-right:15px; }
84
+
85
+ .sidebar .widget-category-link { display:block; margin:0 0 15px; padding:0 10px; }
86
+ .sidebar .widget-category-link a { background:url(../images/widgets/i_widget-link.gif) 100% 4px no-repeat; padding:0 15px 0 0; }
87
+
88
+ /* Widget: CMS Page Link */
89
+ .widget-cms-link-inline { display:inline; }
90
+
91
+ .col-main .widget-cms-link { display:block; text-align:right; margin:7px 0; }
92
+ .col-main .widget-cms-link a { background:url(../images/widgets/i_widget-link.gif) 100% 4px no-repeat; padding-right:15px; }
93
+
94
+ .sidebar .widget-cms-link { display:block; margin:0 0 15px; padding:0 10px; }
95
+ .sidebar .widget-cms-link a { background:url(../images/widgets/i_widget-link.gif) 100% 4px no-repeat; padding:0 15px 0 0; }
96
+ /* ======================================================================================= */
skin/frontend/default/default/js/magentokey/MagentokeyUtility.js ADDED
@@ -0,0 +1,47 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /**
2
+ * @author Galey <yanggaojiao@qq.com> (http://www.hifasion.org)
3
+ * @copyright Copyright &copy; 2011, Hifashion (http://www.hifasion.org,http://www.magentkey.com)
4
+ * @version 1.0.0
5
+ */
6
+
7
+ MagentokeyDialogUtility = {
8
+ openDialog: function(url, width, height, title) {
9
+ if ($('browser_window') && typeof(Windows) != 'undefined') {
10
+ Windows.focus('browser_window');
11
+ return;
12
+ }
13
+ this.dialogWindow = Dialog.info(null, {
14
+ closable: true,
15
+ resizable: false,
16
+ draggable: true,
17
+ className: 'magento',
18
+ windowClassName: 'popup-window',
19
+ title: title || 'Subscribe Newsletter...',
20
+ top: 50,
21
+ width: width || 950,
22
+ height: height || 600,
23
+ zIndex: 1000,
24
+ recenterAuto: false,
25
+ hideEffect: Element.hide,
26
+ showEffect: Element.show,
27
+ id: 'browser_window',
28
+ onClose: this.closeDialog.bind(this)
29
+ });
30
+ new Ajax.Updater(
31
+ 'modal_dialog_message',
32
+ url, {
33
+ evalScripts: true
34
+ }
35
+ );
36
+ },
37
+ closeDialog: function(window) {
38
+ if (!window) {
39
+ window = this.dialogWindow;
40
+ }
41
+ if (window) {
42
+ // IE fix - hidden form select fields after closing dialog
43
+ WindowUtilities._showSelect();
44
+ window.close();
45
+ }
46
+ }
47
+ }