MailPoet Newsletters (Previous) - Version 2.6.9

Version Description

  • 2014-07-14 =
  • Fixed email display issues caused by responsive CSS. We're truly sorry for this.
  • New columns on Subscribers page: "Never opened or clicked"
  • Removed "Unconfirmed" filter on Subscribers page when signup confirmation is off
  • Fixed a few minor bugs on the Statistics page for Premium users. Thanks for your feedbacks!
  • Fixed our hair with spray to look like cool kids in the eighties
Download this release

Release Info

Developer bordoni
Plugin Icon 128x128 MailPoet Newsletters (Previous)
Version 2.6.9
Comparing to
See all releases

Code changes from version 2.5.4 to 2.6.9

Files changed (92) hide show
  1. add-ons/add-ons-list.php +324 -0
  2. add-ons/add-ons.php +263 -0
  3. {inc/wp-special → add-ons}/index.html +0 -0
  4. classes/WJ_Analytics.php +706 -260
  5. classes/WJ_Export.php +216 -0
  6. classes/WJ_Field.php +283 -0
  7. classes/WJ_FieldHandler.php +59 -0
  8. classes/WJ_FieldRender.php +249 -0
  9. classes/WJ_FieldUser.php +130 -0
  10. classes/WJ_Import.php +828 -0
  11. classes/WJ_Migrator.php +53 -0
  12. classes/WJ_Option.php +29 -0
  13. classes/WJ_Settings.php +30 -0
  14. classes/WJ_Stats.php +474 -0
  15. classes/WJ_Upgrade.php +390 -0
  16. classes/WJ_Utils.php +69 -0
  17. {js/amcharts/images → classes}/index.html +0 -0
  18. controllers/ajax/campaigns.php +999 -851
  19. controllers/ajax/config.php +143 -7
  20. controllers/ajax/statistics.php +106 -0
  21. controllers/ajax/subscribers.php +27 -6
  22. controllers/ajax/tmce.php +138 -139
  23. controllers/back.php +41 -115
  24. controllers/back/campaigns.php +2719 -2615
  25. controllers/back/config.php +383 -379
  26. controllers/back/premium.php +34 -0
  27. controllers/back/statistics.php +200 -0
  28. controllers/back/subscribers.php +372 -907
  29. controllers/front.php +6 -4
  30. controllers/front/confirm.php +56 -73
  31. controllers/front/email.php +32 -11
  32. controllers/front/module.php +38 -0
  33. controllers/front/stats.php +29 -273
  34. core/base.php +1531 -1243
  35. core/controller.php +81 -72
  36. core/model.php +1028 -959
  37. core/module/module.php +248 -0
  38. core/module/statistics.php +33 -0
  39. core/module/statistics_model.php +139 -0
  40. core/module/statisticschart.php +11 -0
  41. core/module/statisticstable.php +5 -0
  42. core/view.php +179 -22
  43. css/add-ons.css +1 -0
  44. css/admin-campaigns-articles.css +1 -1
  45. css/admin-campaigns-autopost.css +1 -1
  46. css/admin-campaigns-bookmarks.css +1 -1
  47. css/admin-campaigns-dividers.css +1 -1
  48. css/admin-campaigns-editDetails.css +1 -1
  49. css/admin-campaigns-medias.css +1 -1
  50. css/admin-campaigns-themes.css +1 -1
  51. css/admin-campaigns-viewstats.css +1 -0
  52. css/admin-campaigns-welcome_new.css +1 -0
  53. css/admin-campaigns.css +1 -1
  54. css/admin-config-form_widget_settings.css +1 -1
  55. css/admin-config.css +1 -1
  56. css/admin-dashicons.css +1 -0
  57. css/admin-global.css +1 -1
  58. css/admin-premium.css +1 -0
  59. css/admin-statistics.css +1 -0
  60. css/admin-subscribers-addlist.css +1 -0
  61. css/admin-subscribers-edit.css +1 -0
  62. css/admin-subscribers-export.css +1 -0
  63. css/admin-subscribers-exportlist.css +1 -0
  64. css/admin-subscribers-importmatch.css +1 -1
  65. css/admin-subscribers.css +1 -0
  66. css/admin-widget.css +1 -1
  67. css/admin.css +1 -1
  68. css/adminPopup.css +1 -1
  69. css/jquery/ui/themes/base/images/animated-overlay.gif +0 -0
  70. css/jquery/ui/themes/base/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
  71. css/jquery/ui/themes/base/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
  72. css/jquery/ui/themes/base/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
  73. css/jquery/ui/themes/base/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
  74. css/jquery/ui/themes/base/images/ui-bg_glass_75_dadada_1x400.png +0 -0
  75. css/jquery/ui/themes/base/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
  76. css/jquery/ui/themes/base/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
  77. css/jquery/ui/themes/base/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
  78. css/jquery/ui/themes/base/images/ui-icons_222222_256x240.png +0 -0
  79. css/jquery/ui/themes/base/images/ui-icons_2e83ff_256x240.png +0 -0
  80. css/jquery/ui/themes/base/images/ui-icons_454545_256x240.png +0 -0
  81. css/jquery/ui/themes/base/images/ui-icons_888888_256x240.png +0 -0
  82. css/jquery/ui/themes/base/images/ui-icons_cd0a0a_256x240.png +0 -0
  83. css/jquery/ui/themes/base/jquery.ui.core.min.css +5 -0
  84. css/jquery/ui/themes/base/jquery.ui.datepicker.min.css +5 -0
  85. css/rtl.css +1 -1
  86. css/select2/select2.css +615 -0
  87. css/smoothness/jquery-ui-1.8.20.custom.css +7 -7
  88. css/tmce/editor.css +2317 -0
  89. css/validationEngine.jquery.css +1 -1
  90. css/vendor/bootstrap.tooltip.css +101 -0
  91. css/wysija-editor.css +1 -1
  92. css/wysija-form-editor.css +1 -1
add-ons/add-ons-list.php ADDED
@@ -0,0 +1,324 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * List of all add-ons available for MailPoet
4
+ */
5
+ function add_ons_list(){
6
+ $available_add_ons = array(
7
+ array(
8
+ 'name' => 'WooCommerce: Subscribe on Checkout',
9
+ 'search' => 'MailPoet WooCommerce Add-on',
10
+ 'thumbnail' => 'woocommerce.png',
11
+ 'description' => __( 'Add a checkbox on checkout page for your customers to subscribe to your MailPoet newsletters.', WYSIJA ),
12
+ 'plugin_url' => 'mailpoet-woocommerce-addon/mailpoet-woocommerce-addon.php',
13
+ 'version' => '1.0.2',
14
+ 'config_url' => 'admin.php?page=woocommerce_settings&tab=mailpoet',
15
+ 'official' => true,
16
+ 'on_wordpress.org' => true,
17
+ 'free' => true,
18
+ 'service' => false,
19
+ 'requires' => 'woocommerce/woocommerce.php',
20
+ 'requires_name' => 'WooCommerce',
21
+ ),
22
+
23
+ array(
24
+ 'name' => 'Autoresponders for WooCommerce Products',
25
+ 'search' => 'Autoresponders for WooCommerce Products',
26
+ 'thumbnail' => 'woocommerce.png',
27
+ 'description' => __( 'Decide which emails a new customer gets automatically, based on the product he just purchased. This a Premium add-on for WooCommerce.', WYSIJA ),
28
+ 'review' => '',
29
+ 'plugin_url' => '',
30
+ 'author_url' => 'http://clicky.me/woocommerce-autoresponder',
31
+ 'purchase_url' => 'http://clicky.me/woocommerce-autoresponder',
32
+ 'version' => '1.0.1',
33
+ 'official' => true,
34
+ 'on_wordpress.org' => false,
35
+ 'free' => false,
36
+ 'service' => false,
37
+ ),
38
+
39
+ array(
40
+ 'name' => 'Jigoshop: Subscribe on Checkout',
41
+ 'search' => 'MailPoet Jigoshop Add-on',
42
+ 'thumbnail' => 'jigoshop.png',
43
+ 'description' => __( 'Add a checkbox on checkout page for your customers to subscribe to your MailPoet newsletters.', WYSIJA ),
44
+ 'plugin_url' => 'mailpoet-jigoshop-addon/mailpoet-jigoshop-addon.php',
45
+ 'version' => '1.0.3',
46
+ 'config_url' => 'admin.php?page=jigoshop_settings&tab=mailpoet',
47
+ 'official' => true,
48
+ 'on_wordpress.org' => true,
49
+ 'free' => true,
50
+ 'service' => false,
51
+ 'requires' => 'jigoshop/jigoshop.php',
52
+ 'requires_name' => 'Jigoshop',
53
+ ),
54
+
55
+ array(
56
+ 'name' => 'Gravity Forms: Subscribe Add-on',
57
+ 'search' => 'MailPoet Gravity Forms Add-on',
58
+ 'thumbnail' => 'gravity-forms.png',
59
+ 'description' => __( 'Add a new field to add to your forms so your visitors can subscribe to your MailPoet newsletters.', WYSIJA ),
60
+ 'plugin_url' => 'mailpoet-gravity-forms-addon/mailpoet-gravity-forms-addon.php',
61
+ 'version' => '1.0.0',
62
+ 'official' => true,
63
+ 'on_wordpress.org' => true,
64
+ 'free' => true,
65
+ 'service' => false,
66
+ 'requires' => 'gravityforms/gravityforms.php',
67
+ 'requires_name' => 'Gravity Forms',
68
+ ),
69
+
70
+ array(
71
+ 'name' => 'WP e-Commerce: Subscribe on Checkout',
72
+ 'search' => 'MailPoet WP e-Commerce Add-on',
73
+ 'thumbnail' => 'wp-e-commerce.png',
74
+ 'description' => __( 'Add a checkbox on checkout page for your customers to subscribe to your MailPoet newsletters.', WYSIJA ),
75
+ 'plugin_url' => 'mailpoet-wp-ecommerce-addon/mailpoet-wp-ecommerce-addon.php',
76
+ 'version' => '1.0.0',
77
+ 'config_url' => 'edit.php?post_type=wpsc-product&page=mailpoet',
78
+ 'official' => true,
79
+ 'on_wordpress.org' => true,
80
+ 'free' => true,
81
+ 'service' => false,
82
+ 'requires' => 'wp-e-commerce/wp-shopping-cart.php',
83
+ 'requires_name' => 'WP e-Commerce',
84
+ ),
85
+
86
+ array(
87
+ 'name' => 'Restrict Content Pro: Registration Add-on',
88
+ 'search' => 'Restrict Content Pro Wysija',
89
+ 'thumbnail' => 'pippins.png',
90
+ 'description' => __( 'Add a checkbox on the registration form of this plugin so your new users join a list of your choice.', WYSIJA ),
91
+ 'plugin_url' => 'restrict-content-pro-wysija/rcp-wysija.php',
92
+ 'version' => '1.0',
93
+ 'official' => true,
94
+ 'on_wordpress.org' => true,
95
+ 'free' => true,
96
+ 'service' => false,
97
+ 'requires' => 'restrict-content-pro/restrict-content-pro.php',
98
+ 'requires_name' => 'Restrict Content Pro',
99
+ ),
100
+
101
+ array(
102
+ 'name' => 'Contact Form 7: MailPoet Add-on',
103
+ 'search' => 'MailPoet Contact Form 7',
104
+ 'thumbnail' => 'cf7.png',
105
+ 'description' => __( 'Add a checkbox in your forms, and choose which lists the user gets added to.', WYSIJA ),
106
+ 'plugin_url' => 'mailpoet-contact-form-7/mailpoet-contact-form-7.php',
107
+ 'author_url' => '',
108
+ 'version' => '1.0.0',
109
+ 'official' => true,
110
+ 'on_wordpress.org' => true,
111
+ 'free' => true,
112
+ 'service' => false,
113
+ 'requires' => 'contact-form-7/wp-contact-form-7.php',
114
+ 'requires_name' => 'Contact Form 7',
115
+ ),
116
+
117
+ array(
118
+ 'name' => 'WangGuard: MailPoet Connector',
119
+ 'search' => 'WangGuard Wysija Newsletter Connector',
120
+ 'thumbnail' => 'wangguard.png',
121
+ 'description' => __( 'Stop fake signups by robots with WangGuard, a free white listing service, and plugin.', WYSIJA ),
122
+ 'review' => __( 'If you have this problem, then this is your solution. Totally free too.', WYSIJA ),
123
+ 'plugin_url' => 'wangguard-wysija-newsletter-connector/wangguard-wysija.php',
124
+ 'author_url' => 'http://clicky.me/wangguard',
125
+ 'version' => '1.0.0',
126
+ 'official' => true,
127
+ 'on_wordpress.org' => true,
128
+ 'free' => true,
129
+ 'service' => false,
130
+ 'requires' => '',
131
+ ),
132
+
133
+ array(
134
+ 'name' => 'Leaky Paywall: MailPoet Add-on',
135
+ 'search' => 'Leaky Paywall: MailPoet Add-on',
136
+ 'thumbnail' => 'leakypw.png',
137
+ 'description' => __( 'Leaky Paywall is a Premium plugin to put content behind a paywall. This add-on manages your customers\' customers subscriptions.', WYSIJA ),
138
+ 'plugin_url' => 'leaky-paywall-mail-poet/issuem-leaky-paywall-mailpoet.php',
139
+ 'author_url' => 'http://clicky.me/leakypw',
140
+ 'version' => '1.0.0',
141
+ 'official' => true,
142
+ 'on_wordpress.org' => true,
143
+ 'free' => true,
144
+ 'service' => false,
145
+ ),
146
+
147
+ array(
148
+ 'name' => 'GetConversion: Bar and Box Forms Add-on',
149
+ 'search' => 'GC MailPoet EX',
150
+ 'thumbnail' => 'getconversion.png',
151
+ 'description' => __( 'Put a form in a top or bottom bar of your site, or in a nice box within your posts with GetConversion\'s free plugins. Connect them to MailPoet with this add-on.<br/></br>Get 30% off the Premium version of their add-on by clicking <a href="http://getconversion.com/products/gc-mailpoet-ex-pro/?coupon=MAILPOET">here</a>.', WYSIJA ),
152
+ 'review' => __( 'Try it yourself, we were impressed by the free versions.', WYSIJA ),
153
+ 'plugin_url' => 'gc-message-bar/main.php',
154
+ 'author_url' => 'http://clicky.me/GC-add-on',
155
+ 'version' => '1.0.0',
156
+ 'official' => true,
157
+ 'on_wordpress.org' => true,
158
+ 'free' => true,
159
+ 'service' => false,
160
+ ),
161
+
162
+ /* Below is the list of services that work with MailPoet */
163
+
164
+ array(
165
+ 'name' => 'OptinMonster: Slick Forms',
166
+ 'search' => 'OptinMonster: slick forms',
167
+ 'thumbnail' => 'optinmonster.png',
168
+ 'description' => __( 'Put a subscription form in a popup, footer bar or slide-in to add subscribers with this Premium plugin.', WYSIJA ),
169
+ 'review' => __( 'The authors have done a pretty awesome job.', WYSIJA ),
170
+ 'plugin_url' => '',
171
+ 'author_url' => 'http://clicky.me/optinmonsteraddon',
172
+ 'purchase_url' => '',
173
+ 'version' => '',
174
+ 'official' => false,
175
+ 'on_wordpress.org' => false,
176
+ 'free' => false,
177
+ 'service' => true,
178
+ 'premium_offer' => __( 'Premium users save 20% with this coupon: MP20', WYSIJA ),
179
+ ),
180
+
181
+ array(
182
+ 'name' => 'Pippity: Form in a Popup',
183
+ 'search' => 'Pippity: form in a popup',
184
+ 'thumbnail' => 'pippity.png',
185
+ 'description' => __( 'This Premium plugin allows you to add a MailPoet form in a popup.', WYSIJA ),
186
+ 'review' => __( 'You\'ll need to know CSS to design it to your taste.', WYSIJA ),
187
+ 'plugin_url' => '',
188
+ 'author_url' => 'http://clicky.me/pippity',
189
+ 'purchase_url' => '',
190
+ 'version' => '',
191
+ 'official' => false,
192
+ 'on_wordpress.org' => false,
193
+ 'free' => false,
194
+ 'service' => true,
195
+ 'premium_offer' => __( 'Premium users save 25% with this coupon: mailpoet25', WYSIJA ),
196
+ ),
197
+
198
+
199
+ array(
200
+ 'name' => 'Hybrid Connect: Forms and Facebook',
201
+ 'search' => 'Hybrid Connect: forms and Facebook',
202
+ 'thumbnail' => 'hybrid-connect.png',
203
+ 'description' => __( 'This Premium plugin allows you to add MailPoet\'s forms in many places, and in Facebook.', WYSIJA ),
204
+ 'review' => __( 'Very powerful, if not a quirky user interface.', WYSIJA ),
205
+ 'plugin_url' => '',
206
+ 'author_url' => 'http://clicky.me/hybrid-connect',
207
+ 'purchase_url' => '',
208
+ 'version' => '',
209
+ 'official' => false,
210
+ 'on_wordpress.org' => false,
211
+ 'free' => false,
212
+ 'service' => true,
213
+ 'premium_offer' => '',
214
+ ),
215
+
216
+ array(
217
+ 'name' => 'Magic Action Box: Pretty forms in post',
218
+ 'search' => 'Magic Action Box: pretty forms in post',
219
+ 'thumbnail' => 'magic-action-box.png',
220
+ 'description' => __( 'This free plugin allows you to design and position a form at the beginning or bottom of a post.', WYSIJA ),
221
+ 'review' => __( 'It\'s free, and has proven popular with our users.', WYSIJA ),
222
+ 'plugin_url' => '',
223
+ 'author_url' => 'http://clicky.me/magic-action-box',
224
+ 'purchase_url' => '',
225
+ 'version' => '',
226
+ 'official' => false,
227
+ 'on_wordpress.org' => false,
228
+ 'free' => false,
229
+ 'service' => true,
230
+ 'premium_offer' => '',
231
+ ),
232
+
233
+ array(
234
+ 'name' => 'Optin Revolution: Popup form',
235
+ 'search' => 'Optin Revolution: popup form',
236
+ 'thumbnail' => 'optin-revolution.png',
237
+ 'description' => __( 'This free plugin allows you to put a form in a popup, that\'s it.', WYSIJA ),
238
+ 'review' => __( 'This is the free version of a more powerful Premium version.', WYSIJA ),
239
+ 'plugin_url' => '',
240
+ 'author_url' => 'http://clicky.me/optin-revolution',
241
+ 'purchase_url' => '',
242
+ 'version' => '',
243
+ 'official' => false,
244
+ 'on_wordpress.org' => false,
245
+ 'free' => false,
246
+ 'service' => true,
247
+ 'premium_offer' => '',
248
+ ),
249
+
250
+ array(
251
+ 'name' => 'Ultimate Coming Soon Page',
252
+ 'search' => 'Ultimate Coming Soon Page',
253
+ 'thumbnail' => 'ultimate-coming-soon.png',
254
+ 'description' => __( 'Your new site is not yet launched? Put a coming soon page with a form to capture emails with this Premium plugin.', WYSIJA ),
255
+ 'review' => __( 'A well designed plugin for a simple idea.', WYSIJA ),
256
+ 'plugin_url' => '',
257
+ 'author_url' => 'http://clicky.me/coming-soon',
258
+ 'purchase_url' => '',
259
+ 'version' => '',
260
+ 'official' => false,
261
+ 'on_wordpress.org' => false,
262
+ 'free' => false,
263
+ 'service' => true,
264
+ 'premium_offer' => __( 'Premium users save 20% with this coupon: MAILPOET20', WYSIJA ),
265
+ ),
266
+
267
+ array(
268
+ 'name' => 'Plugmatter: form below your header',
269
+ 'search' => 'Plugmatter',
270
+ 'thumbnail' => 'plugmatter.png',
271
+ 'description' => __( 'This Premium plugin allows you to put a pretty form right below the header. Nothing more, nothing less.', WYSIJA ),
272
+ 'review' => '',
273
+ 'plugin_url' => '',
274
+ 'author_url' => 'http://clicky.me/plugmatter',
275
+ 'purchase_url' => '',
276
+ 'version' => '',
277
+ 'official' => false,
278
+ 'on_wordpress.org' => false,
279
+ 'free' => false,
280
+ 'service' => true,
281
+ 'premium_offer' => '',
282
+ ),
283
+
284
+ array(
285
+ 'name' => 'EDD: MailPoet: Subscribe on Checkout',
286
+ 'search' => 'Easy Digital Downloads - MailPoet',
287
+ 'thumbnail' => 'easy-digital-downloads.png',
288
+ 'description' => __( 'A checkbox is added as option for your customers to signup for your newsletter while purchasing from your digital store.', WYSIJA ),
289
+ 'review' => '',
290
+ 'plugin_url' => '',
291
+ 'author_url' => 'http://clicky.me/easy-digital-downloads',
292
+ 'purchase_url' => 'http://clicky.me/easy-digital-downloads',
293
+ 'version' => '1.1.2',
294
+ 'official' => false,
295
+ 'on_wordpress.org' => false,
296
+ 'free' => false,
297
+ 'service' => false,
298
+ 'requires' => 'easy-digital-downloads/easy-digital-downloads.php',
299
+ 'requires_name' => 'Easy Digital Downloads',
300
+ 'premium_offer' => '',
301
+ ),
302
+
303
+ array(
304
+ 'name' => 'Ninja Forms: Subscribe Add-on',
305
+ 'search' => 'Ninja Forms: Subscribe Add-on',
306
+ 'thumbnail' => 'ninja-forms.png',
307
+ 'description' => __( 'Quickly create newsletter signup forms for your MailPoet mailing lists using the power and flexibility that Ninja Forms provides.', WYSIJA ),
308
+ 'review' => '',
309
+ 'plugin_url' => 'ninja-forms-mailpoet/nf-mailpoet.php',
310
+ 'author_url' => 'http://clicky.me/ninja-forms',
311
+ 'purchase_url' => 'http://clicky.me/ninja-forms',
312
+ 'version' => '1.0.1',
313
+ 'official' => false,
314
+ 'on_wordpress.org' => false,
315
+ 'free' => true,
316
+ 'service' => false,
317
+ 'requires' => 'ninja-forms/ninja-forms.php',
318
+ 'requires_name' => 'Ninja Forms',
319
+ 'premium_offer' => '',
320
+ ),
321
+ );
322
+
323
+ return $available_add_ons;
324
+ }
add-ons/add-ons.php ADDED
@@ -0,0 +1,263 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ if ( ! defined( 'ABSPATH' ) ){
3
+ exit; // Exit if accessed directly
4
+ }
5
+
6
+ class MailPoet_Add_ons {
7
+ /**
8
+ * Constructor
9
+ */
10
+ public function __construct(){
11
+ $this->plugin_path = WYSIJA_DIR;
12
+ $this->wp_plugin_path = str_replace( 'wysija-newsletters', '', $this->plugin_path );
13
+ $this->plugin_url = WYSIJA_URL;
14
+ $this->image_url = 'http://ps.w.org/wysija-newsletters/assets/add-ons/';
15
+
16
+ $this->mailpoet_add_on_activated_notice();
17
+ $this->mailpoet_add_on_deactivated_notice();
18
+ }
19
+
20
+ /**
21
+ * Runs when the plugin is initialized.
22
+ */
23
+ public function init_mail_poet_add_ons(){
24
+ // Load JavaScript and stylesheets.
25
+ $this->register_scripts_and_styles();
26
+ }
27
+
28
+ /**
29
+ * Registers and enqueues stylesheets for the
30
+ * administration panel and the public facing site.
31
+ */
32
+ public function register_scripts_and_styles(){
33
+ if ( is_admin() ) {
34
+ wp_register_style( 'mail_poet_add_ons', WYSIJA_URL . 'css/add-ons.css' );
35
+ wp_enqueue_style( 'mail_poet_add_ons' );
36
+ } // end if
37
+ } // end register_scripts_and_styles
38
+
39
+ /**
40
+ * This notifies the user that the add-on plugin
41
+ * is now activated and returns them back to the
42
+ * add-ons page.
43
+ */
44
+ public function mailpoet_add_on_activated_notice(){
45
+ global $current_screen;
46
+
47
+ require_once(ABSPATH.'/wp-admin/includes/plugin.php');
48
+
49
+ if ( isset($_GET['action'] ) && $_GET['action'] == 'activate' && isset( $_GET['module'] ) ) {
50
+
51
+ $plugin = plugin_basename( $_GET['module'] );
52
+ $plugin_data = get_plugin_data( $this->wp_plugin_path . $plugin );
53
+
54
+ $plugin_name = esc_attr( str_replace( ' ', '_', $plugin_data['Name'] ) );
55
+ $plugin_name = esc_attr( str_replace( '&#039;', '_', $plugin_name ) );
56
+
57
+ if ( isset( $_GET['requires'] ) ) {
58
+ if ( file_exists( $this->wp_plugin_path . plugin_basename( $_GET['requires'] ) ) ) {
59
+ if ( ! WYSIJA::is_plugin_active( $_GET['requires'] ) ) {
60
+ $location = admin_url( 'admin.php?page=wysija_config&status=not-activated&add-on=' . $plugin_name . '&requires=' . esc_attr( str_replace( ' ', '_', $_GET['requires_name'] ) ) . '#tab-add-ons' );
61
+ wp_safe_redirect( $location );
62
+ exit;
63
+ }
64
+ } else {
65
+ $location = admin_url( 'admin.php?page=wysija_config&status=not-installed&add-on=' . $plugin_name . '&requires=' . esc_attr( str_replace( ' ', '_', $_GET['requires_name'] ) ) . '#tab-add-ons' );
66
+ wp_safe_redirect( $location );
67
+ exit;
68
+ }
69
+ }
70
+
71
+ // Activate the add-on plugin.
72
+ activate_plugin( $plugin );
73
+
74
+ // Return back to add-on page.
75
+ $location = admin_url( 'admin.php?page=wysija_config&status=activated&add-on=' . $plugin_name . '#tab-add-ons' );
76
+ wp_safe_redirect( $location );
77
+ exit;
78
+ }
79
+
80
+ /**
81
+ * Display message if the plugin was not able to activate due
82
+ * to a required plugin is not active first.
83
+ */
84
+ if ( $current_screen->parent_base == 'wysija_campaigns' && isset( $_GET['status'] ) && $_GET['status'] == 'not-activated' || isset( $_GET['status'] ) && $_GET['status'] == 'not-installed' ){
85
+ echo
86
+ '<div id="message" class="error fade" style="display:block !important;">' .
87
+ '<p>' .
88
+ '<strong>' . esc_attr( str_replace( '_', ' ', $_GET['add-on'] ) ) . '</strong> ' .
89
+ wp_kses( sprintf(
90
+ __( 'was not activated as it requires <strong><a href="%s">%s</a></strong> to be installed and active first.', WYSIJA ),
91
+ esc_url( admin_url( 'plugin-install.php?tab=search&type=term&s=' . esc_attr( strtolower( str_replace( ' ', '+', $_GET['requires'] ) ) ) ) ),
92
+ str_replace( '_', ' ', $_GET['requires'] )
93
+ ), array( 'a' => array( 'href' => array() ), 'strong' => array(), 'b' => array(), 'em' => array() ) ) .
94
+ ' <input type="button" class="button" value="' . esc_attr__( 'Hide this message', WYSIJA ) . '" onclick="document.location.href=\'' . esc_url( admin_url( 'admin.php?page=wysija_config#tab-add_ons' ) ) . '\';">' .
95
+ '</p>' .
96
+ '</div>';
97
+ }
98
+
99
+ // Display message once the add-on has been activated.
100
+ if ( $current_screen->parent_base == 'wysija_campaigns' && isset( $_GET['status'] ) && $_GET['status'] == 'activated' ){
101
+ echo '<div id="message" class="updated fade" style="display:block !important;"><p><strong>' . esc_attr( str_replace( '_', ' ', $_GET['add-on'] ) ) . '</strong> ' . esc_attr__( 'has been activated.', WYSIJA ) . '</p></div>';
102
+ }
103
+ }
104
+
105
+ /**
106
+ * This notifies the user that the add-on plugin
107
+ * is now deactivated and returns them back to the
108
+ * add-ons page.
109
+ */
110
+ public function mailpoet_add_on_deactivated_notice(){
111
+ global $current_screen;
112
+
113
+ require_once ABSPATH . '/wp-admin/includes/plugin.php';
114
+
115
+ if ( isset( $_GET['action'] ) && $_GET['action'] == 'deactivate' && isset( $_GET['module'] ) ) {
116
+ $plugin = plugin_basename( $_GET['module'] );
117
+ $plugin_data = get_plugin_data( $this->wp_plugin_path . $plugin );
118
+
119
+ // Deactivate the add-on plugin.
120
+ deactivate_plugins( $plugin );
121
+
122
+ // Return back to add-on page.
123
+ $location = admin_url( 'admin.php?page=wysija_config&status=deactivated&add-on=' . esc_html( str_replace( ' ', '_', $plugin_data['Name'] ) ) . '#tab-add-ons' );
124
+ wp_safe_redirect( $location );
125
+ exit;
126
+ }
127
+
128
+ // Display message once the add-on has been deactivated.
129
+ if ( $current_screen->parent_base == 'wysija_campaigns' && isset( $_GET['status'] ) && $_GET['status'] == 'deactivated' ) {
130
+ echo '<div id="message" class="updated fade" style="display:block !important;"><p><strong>' . esc_attr( str_replace( '_', ' ', $_GET['add-on'] ) ) . '</strong> ' . esc_attr__( 'has been de-activated.', WYSIJA ) . '</p></div>';
131
+ }
132
+
133
+ }
134
+
135
+ /**
136
+ * Displays the add ons page and lists
137
+ * the plugins and services available.
138
+ */
139
+ public function add_ons_page(){
140
+ require_once WYSIJA_DIR . '/add-ons/add-ons-list.php';
141
+
142
+ echo '<div class="module-container">';
143
+ foreach ( add_ons_list() as $plugin => $product ){
144
+ $status = ''; // Status class.
145
+
146
+ /**
147
+ * Queries if the plugin is installed,
148
+ * active and meets the requirements
149
+ * it requires if any.
150
+ */
151
+ if ( file_exists( $this->wp_plugin_path . plugin_basename( $product['plugin_url'] ) ) ) {
152
+ $status .= ' installed';
153
+ } else {
154
+ $status .= ' not-installed';
155
+ }
156
+
157
+ if ( WYSIJA::is_plugin_active( $product['plugin_url'] ) ) {
158
+ $status .= ' active';
159
+ } else {
160
+ $status .= ' inactive';
161
+ }
162
+
163
+ if ( empty( $product['requires'] ) ) {
164
+ $status .= ' ready';
165
+ } elseif ( ! empty( $product['requires'] ) && file_exists( $this->wp_plugin_path . plugin_basename( $product['requires'] ) ) ) {
166
+ $status .= ' ready';
167
+ if ( WYSIJA::is_plugin_active( $product['requires'] ) ) {
168
+ $status .= ' ready';
169
+ } else {
170
+ $status .= ' not-ready';
171
+ }
172
+ } elseif ( ! empty( $product['requires'] ) && ! file_exists( $this->wp_plugin_path . plugin_basename( $product['requires'] ) ) ) {
173
+ $status .= ' not-ready';
174
+ }
175
+
176
+ if ( WYSIJA::is_plugin_active( 'wysija-newsletters-premium/index.php' ) ) {
177
+ $status .= ' premium-active';
178
+ }
179
+
180
+ echo
181
+ '<div class="mailpoet-module' . esc_attr( $status ) . '" id="product">' .
182
+ '<h3>' . esc_attr( $product['name'] ) . '</h3>';
183
+
184
+ if ( ! empty( $product['thumbnail'] ) ) {
185
+ echo '<div class="mailpoet-module-image"><img src="' . esc_url( $this->image_url . $product['thumbnail'] ) . '" width="100%" title="' . esc_attr( $product['name'] ) . '" alt=""></div>';
186
+ }
187
+
188
+ echo
189
+ '<div class="mailpoet-module-content">' .
190
+ '<div class="mailpoet-module-description">' .
191
+ '<p>' . wp_kses( $product['description'], array() ) . '</p>';
192
+
193
+ if ( ! empty( $product['review'] ) ) {
194
+ echo '<p><strong>' . esc_attr__( 'MailPoet says: ', WYSIJA ) . '<em>' . esc_attr( $product['review'] ) . '</em>' . '</strong></p>';
195
+ }
196
+
197
+ if ( WYSIJA::is_plugin_active( 'wysija-newsletters-premium/index.php' ) && ! empty( $product['premium_offer'] ) ) {
198
+ echo '<p><strong>' . esc_attr( $product['premium_offer'] ) . '</strong></p>';
199
+ }
200
+ echo
201
+ '</div>' .
202
+ '</div>' .
203
+
204
+ '<div class="mailpoet-module-actions">';
205
+
206
+ if ( ! empty( $product['author_url'] ) ) {
207
+ echo '<a href="' . esc_url( $product['author_url'] ) . '" target="_blank" rel="external" class="button-primary website">' . esc_attr__( 'Website', WYSIJA ) . '</a>&nbsp;';
208
+ }
209
+
210
+ if ( $product['free'] == false && ! empty( $product['purchase_url'] ) ) {
211
+ if ( ! empty( $product['plugin_url'] ) && ! file_exists( $this->wp_plugin_path . plugin_basename( $product['plugin_url'] ) ) ) {
212
+ echo '<a href="' . esc_url( $product['purchase_url'] ) . '" target="_blank" rel="external" class="button-primary purchase">' . esc_attr__( 'Purchase', WYSIJA ) . '</a>&nbsp;';
213
+ } // end if plugin is installed, don't show purchase button.
214
+ } // end if product is not free.
215
+
216
+ if ( $product['service'] == false ){
217
+ if ( $product['on_wordpress.org'] == true ){
218
+ if ( ! file_exists( $this->wp_plugin_path . plugin_basename( $product['plugin_url'] ) ) ) {
219
+ echo '<a href="' . esc_url( admin_url( 'plugin-install.php?tab=search&type=term&s=' . strtolower( str_replace( ' ', '+', $product['search'] ) ) ) ) . '" class="button-primary install">' . esc_attr__( 'Install from WordPress.org', WYSIJA ) . '</a>&nbsp;';
220
+ }
221
+ } // end if $product['on_wordpress.org'];
222
+
223
+ if ( ! empty( $product['plugin_url'] ) && file_exists( $this->wp_plugin_path . plugin_basename( $product['plugin_url'] ) ) ) {
224
+ if ( ! WYSIJA::is_plugin_active( $product['plugin_url'] ) ) {
225
+ if ( ! empty( $product['requires'] ) ) {
226
+ $requires = '&amp;requires=' . $product['requires'] . '&amp;requires_name=' . $product['requires_name'];
227
+ } else {
228
+ $requires = '';
229
+ }
230
+ echo '<a href="' . esc_url( admin_url( 'admin.php?page=wysija_config&amp;action=activate&amp;module=' . $product['plugin_url'] . $requires ) ) . '" class="button-primary activate">' . esc_attr__( 'Activate', WYSIJA ) . '</a>&nbsp;';
231
+ } else {
232
+ if ( ! empty( $product['config_url'] ) ) {
233
+ echo '<a href="' . esc_url( $product['config_url'] ) . '" class="mailpoet-configure-button button-secondary">' . esc_attr__( 'Configure', WYSIJA ) . '</a>';
234
+ }
235
+ }
236
+ }
237
+ }
238
+
239
+ echo
240
+ '</div>' .
241
+ '</div>';
242
+ } // end if local is yes.
243
+
244
+ echo
245
+ '<div class="submit-idea">' .
246
+ '<p>' . wp_kses( sprintf( __( 'Don\'t see the add-on you\'re looking for? <a href="%s">Submit it</a> in our contact form.', WYSIJA ), 'http://www.mailpoet.com/contact/" target="blank' ), array( 'a' => array( 'href' => array() ) ) ) . '</p>' .
247
+ '</div>' .
248
+ '</div>';
249
+ }
250
+ } // end class
251
+
252
+ /**
253
+ * This loads the add ons class and displays the page.
254
+ *
255
+ * @init_mail_poet_add_ons();
256
+ * @add_ons_page();
257
+ */
258
+ function load_add_ons_manager(){
259
+ $mailpoet_add_ons = new MailPoet_Add_ons();
260
+ $mailpoet_add_ons->init_mail_poet_add_ons();
261
+ $mailpoet_add_ons->add_ons_page();
262
+ }
263
+ load_add_ons_manager();
{inc/wp-special → add-ons}/index.html RENAMED
File without changes
classes/WJ_Analytics.php CHANGED
@@ -1,347 +1,793 @@
1
  <?php
2
 
3
- /**
4
- * Class Analytics.
5
- *
6
- * It's a sort of useful stats and numbers generator about Wysija usage.
7
- * It also handles the MixPanel integration.
 
 
8
  */
9
  class WJ_Analytics {
10
 
11
- // Array: store all analytics data to be sent to JS.
12
- private $analytics_data = array(
13
- 'monthly_emails_sent' => '',
14
- 'lists_with_more_than_25' => '',
15
- 'confirmed_subscribers' => '',
16
- 'unconfirmed_subscribers' => '',
17
- 'standard_newsletters' => '',
18
- 'auto_newsletters' => '',
19
- 'wordpress_version' => '',
20
- 'plugin_version' => '',
21
- 'license_type' => '',
22
- 'sending_method' => '',
23
- 'smtp_hostname' => '',
24
- 'activation_email_status' => '',
25
- 'average_open_rate' => '',
26
- 'average_click_rate' => '',
27
- 'industry' => '',
28
- 'wordpress_language' => '',
29
- 'rtl' => '',
30
- 'beta' =>''
31
- );
32
-
33
- function __construct() {
34
-
35
- }
36
-
37
- /**
38
- * Send data to Mixpanel by enqueuing the analytics JS file.
39
- * @return
40
- */
41
- public function send() {
42
-
43
- // Enqueue analytics Javascript.
44
- wp_enqueue_script('analytics', WYSIJA_URL.'js/analytics.js',array(),WYSIJA::get_version());
45
- // Make analytics data available in JS.
46
- wp_localize_script('analytics', 'analytics_data', $this->analytics_data);
47
-
48
- }
49
-
50
- /**
51
- * Generate fresh data and store it in the $analytics_data Class property.
52
- * @return
53
- */
54
- public function generate_data() {
55
-
56
- $this->analytics_data['monthly_emails_sent'] = $this->get_monthly_emails_sent();
57
- $this->analytics_data['lists_with_more_than_25'] = $this->get_lists_with_more_than_25();
58
- $this->analytics_data['confirmed_subscribers'] = $this->get_confirmed_subscribers();
59
- $this->analytics_data['unconfirmed_subscribers'] = $this->get_unconfirmed_subscribers();
60
- $this->analytics_data['standard_newsletters'] = $this->get_standard_newsletters();
61
- $this->analytics_data['auto_newsletters'] = $this->get_auto_newsletters();
62
- $this->analytics_data['wordpress_version'] = get_bloginfo('version');
63
- $this->analytics_data['plugin_version'] = WYSIJA::get_version();
64
- $this->analytics_data['license_type'] = $this->get_license_type();
65
- $this->analytics_data['sending_method'] = $this->get_sending_method();
66
- $this->analytics_data['smtp_hostname'] = $this->get_smtp_hostname();
67
- $this->analytics_data['activation_email_status'] = $this->get_activation_email_status();
68
- $this->analytics_data['average_open_rate'] = $this->get_average_open_rate();
69
- $this->analytics_data['average_click_rate'] = $this->get_average_click_rate();
70
- $this->analytics_data['industry'] = $this->get_industry();
71
- $this->analytics_data['wordpress_language'] = get_bloginfo('language');
72
- $this->analytics_data['rtl'] = $this->get_rtl();
73
- $this->analytics_data['beta'] = $this->get_beta();
74
- }
75
-
76
- /**
77
- * Calculate Emails sent in the last 30 days.
78
- * @return Int
79
- */
80
- private function get_monthly_emails_sent() {
81
-
82
- $model_email_user_stat = WYSIJA::get('email_user_stat','model');
83
- $query = 'SELECT COUNT(*) as total_emails
84
- FROM ' . '[wysija]' . $model_email_user_stat->table_name. '
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
85
  WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= sent_at';
86
- $result = $model_email_user_stat->query('get_res', $query);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
87
 
88
- return $result[0]['total_emails'];
 
 
 
 
 
89
 
90
- }
 
 
 
 
 
91
 
92
- /**
93
- * Calculate lists with more than 25 subscribers.
94
- * @return Int
95
- */
96
- private function get_lists_with_more_than_25() {
97
 
98
- $model_user_list = WYSIJA::get('user_list','model');
99
- $query = 'SELECT list_id, COUNT(*) as count
100
- FROM ' . '[wysija]' . $model_user_list->table_name. '
101
  GROUP BY list_id
102
  HAVING COUNT(*) >= 25';
103
- $result = $model_user_list->query('get_res', $query);
104
- $lists_count = count($result);
 
 
 
105
 
106
- return $lists_count;
 
 
 
 
107
 
108
- }
 
 
 
109
 
110
- /**
111
- * Calculate confirmed subscribers.
112
- * @return Int
113
- */
114
- private function get_confirmed_subscribers() {
 
 
 
115
 
116
- $model_user = WYSIJA::get('user','model');
117
- $query = 'SELECT COUNT(*) as confirmed_subscribers
118
- FROM ' . '[wysija]' . $model_user->table_name. '
119
  WHERE status = 1';
120
- $result = $model_user->query('get_res', $query);
121
 
122
- return $result[0]['confirmed_subscribers'];
 
 
123
 
124
- }
 
125
 
126
- /**
127
- * Calculate unconfirmed subscribers.
128
- * @return Int
129
- */
130
- public function get_unconfirmed_subscribers() {
131
 
132
- $model_user = WYSIJA::get('user','model');
133
- $query = 'SELECT COUNT(*) as unconfirmed_subscribers
134
- FROM ' . '[wysija]' . $model_user->table_name. '
135
  WHERE status = 0';
136
- $result = $model_user->query('get_res', $query);
137
-
138
- return $result[0]['unconfirmed_subscribers'];
139
 
140
- }
 
141
 
142
- /**
143
- * Calculate standard newsletters total.
144
- * @return Int
145
- */
146
- private function get_standard_newsletters() {
147
 
148
- $model_email = WYSIJA::get('email','model');
149
- $query = 'SELECT COUNT(*) as standard_newsletters
150
- FROM ' . '[wysija]' . $model_email->table_name. '
151
  WHERE type = 1
152
  AND status = 2';
153
- $result = $model_email->query('get_res', $query);
154
-
155
- return $result[0]['standard_newsletters'];
156
 
157
- }
 
158
 
159
- /**
160
- * Calculate auto newsletters total.
161
- * @return Int
162
- */
163
- private function get_auto_newsletters() {
164
 
165
- $model_email = WYSIJA::get('email','model');
166
- $query = 'SELECT COUNT(*) as auto_newsletters
167
- FROM ' . '[wysija]' . $model_email->table_name. '
168
  WHERE type = 2';
169
- $result = $model_email->query('get_res', $query);
170
 
171
- return $result[0]['auto_newsletters'];
 
172
 
173
- }
 
 
 
 
174
 
175
- /**
176
- * Check license type in use.
177
- * @return String Free | Premium
178
- */
179
- private function get_license_type() {
 
 
 
 
 
 
180
 
181
- $model_config = WYSIJA::get('config','model');
182
- $is_premium = $model_config->getValue('premium_key');
 
 
 
183
 
184
- if ($is_premium) {
185
- $license_type = 'Premium';
186
- } else {
187
- $license_type = 'Free';
188
  }
189
 
190
- return $license_type;
 
 
 
 
191
 
192
- }
 
 
193
 
194
- /**
195
- * Get sending method in use.
196
- * @return String
197
- */
198
- private function get_sending_method() {
199
 
200
- $model_config = WYSIJA::get('config','model');
201
- return $model_config->getValue('sending_method');
202
 
203
- }
 
 
 
 
204
 
205
- /**
206
- * Get smtp hostname in use.
207
- * @return String
208
- */
209
- private function get_smtp_hostname() {
210
 
211
- $model_config = WYSIJA::get('config','model');
212
- return $model_config->getValue('smtp_host');
 
 
 
 
 
 
 
 
 
 
 
 
213
 
214
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
215
 
216
- /**
217
- * Get activation email status.
218
- * @return String On | Off
219
- */
220
- private function get_activation_email_status() {
 
 
 
 
 
 
 
 
 
221
 
222
- $model_config = WYSIJA::get('config','model');
223
- $activation_email_status = $model_config->getValue('confirm_dbleoptin');
 
 
 
 
 
 
 
 
 
 
 
 
224
 
225
- if ($activation_email_status === 1) {
226
- $result = 'On';
227
- } else {
228
- $result = 'Off';
 
 
 
 
 
 
 
 
 
229
  }
230
 
231
- return $result;
 
 
 
 
 
 
 
 
 
 
 
 
 
232
 
233
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
234
 
235
- /**
236
- * Calculate average open rate.
237
- * @return Int
238
- */
239
- private function get_average_open_rate() {
240
 
241
- $model_email_user_stat = WYSIJA::get('email_user_stat','model');
242
- $query = 'SELECT COUNT(*) as opened_emails
243
- FROM ' . '[wysija]' . $model_email_user_stat->table_name. '
244
  WHERE status = 1';
245
- $result = $model_email_user_stat->query('get_res', $query);
246
 
247
- $opened_emails = $result[0]['opened_emails'];
248
- $total_emails = $this->get_total_emails_sent();
249
 
250
- if ($total_emails === 0) {
251
- $average_open_rate = 0;
252
- } else {
253
- $average_open_rate = round(($opened_emails * 100) / $total_emails);
 
 
 
254
  }
255
 
256
- return $average_open_rate;
 
 
 
 
 
 
 
 
 
 
257
 
258
- }
 
259
 
260
- /**
261
- * Calculate average click rate.
262
- * @return String opened/total
263
- */
264
- private function get_average_click_rate() {
265
 
266
- $model_email_user_stat = WYSIJA::get('email_user_stat','model');
267
- $query = 'SELECT COUNT(*) as clicked_emails
268
- FROM ' . '[wysija]' . $model_email_user_stat->table_name. '
269
- WHERE status = 2';
270
- $result = $model_email_user_stat->query('get_res', $query);
 
 
 
 
 
 
 
 
271
 
272
- $clicked_emails = $result[0]['clicked_emails'];
273
- $total_emails = $this->get_total_emails_sent();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
274
 
275
- if ($total_emails === 0) {
276
- $average_click_rate = 0;
277
- } else {
278
- $average_click_rate = round(($clicked_emails * 100) / $total_emails);
 
 
 
279
  }
280
 
281
- return $average_click_rate;
 
 
 
 
282
 
283
- }
 
 
 
 
284
 
 
 
285
 
286
- /**
287
- * Get all emails sent.
288
- * @return Int
289
- */
290
- private function get_total_emails_sent() {
291
 
292
- $model_email_user_stat = WYSIJA::get('email_user_stat','model');
293
- $query = 'SELECT COUNT(*) as all_emails
294
- FROM ' . '[wysija]' . $model_email_user_stat->table_name. '';
295
- $result = $model_email_user_stat->query('get_res', $query);
 
296
 
297
- return $result[0]['all_emails'];
 
298
 
299
- }
 
 
 
 
300
 
301
- /**
302
- * Get Industry specified in the settings page.
303
- * @return String
304
- */
305
- private function get_industry() {
306
 
307
- $model_config = WYSIJA::get('config','model');
 
 
 
 
308
 
309
- return $model_config->getValue('industry');
 
310
 
311
- }
 
 
 
 
312
 
313
- /**
314
- * Get if is using right to left language.
315
- * @return String
316
- */
317
- private function get_rtl() {
318
 
319
- if (is_rtl()) {
320
- $is_rtl = 'Yes';
321
- } else {
322
- $is_rtl = 'No';
 
 
 
323
  }
324
 
325
- return $is_rtl;
 
 
 
 
 
 
 
 
 
 
 
 
326
 
327
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
328
 
329
- /**
330
- * Get if is using beta mode
331
- * @return String
332
- */
333
- private function get_beta() {
 
 
 
 
 
 
 
 
 
 
 
 
 
334
 
335
- $model_config = WYSIJA::get('config','model');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
336
 
337
- if ($model_config->getValue('beta_mode')) {
338
- $is_beta = 'Yes';
339
- } else {
340
- $is_beta = 'No';
 
 
 
 
 
 
 
 
 
 
 
 
 
341
  }
342
 
343
- return $is_beta;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
344
 
345
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
346
 
347
- }
1
  <?php
2
 
3
+ /*
4
+ Class Analytics.
5
+ It's a sort of useful stats and numbers generator about MailPoet usage.
6
+ It also handles the MixPanel integration.
7
+ $analytics = new WJ_Analytics();
8
+ $analytics->generate_data();
9
+ $analytics->send();
10
  */
11
  class WJ_Analytics {
12
 
13
+ // All analytics data to be sent to JS.
14
+ private $analytics_data = array(
15
+ 'monthly_emails_sent' => array(
16
+ 'label' => 'Monthly emails sent',
17
+ 'value' => ''
18
+ ),
19
+ 'lists_with_more_than_25' => array(
20
+ 'label' => 'Lists with more than 25 subscribers',
21
+ 'value' => ''
22
+ ),
23
+ 'confirmed_subscribers' => array(
24
+ 'label' => 'Confirmed subscribers',
25
+ 'value' => ''
26
+ ),
27
+ 'unconfirmed_subscribers' => array(
28
+ 'label' => 'Unconfirmed subscribers',
29
+ 'value' => ''
30
+ ),
31
+ 'standard_newsletters' => array(
32
+ 'label' => 'Standard newsletters',
33
+ 'value' => ''
34
+ ),
35
+ 'auto_newsletters' => array(
36
+ 'label' => 'Auto newsletters',
37
+ 'value' => ''
38
+ ),
39
+ 'wordpress_version' => array(
40
+ 'label' => 'WordPress Version',
41
+ 'value' => ''
42
+ ),
43
+ 'plugin_version' => array(
44
+ 'label' => 'Plugin Version',
45
+ 'value' => ''
46
+ ),
47
+ 'license_type' => array(
48
+ 'label' => 'License type',
49
+ 'value' => ''
50
+ ),
51
+ 'sending_method' => array(
52
+ 'label' => 'Sending method',
53
+ 'value' => ''
54
+ ),
55
+ 'smtp_hostname' => array(
56
+ 'label' => 'Smtp hostname',
57
+ 'value' => ''
58
+ ),
59
+ 'activation_email_status' => array(
60
+ 'label' => 'Activation Email',
61
+ 'value' => ''
62
+ ),
63
+ 'average_open_rate' => array(
64
+ 'label' => 'Open rate',
65
+ 'value' => ''
66
+ ),
67
+ 'average_click_rate' => array(
68
+ 'label' => 'Click rate',
69
+ 'value' => ''
70
+ ),
71
+ 'industry' => array(
72
+ 'label' => 'Industry',
73
+ 'value' => ''
74
+ ),
75
+ 'wordpress_language' => array(
76
+ 'label' => 'WordPress Language',
77
+ 'value' => ''
78
+ ),
79
+ 'rtl' => array(
80
+ 'label' => 'Rtl',
81
+ 'value' => ''
82
+ ),
83
+ 'beta' => array(
84
+ 'label' => 'Beta',
85
+ 'value' => ''
86
+ ),
87
+ 'archive_page' => array(
88
+ 'label' => 'Archive Page',
89
+ 'value' => ''
90
+ ),
91
+ 'dkim_status' => array(
92
+ 'label' => 'DKIM Active',
93
+ 'value' => ''
94
+ ),
95
+ 'subscribe_in_comments' => array(
96
+ 'label' => 'Subscribe in comments',
97
+ 'value' => ''
98
+ ),
99
+ 'subscribe_on_register' => array(
100
+ 'label' => 'Subscribe on registration',
101
+ 'value' => ''
102
+ ),
103
+ 'browser_link' => array(
104
+ 'label' => 'View in browser link',
105
+ 'value' => ''
106
+ ),
107
+ 'profile_edit'=> array(
108
+ 'label' => 'Subcsribers can edit profile',
109
+ 'value' => ''
110
+ ),
111
+ 'html_edit' => array(
112
+ 'label' => 'Allow HTML edit',
113
+ 'value' => ''
114
+ ),
115
+ 'mailpoet_cron' => array(
116
+ 'label' => 'MailPoet Cron Enabled',
117
+ 'value' => ''
118
+ ),
119
+ 'forms_number' => array(
120
+ 'label' => 'Total number of forms',
121
+ 'value' => ''
122
+ ),
123
+ 'using_custom_fields' => array(
124
+ 'label' => 'Using custom fields',
125
+ 'value' => ''
126
+ ),
127
+ 'custom_fields_input' => array(
128
+ 'label' => 'Custom Fields: Input field',
129
+ 'value' => ''
130
+ ),
131
+ 'custom_fields_textarea' => array(
132
+ 'label' => 'Custom Fields: Textarea',
133
+ 'value' => ''
134
+ ),
135
+ 'custom_fields_select' => array(
136
+ 'label' => 'Custom Fields: Select',
137
+ 'value' => ''
138
+ ),
139
+ 'custom_fields_checkbox' => array(
140
+ 'label' => 'Custom Fields: Checkbox',
141
+ 'value' => ''
142
+ ),
143
+ 'custom_fields_radio' => array(
144
+ 'label' => 'Custom Fields: Radio',
145
+ 'value' => ''
146
+ ),
147
+ 'active_last_week' => array(
148
+ 'label' => 'Active last week',
149
+ 'value' => ''
150
+ ),
151
+ 'is_multisite' => array(
152
+ 'label' => 'Using Multisite',
153
+ 'value' => ''
154
+ )
155
+ );
156
+
157
+ function __construct() {
158
+
159
+ }
160
+
161
+ /**
162
+ * Send data to Mixpanel by enqueuing the analytics JS file.
163
+ * @return
164
+ */
165
+ public function send() {
166
+
167
+ // Enqueue analytics Javascript.
168
+ wp_enqueue_script('analytics', WYSIJA_URL . 'js/analytics.js', array(), WYSIJA::get_version());
169
+ // Make analytics data available in JS.
170
+ wp_localize_script('analytics', 'analytics_data', $this->analytics_data);
171
+ }
172
+
173
+ /**
174
+ * Generate fresh data and store it in the $analytics_data Class property.
175
+ * @return
176
+ */
177
+ public function generate_data() {
178
+
179
+ foreach ($this->analytics_data as $key => $data) {
180
+ $method = $key;
181
+ $this->analytics_data[$key]['value'] = $this->$method();
182
+ }
183
+
184
+ }
185
+
186
+ /**
187
+ * Calculate Emails sent in the last 30 days.
188
+ * @return Int
189
+ */
190
+ private function monthly_emails_sent() {
191
+
192
+ $model_email_user_stat = WYSIJA::get('email_user_stat', 'model');
193
+ $query = 'SELECT COUNT(*) as total_emails
194
+ FROM ' . '[wysija]' . $model_email_user_stat->table_name . '
195
  WHERE DATE_SUB(CURDATE(),INTERVAL 30 DAY) <= sent_at';
196
+ $result = $model_email_user_stat->query('get_res', $query);
197
+
198
+ $total_emails = $result[0]['total_emails'];
199
+ switch (true) {
200
+ case ($total_emails <= 1000):
201
+ $track = 'Less than 1000';
202
+ break;
203
+ case ((1001 <= $total_emails) && ($total_emails <= 2500)):
204
+ $track = '1001 to 2500';
205
+ break;
206
+ case ((2501 <= $total_emails) && ($total_emails <= 5000)):
207
+ $track = '2501 to 5000';
208
+ break;
209
+ case ((5001 <= $total_emails) && ($total_emails <= 10000)):
210
+ $track = '5001 to 10000';
211
+ break;
212
+ case ((10001 <= $total_emails) && ($total_emails <= 25000)):
213
+ $track = '10001 to 25000';
214
+ break;
215
+ case ((25001 <= $total_emails) && ($total_emails <= 50000)):
216
+ $track = '25001 to 50000';
217
+ break;
218
+ case ((50001 <= $total_emails) && ($total_emails <= 100000)):
219
+ $track = '50001 to 100000';
220
+ break;
221
+ case (100001 <= $total_emails):
222
+ $track = 'More than 100001';
223
+ break;
224
+ default:
225
+ $track = 'No emails sent';
226
+ break;
227
+ }
228
+
229
+ return $track;
230
+
231
+ }
232
+
233
+ /*
234
+ Pass through the WordPress version.
235
+ */
236
+ private function wordpress_version() {
237
+ return get_bloginfo('version');
238
+ }
239
 
240
+ /*
241
+ Pass through the WordPress language.
242
+ */
243
+ private function wordpress_language() {
244
+ return get_bloginfo('language');
245
+ }
246
 
247
+ /*
248
+ The plugin version.
249
+ */
250
+ private function plugin_version() {
251
+ return WYSIJA::get_version();
252
+ }
253
 
254
+ /**
255
+ * Calculate lists with more than 25 subscribers.
256
+ * @return Int
257
+ */
258
+ private function lists_with_more_than_25() {
259
 
260
+ $model_user_list = WYSIJA::get('user_list', 'model');
261
+ $query = 'SELECT list_id, COUNT(*) as count
262
+ FROM ' . '[wysija]' . $model_user_list->table_name . '
263
  GROUP BY list_id
264
  HAVING COUNT(*) >= 25';
265
+ $result = $model_user_list->query('get_res', $query);
266
+ $lists_count = count($result);
267
+
268
+ return $lists_count;
269
+ }
270
 
271
+ /**
272
+ * Calculate total subscribers.
273
+ * @return Int
274
+ */
275
+ private function total_subcsribers() {
276
 
277
+ $model_user = WYSIJA::get('user', 'model');
278
+ $query = 'SELECT COUNT(*) as total_subscribers
279
+ FROM ' . '[wysija]' . $model_user->table_name;
280
+ $result = $model_user->query('get_res', $query);
281
 
282
+ return $result[0]['total_subscribers'];
283
+ }
284
+
285
+ /**
286
+ * Calculate confirmed subscribers.
287
+ * @return Int
288
+ */
289
+ private function confirmed_subscribers() {
290
 
291
+ $model_user = WYSIJA::get('user', 'model');
292
+ $query = 'SELECT COUNT(*) as confirmed_subscribers
293
+ FROM ' . '[wysija]' . $model_user->table_name . '
294
  WHERE status = 1';
295
+ $result = $model_user->query('get_res', $query);
296
 
297
+ $confirmed_subscribers = $result[0]['confirmed_subscribers'];
298
+ $total_subscribers = $this->total_subcsribers();
299
+ $confirmed_percentage = round(($confirmed_subscribers * 100) / $total_subscribers);
300
 
301
+ return $confirmed_percentage;
302
+ }
303
 
304
+ /**
305
+ * Calculate unconfirmed subscribers.
306
+ * @return Int
307
+ */
308
+ public function unconfirmed_subscribers() {
309
 
310
+ $model_user = WYSIJA::get('user', 'model');
311
+ $query = 'SELECT COUNT(*) as unconfirmed_subscribers
312
+ FROM ' . '[wysija]' . $model_user->table_name . '
313
  WHERE status = 0';
314
+ $result = $model_user->query('get_res', $query);
 
 
315
 
316
+ return $result[0]['unconfirmed_subscribers'];
317
+ }
318
 
319
+ /**
320
+ * Calculate standard newsletters total.
321
+ * @return Int
322
+ */
323
+ private function standard_newsletters() {
324
 
325
+ $model_email = WYSIJA::get('email', 'model');
326
+ $query = 'SELECT COUNT(*) as standard_newsletters
327
+ FROM ' . '[wysija]' . $model_email->table_name . '
328
  WHERE type = 1
329
  AND status = 2';
330
+ $result = $model_email->query('get_res', $query);
 
 
331
 
332
+ return $result[0]['standard_newsletters'];
333
+ }
334
 
335
+ /**
336
+ * Calculate auto newsletters total.
337
+ * @return Int
338
+ */
339
+ private function auto_newsletters() {
340
 
341
+ $model_email = WYSIJA::get('email', 'model');
342
+ $query = 'SELECT COUNT(*) as auto_newsletters
343
+ FROM ' . '[wysija]' . $model_email->table_name . '
344
  WHERE type = 2';
345
+ $result = $model_email->query('get_res', $query);
346
 
347
+ return $result[0]['auto_newsletters'];
348
+ }
349
 
350
+ /**
351
+ * Check license type in use.
352
+ * @return String Free | Premium
353
+ */
354
+ private function license_type() {
355
 
356
+ $model_config = WYSIJA::get('config', 'model');
357
+ $is_premium = $model_config->getValue('premium_key');
358
+
359
+ if ($is_premium) {
360
+ $license_type = 'Premium';
361
+ } else {
362
+ $license_type = 'Free';
363
+ }
364
+
365
+ return $license_type;
366
+ }
367
 
368
+ /**
369
+ * Get sending method in use.
370
+ * @return String
371
+ */
372
+ private function sending_method() {
373
 
374
+ $model_config = WYSIJA::get('config', 'model');
375
+ return $model_config->getValue('sending_method');
 
 
376
  }
377
 
378
+ /**
379
+ * Get smtp hostname in use.
380
+ * @return String
381
+ */
382
+ private function smtp_hostname() {
383
 
384
+ $model_config = WYSIJA::get('config', 'model');
385
+ return $model_config->getValue('smtp_host');
386
+ }
387
 
388
+ /**
389
+ * Get activation email status.
390
+ * @return String On | Off
391
+ */
392
+ private function activation_email_status() {
393
 
394
+ $model_config = WYSIJA::get('config', 'model');
395
+ $activation_email_status = $model_config->getValue('confirm_dbleoptin');
396
 
397
+ if ($activation_email_status === 1) {
398
+ $result = 'On';
399
+ } else {
400
+ $result = 'Off';
401
+ }
402
 
403
+ return $result;
404
+ }
 
 
 
405
 
406
+ /**
407
+ * Get DKIM status.
408
+ * @return String Yes | No
409
+ */
410
+ private function dkim_status() {
411
+ $model_config = WYSIJA::get('config', 'model');
412
+ $dkim_status = $model_config->getValue('dkim_active');
413
+ if ($dkim_status === 1) {
414
+ $result = 'Yes';
415
+ } else {
416
+ $result = 'No';
417
+ }
418
+ return $result;
419
+ }
420
 
421
+ /**
422
+ * Get subscribe in comments.
423
+ * @return String Yes | No
424
+ */
425
+ private function subscribe_in_comments() {
426
+ $model_config = WYSIJA::get('config', 'model');
427
+ $subscribe_in_comments = $model_config->getValue('commentform');
428
+ if ($subscribe_in_comments == 1) {
429
+ $result = 'Yes';
430
+ } else {
431
+ $result = 'No';
432
+ }
433
+ return $result;
434
+ }
435
 
436
+ /**
437
+ * Get subscribe during registration option.
438
+ * @return String Yes | No
439
+ */
440
+ private function subscribe_on_register() {
441
+ $model_config = WYSIJA::get('config', 'model');
442
+ $subscribe_on_register = $model_config->getValue('registerform');
443
+ if ($subscribe_on_register == 1) {
444
+ $result = 'Yes';
445
+ } else {
446
+ $result = 'No';
447
+ }
448
+ return $result;
449
+ }
450
 
451
+ /**
452
+ * Get view in browser option.
453
+ * @return String Yes | No
454
+ */
455
+ private function browser_link() {
456
+ $model_config = WYSIJA::get('config', 'model');
457
+ $browser_link = $model_config->getValue('viewinbrowser');
458
+ if ($browser_link == 1) {
459
+ $result = 'Yes';
460
+ } else {
461
+ $result = 'No';
462
+ }
463
+ return $result;
464
+ }
465
 
466
+ /**
467
+ * Get profile edit option.
468
+ * @return String Yes | No
469
+ */
470
+ private function profile_edit() {
471
+ $model_config = WYSIJA::get('config', 'model');
472
+ $profile_edit = $model_config->getValue('manage_subscriptions');
473
+ if ($profile_edit == 1) {
474
+ $result = 'Yes';
475
+ } else {
476
+ $result = 'No';
477
+ }
478
+ return $result;
479
  }
480
 
481
+ /**
482
+ * Get html edit in newsletter option.
483
+ * @return String Yes | No
484
+ */
485
+ private function html_edit() {
486
+ $model_config = WYSIJA::get('config', 'model');
487
+ $html_edit = $model_config->getValue('html_source');
488
+ if ($html_edit == 1) {
489
+ $result = 'Yes';
490
+ } else {
491
+ $result = 'No';
492
+ }
493
+ return $result;
494
+ }
495
 
496
+ /**
497
+ * Get mailpoet cron option.
498
+ * @return String Yes | No
499
+ */
500
+ private function mailpoet_cron() {
501
+ $model_config = WYSIJA::get('config', 'model');
502
+ $cron_option = $model_config->getValue('cron_manual');
503
+ if ($cron_option == 1) {
504
+ $result = 'Yes';
505
+ } else {
506
+ $result = 'No';
507
+ }
508
+ return $result;
509
+ }
510
 
511
+ /**
512
+ * Calculate average open rate.
513
+ * @return Int
514
+ */
515
+ private function average_open_rate() {
516
 
517
+ $model_email_user_stat = WYSIJA::get('email_user_stat', 'model');
518
+ $query = 'SELECT COUNT(*) as opened_emails
519
+ FROM ' . '[wysija]' . $model_email_user_stat->table_name . '
520
  WHERE status = 1';
521
+ $result = $model_email_user_stat->query('get_res', $query);
522
 
523
+ $opened_emails = $result[0]['opened_emails'];
524
+ $total_emails = $this->total_emails_sent();
525
 
526
+ if ($total_emails == 0) {
527
+ $average_open_rate = 0;
528
+ } else {
529
+ $average_open_rate = round(($opened_emails * 100) / $total_emails);
530
+ }
531
+
532
+ return $average_open_rate;
533
  }
534
 
535
+ /**
536
+ * Calculate average click rate.
537
+ * @return String opened/total
538
+ */
539
+ private function average_click_rate() {
540
+
541
+ $model_email_user_stat = WYSIJA::get('email_user_stat', 'model');
542
+ $query = 'SELECT COUNT(*) as clicked_emails
543
+ FROM ' . '[wysija]' . $model_email_user_stat->table_name . '
544
+ WHERE status = 2';
545
+ $result = $model_email_user_stat->query('get_res', $query);
546
 
547
+ $clicked_emails = $result[0]['clicked_emails'];
548
+ $total_emails = $this->total_emails_sent();
549
 
550
+ if ($total_emails == 0) {
551
+ $average_click_rate = 0;
552
+ } else {
553
+ $average_click_rate = round(($clicked_emails * 100) / $total_emails);
554
+ }
555
 
556
+ return $average_click_rate;
557
+ }
558
+
559
+ /**
560
+ * Get all emails sent.
561
+ * @return Int
562
+ */
563
+ private function total_emails_sent() {
564
+
565
+ $model_email_user_stat = WYSIJA::get('email_user_stat', 'model');
566
+ $query = 'SELECT COUNT(*) as all_emails
567
+ FROM ' . '[wysija]' . $model_email_user_stat->table_name . '';
568
+ $result = $model_email_user_stat->query('get_res', $query);
569
 
570
+ return $result[0]['all_emails'];
571
+ }
572
+
573
+ /**
574
+ * Get total number of forms.
575
+ * @return Int
576
+ */
577
+ private function forms_number() {
578
+
579
+ $model_form = WYSIJA::get('forms', 'model');
580
+ $query = 'SELECT COUNT(*) as forms_number
581
+ FROM ' . '[wysija]' . $model_form->table_name . '';
582
+ $result = $model_form->query('get_res', $query);
583
+
584
+ return $result[0]['forms_number'];
585
+ }
586
 
587
+ /**
588
+ * Get Industry specified in the settings page.
589
+ * @return String
590
+ */
591
+ public function industry() {
592
+ $model_config = WYSIJA::get('config', 'model');
593
+ return $model_config->getValue('industry');
594
  }
595
 
596
+ /**
597
+ * Get if is using right to left language.
598
+ * @return String
599
+ */
600
+ private function rtl() {
601
 
602
+ if (is_rtl()) {
603
+ $is_rtl = 'Yes';
604
+ } else {
605
+ $is_rtl = 'No';
606
+ }
607
 
608
+ return $is_rtl;
609
+ }
610
 
611
+ /**
612
+ * Check if it's multisite.
613
+ * @return String
614
+ */
615
+ private function is_multisite() {
616
 
617
+ if (is_multisite()) {
618
+ $is_multisite = 'Yes';
619
+ } else {
620
+ $is_multisite = 'No';
621
+ }
622
 
623
+ return $is_multisite;
624
+ }
625
 
626
+ /**
627
+ * Get if is using beta mode
628
+ * @return String
629
+ */
630
+ private function beta() {
631
 
632
+ $model_config = WYSIJA::get('config', 'model');
 
 
 
 
633
 
634
+ if ($model_config->getValue('beta_mode')) {
635
+ $is_beta = 'Yes';
636
+ } else {
637
+ $is_beta = 'No';
638
+ }
639
 
640
+ return $is_beta;
641
+ }
642
 
643
+ /**
644
+ * Checks if user used the archive page feature.
645
+ * @return String true | false
646
+ */
647
+ private function archive_page() {
648
 
649
+ $model_config = WYSIJA::get('config', 'model');
650
+ $archive_lists = $model_config->getValue('archive_lists');
 
 
 
651
 
652
+ if (!empty($archive_lists)) {
653
+ $used_archive = 'true';
654
+ } else {
655
+ $used_archive = 'false';
656
+ }
657
+
658
+ return $used_archive;
659
  }
660
 
661
+ /*
662
+ Check if user is using custom fields or not.
663
+ # => Yes | No
664
+ */
665
+ private function using_custom_fields() {
666
+ $fields = WJ_Field::get_all();
667
+ if ($fields != null) {
668
+ $result = 'Yes';
669
+ } else {
670
+ $result = 'No';
671
+ }
672
+ return $result;
673
+ }
674
 
675
+ /*
676
+ How many input custom fields are in use.
677
+ # => int | null
678
+ */
679
+ private function custom_fields_input() {
680
+ global $wpdb;
681
+ $field = new WJ_Field();
682
+ $table_name = $field->get_table_name();
683
+ $result = $wpdb->get_var(
684
+ "SELECT COUNT(*) as inputs
685
+ FROM $table_name
686
+ WHERE type = 'input'"
687
+ );
688
+ if ($result == null) {
689
+ $result = '0';
690
+ }
691
+ return $result;
692
+ }
693
 
694
+ /*
695
+ How many textarea custom fields are in use.
696
+ # => int | null
697
+ */
698
+ private function custom_fields_textarea() {
699
+ global $wpdb;
700
+ $field = new WJ_Field();
701
+ $table_name = $field->get_table_name();
702
+ $result = $wpdb->get_var(
703
+ "SELECT COUNT(*) as textareas
704
+ FROM $table_name
705
+ WHERE type = 'textarea'"
706
+ );
707
+ if ($result == null) {
708
+ $result = '0';
709
+ }
710
+ return $result;
711
+ }
712
 
713
+ /*
714
+ How many select custom fields are in use.
715
+ # => int | null
716
+ */
717
+ private function custom_fields_select() {
718
+ global $wpdb;
719
+ $field = new WJ_Field();
720
+ $table_name = $field->get_table_name();
721
+ $result = $wpdb->get_var(
722
+ "SELECT COUNT(*) as selects
723
+ FROM $table_name
724
+ WHERE type = 'select'"
725
+ );
726
+ if ($result == null) {
727
+ $result = '0';
728
+ }
729
+ return $result;
730
+ }
731
 
732
+ /*
733
+ How many checkbox custom fields are in use.
734
+ # => int | null
735
+ */
736
+ private function custom_fields_checkbox() {
737
+ global $wpdb;
738
+ $field = new WJ_Field();
739
+ $table_name = $field->get_table_name();
740
+ $result = $wpdb->get_var(
741
+ "SELECT COUNT(*) as checkboxes
742
+ FROM $table_name
743
+ WHERE type = 'checkbox'"
744
+ );
745
+ if ($result == null) {
746
+ $result = '0';
747
+ }
748
+ return $result;
749
  }
750
 
751
+ /*
752
+ How many checkbox custom fields are in use.
753
+ # => int | null
754
+ */
755
+ private function custom_fields_radio() {
756
+ global $wpdb;
757
+ $field = new WJ_Field();
758
+ $table_name = $field->get_table_name();
759
+ $result = $wpdb->get_var(
760
+ "SELECT COUNT(*) as radios
761
+ FROM $table_name
762
+ WHERE type = 'radio'"
763
+ );
764
+ if ($result == null) {
765
+ $result = '0';
766
+ }
767
+ return $result;
768
+ }
769
 
770
+ /*
771
+ Check if user has been active in the last week.
772
+ This means he sent at least one email.
773
+ # => Yes | No
774
+ */
775
+ private function active_last_week() {
776
+ global $wpdb;
777
+ $model_stats = WYSIJA::get('email_user_stat', 'model');
778
+ $table_name = '[wysija]' . $model_stats->table_name;
779
+
780
+ $query = 'SELECT COUNT(*) as activities
781
+ FROM ' . $table_name .
782
+ ' WHERE sent_at > UNIX_TIMESTAMP(date_sub(now(), interval 1 week))';
783
+
784
+ $result = $model_stats->query('get_res', $query);
785
+ $result = $result[0]['activities'];
786
+
787
+ if ($result > 0) {
788
+ return 'Yes';
789
+ }
790
+ return 'No';
791
+ }
792
 
793
+ }
classes/WJ_Export.php ADDED
@@ -0,0 +1,216 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class Export.
5
+ *
6
+ * Exporting subscribers
7
+ */
8
+ class WJ_Export extends WYSIJA_object {
9
+
10
+ private $_file_header = '';
11
+ private $_file_handle = null;
12
+ private $_user_ids_rows = 0;
13
+ private $_user_ids = array();
14
+ private $_fields = array();
15
+ private $_export_batch = 2000;
16
+ private $_filter_list = '';
17
+ private $_filter_confirmed = '';
18
+ private $_fields_separator = ';';
19
+ private $_lines_separator = "\n";
20
+ private $_base_encode = 'UTF-8';
21
+ private $_output_encode = 'UTF-8//TRANSLIT//IGNORE';
22
+
23
+ //needed for tung's batch actions
24
+ public $batch_select = null;
25
+
26
+ function __construct() {
27
+ if ( ! empty( $_POST['wysija']['export']['fields'] ) ) {
28
+ $this->_fields = $_POST['wysija']['export']['fields'];
29
+ }
30
+
31
+ if ( ! empty( $_POST['wysija']['export']['user_ids'] ) ) {
32
+ $this->_user_ids = $this->_get_posted_user_ids();
33
+ }
34
+ if ( ! empty($_POST['wysija']['export']['filter']['list'] ) ) {
35
+ $this->_filter_list = $_POST['wysija']['export']['filter']['list'];
36
+ }
37
+
38
+ // how do we separate the values in the files commas or semy colons ?
39
+ if ( ! empty($_POST['wysija']['export']['format'] ) ) {
40
+ $this->_fields_separator = $_POST['wysija']['export']['format'];
41
+ }
42
+
43
+ if ( ! empty($_POST['wysija']['export']['filter']['confirmed'] ) ) {
44
+ $this->_filter_confirmed = $_POST['wysija']['export']['filter']['confirmed'];
45
+ }
46
+ }
47
+
48
+ /**
49
+ * export the subscribers
50
+ * @return type
51
+ */
52
+ public function export_subscribers() {
53
+
54
+ //generate temp file
55
+ $helper_file = WYSIJA::get( 'file', 'helper' );
56
+ $this->_prepare_headers();
57
+ $result_file = $helper_file->temp( $this->_file_header, 'export', '.csv' );
58
+
59
+ //open the created file in append mode
60
+ $this->_file_handle = fopen( $result_file['path'], 'a' );
61
+
62
+ //get a list of user_ids to export
63
+ if ( ! empty( $this->_user_ids ) && empty( $this->batch_select ) ) {
64
+
65
+ $this->_user_ids_rows = count( $this->_user_ids );
66
+ $this->_push_data_to_export_file();
67
+ } else {
68
+
69
+ $this->_get_chunks_user_ids();
70
+ }
71
+
72
+ fclose( $this->_file_handle );
73
+ return $result_file['path'];
74
+ }
75
+
76
+ /**
77
+ * get the number of rows exported
78
+ * @return type
79
+ */
80
+ public function get_user_ids_rows() {
81
+ return $this->_user_ids_rows;
82
+ }
83
+
84
+ /**
85
+ * get an array of user_ids from the global $_POST
86
+ * @return type
87
+ */
88
+ private function _get_posted_user_ids() {
89
+ return unserialize( base64_decode( $_POST['wysija']['export']['user_ids'] ) );
90
+ }
91
+
92
+ /**
93
+ * get the query used to select a bung of ids
94
+ * @return string
95
+ */
96
+ private function _get_query_users_ids() {
97
+
98
+ // based on filters prepare a query to get a list of user_ids
99
+ if ( ! empty( $this->batch_select ) ) { // batch select and export
100
+ $this->_user_ids_rows = $this->batch_select['count'];
101
+ $qry = $this->batch_select['original_query'];
102
+ } else { // export all list
103
+ // prepare the filters
104
+ $filters = array();
105
+ if ( ! empty( $this->_filter_list ) ) {
106
+ if ( ! is_array( $this->_filter_list ) ) {
107
+ $this->_filter_list = array( $this->_filter_list );
108
+ }
109
+ }
110
+ $filters['lists'] = $this->_filter_list;
111
+
112
+ // include also unsubscribed and unconfirmed
113
+ if ( ! empty( $this->_filter_confirmed ) ) {
114
+ $filters['status'] = 'subscribed';
115
+ }
116
+
117
+ $model_user = WYSIJA::get( 'user', 'model' );
118
+ $select = array( 'A.user_id' );
119
+ $qry = $model_user->get_subscribers( $select, $filters, '', $return_query = true );
120
+ }
121
+
122
+ return $qry;
123
+ }
124
+
125
+ /**
126
+ * get chunks of subscribers ids and push them step by step to the export file
127
+ */
128
+ private function _get_chunks_user_ids() {
129
+
130
+ $model_user = WYSIJA::get( 'user', 'model' );
131
+ $this->_user_ids = array();
132
+ $query_user_ids = $this->_get_query_users_ids();
133
+ $query_count = str_replace( array( 'DISTINCT(A.user_id)', 'DISTINCT(B.user_id)' ), 'COUNT(DISTINCT(A.user_id))', $query_user_ids );
134
+
135
+ if ( empty( $this->_user_ids_rows ) ) {
136
+ $useridsrows_result = $model_user->getResults( $query_count, ARRAY_N );
137
+ $this->_user_ids_rows = (int) $useridsrows_result[0][0];
138
+ }
139
+
140
+ if ( $this->_user_ids_rows <= $this->_export_batch ) {
141
+ $user_ids_db = $model_user->getResults( $query_user_ids, ARRAY_N );
142
+
143
+ foreach ( $user_ids_db as $uarr ) {
144
+ $this->_user_ids[] = $uarr[0];
145
+ }
146
+
147
+ $this->_push_data_to_export_file();
148
+ } else {
149
+ $pages = ceil( $this->_user_ids_rows / $this->_export_batch ); //pagination
150
+ for ( $i = 0; $i < $pages; $i++ ) {
151
+ $query_batch = $query_user_ids . ' ORDER BY user_id ASC LIMIT ' . ($i * $this->_export_batch) . ',' . $this->_export_batch;
152
+ $user_ids_db = $model_user->getResults( $query_batch, ARRAY_N );
153
+ foreach ( $user_ids_db as $uarr ) {
154
+ $this->_user_ids[] = $uarr[0];
155
+ }
156
+ $this->_push_data_to_export_file();
157
+
158
+ unset($user_ids_db); //free memory
159
+ }
160
+ }
161
+ }
162
+
163
+ /**
164
+ * split the user_ids array into chunks, load the fields of all the concerned
165
+ * users and push the data to the file
166
+ */
167
+ function _push_data_to_export_file() {
168
+ $user_ids_chunks = array(); // chunk rows into separated batchs, limit by $this->_export_batch
169
+ $user_ids_chunks = array_chunk( $this->_user_ids, 200 );
170
+ $this->_user_ids = null; // free memory
171
+
172
+ $model_user = WYSIJA::get( 'user', 'model' );
173
+ foreach ( $user_ids_chunks as $user_id_chunk ) {
174
+ // get the full data for that specific chunk of ids
175
+ $data = $model_user->get( $this->_fields, array( 'user_id' => $user_id_chunk ) );
176
+
177
+ if ( in_array( 'created_at', $this->_fields ) ) {
178
+ foreach ( $data as $key => $row ) {
179
+ $data[$key]['created_at'] = date_i18n( get_option( 'date_format' ), $row['created_at'] );
180
+ }
181
+ }
182
+
183
+ $rows_count = count( $data );
184
+
185
+ // As required in Wysija/plugin#798 removed BOM from file
186
+ // fwrite( $this->_file_handle, "\xEF\xBB\xBF" );
187
+
188
+ // append content to the file
189
+ foreach ( $data as $k => $row ) {
190
+ $row_string = implode( $this->_fields_separator, $row );
191
+ $encoded_string = iconv( $this->_base_encode, $this->_output_encode, $row_string );
192
+ fwrite( $this->_file_handle, $encoded_string . ( $rows_count !== $k ? $this->_lines_separator : '' ) );
193
+ }
194
+ }
195
+ }
196
+
197
+ /**
198
+ * simply prepare the header of the file based on the fields
199
+ */
200
+ private function _prepare_headers() {
201
+ $model_user = WYSIJA::get( 'user_field', 'model' );
202
+ $database_fields = $model_user->getFields();
203
+
204
+ $name_fields = array();
205
+ //prepare the columns that need to be exported
206
+ foreach ( $this->_fields as $key_field ) {
207
+ $name_fields[] = $database_fields[$key_field];
208
+ }
209
+
210
+ //create the export file step by step
211
+ $row_string = implode( $this->_fields_separator, $name_fields ) . $this->_lines_separator;
212
+ $encoded_string = iconv( $this->_base_encode, $this->_output_encode, $row_string );
213
+ $this->_file_header = $encoded_string;
214
+ }
215
+
216
+ }
classes/WJ_Field.php ADDED
@@ -0,0 +1,283 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ A custom field.
5
+ It represents a custom field that
6
+ can be added to a form.
7
+ Example:
8
+ $custom_field = new WJ_Field();
9
+ $custom_field->set(array(
10
+ 'name' => 'Fruits',
11
+ 'type' => 'select',
12
+ 'required' => false,
13
+ 'settings' => array(
14
+ 'label' => 'Select a fruit:',
15
+ 'values' => array(
16
+ 'Apple', 'Orange', 'Banana'
17
+ ),
18
+ 'default_value' => 'Orange'
19
+ )
20
+ ));
21
+ $custom_field->save();
22
+ */
23
+
24
+ class WJ_Field {
25
+
26
+ // The custom fields DB table.
27
+ private $table;
28
+ // The Users table.
29
+ private $user_table;
30
+ // The ID of the custom field.
31
+ public $id;
32
+ // The name of the custom field.
33
+ public $name;
34
+ // input, textarea, checkbox, radio, select
35
+ public $type;
36
+ // true | false
37
+ public $required;
38
+ // Settings.
39
+ public $settings = array();
40
+
41
+ /*
42
+ Just set the correct tables on creation.
43
+ $custom_field = new WJ_Field();
44
+ */
45
+ function __construct() {
46
+ $this->table = WJ_Settings::db_prefix( 'custom_field' );
47
+ $this->user_table = WJ_Settings::db_prefix( 'user' );
48
+ }
49
+
50
+ /*
51
+ Get the table name.
52
+ Useful for statistics and counts on Custom Fields.
53
+ Generally when we want to run DB queries.
54
+ */
55
+ public function get_table_name() {
56
+ return $this->table;
57
+ }
58
+
59
+ /*
60
+ Static method to get a Custom field by id.
61
+ WJ_Field::get(id);
62
+ # => WJCustomField Object
63
+ */
64
+ public static function get( $id ) {
65
+ $object = new self();
66
+ global $wpdb;
67
+ $result = $wpdb->get_row( $wpdb->prepare( "SELECT * from {$object->table} WHERE id = %d", $id ), ARRAY_A );
68
+ if ( $result != null ) {
69
+ $result['settings'] = unserialize( $result['settings'] );
70
+ $result['required'] = WJ_Utils::to_bool( $result['required'] );
71
+ $object->set( $result );
72
+ return $object;
73
+ } else {
74
+ return null;
75
+ }
76
+ }
77
+
78
+ /*
79
+ Get all custom fields.
80
+ WJ_Field::get_all();
81
+ # => Array of WJ_Field
82
+ */
83
+ public static function get_all( $options = array() ) {
84
+ $object = new self();
85
+ global $wpdb;
86
+
87
+ // default order by
88
+ $order_by = 'id ASC';
89
+ if ( isset($options['order_by'] ) ){
90
+ $order_by = $options['order_by'];
91
+ }
92
+
93
+ // fetch rows from db
94
+ $results = $wpdb->get_results( $wpdb->prepare( "SELECT * FROM {$object->table} ORDER BY %s", $order_by ), ARRAY_A );
95
+
96
+ if ( $results != null ) {
97
+ $collection = array();
98
+ foreach ( $results as $result ) {
99
+ $result['settings'] = unserialize( $result['settings'] );
100
+ $result['required'] = WJ_Utils::to_bool( $result['required'] );
101
+ $field = new self();
102
+ $field->set( $result );
103
+ $collection[] = $field;
104
+ }
105
+ return $collection;
106
+ } else {
107
+ return null;
108
+ }
109
+ }
110
+
111
+
112
+ /*
113
+ Get a custom fields names list.
114
+ WJ_Field::get_names_list();
115
+ # => array(1 => 'Address', 2 => 'Gender')
116
+ */
117
+ public static function get_all_names() {
118
+ $fields = self::get_all();
119
+ $fields_list = array();
120
+ if ( isset( $fields ) ) {
121
+ foreach ( $fields as $field ) {
122
+ $fields_list[$field->id] = $field->name;
123
+ }
124
+ }
125
+ return $fields_list;
126
+ }
127
+
128
+ /*
129
+ Set all object properties.
130
+ $custom_field->set(array(
131
+ 'name' => 'First Name',
132
+ 'type' => 'text',
133
+ 'required' => true
134
+ ));
135
+ */
136
+ public function set( $args ) {
137
+ if ( isset( $args['id'] ) ) {
138
+ $this->id = $args['id'];
139
+ }
140
+ $this->name = $args['name'];
141
+ $this->type = $args['type'];
142
+ $this->required = $args['required'];
143
+ $this->settings = $args['settings'];
144
+ }
145
+
146
+ /*
147
+ Store Custom Field in DB.
148
+ If already stored, updates it.
149
+ $custom_field->save();
150
+ */
151
+ public function save() {
152
+ // Check if it's a new object or an update.
153
+ if ( isset( $this->id ) ) {
154
+ $this->update();
155
+ } else {
156
+ $this->create();
157
+ }
158
+ }
159
+
160
+ // Delete custom field from DB.
161
+ public function delete() {
162
+ global $wpdb;
163
+ $result = $wpdb->delete( $this->table, array( 'id' => $this->id ), array( '%d' ) );
164
+ $this->delete_user_col( $this->id );
165
+ return $result;
166
+ }
167
+
168
+ /*
169
+ Generates user column name;
170
+ $custom_field->user_column_name();
171
+ # => 'cf_1'
172
+ */
173
+ public function user_column_name() {
174
+ $column_name = 'cf_' . $this->id;
175
+ return $column_name;
176
+ }
177
+
178
+ /*
179
+ Creates the Custom Field.
180
+ It also creates the user column, depending on type.
181
+ */
182
+ private function create() {
183
+ global $wpdb;
184
+ $required = WJ_Utils::to_int( $this->required );
185
+ $wpdb->insert(
186
+ $this->table,
187
+ array(
188
+ 'name' => $this->name,
189
+ 'type' => $this->type,
190
+ 'required' => $required,
191
+ 'settings' => serialize( $this->settings ),
192
+ ),
193
+ array( '%s', '%s', '%d', '%s', '%s' )
194
+ );
195
+ // ! No id in user col?
196
+ if ( $wpdb->insert_id ) {
197
+ $this->id = $wpdb->insert_id;
198
+ $this->create_user_col();
199
+ } else {
200
+ return false;
201
+ }
202
+ }
203
+
204
+ /*
205
+ Updates the value of the custom field.
206
+ $custom_field->update('New address');
207
+ */
208
+ private function update() {
209
+ global $wpdb;
210
+ $required = WJ_Utils::to_int( $this->required );
211
+ $result = $wpdb->update(
212
+ $this->table,
213
+ array(
214
+ 'name' => $this->name,
215
+ 'type' => $this->type,
216
+ 'required' => $required,
217
+ 'settings' => serialize( $this->settings ),
218
+ ),
219
+ array( 'id' => $this->id ),
220
+ array( '%s', '%s', '%d' ),
221
+ array( '%d' )
222
+ );
223
+ return $result;
224
+ }
225
+
226
+ /*
227
+ Creates the correct user columnn, named cf_x, in the
228
+ user table. x is the ID if the custom field.
229
+ */
230
+ private function create_user_col() {
231
+ global $wpdb;
232
+ $column_name = $this->user_column_name();
233
+ $column_type = $this->generate_column_type();
234
+ $result = $wpdb->query(
235
+ "ALTER TABLE $this->user_table ADD COLUMN $column_name $column_type"
236
+ );
237
+ return $result;
238
+ }
239
+
240
+ /*
241
+ Calculates the correct column type, based on custom field type.
242
+ $custom_field->generate_column_type();
243
+ # => 'VARCHAR(100)'
244
+ */
245
+ private function generate_column_type() {
246
+ switch ( $this->type ) {
247
+ case 'input':
248
+ $column_type = 'VARCHAR(100)';
249
+ break;
250
+ case 'textarea':
251
+ $column_type = 'VARCHAR(255)';
252
+ break;
253
+ case 'checkbox':
254
+ $column_type = 'TINYINT(1)';
255
+ break;
256
+ case 'radio':
257
+ $column_type = 'VARCHAR(255)';
258
+ break;
259
+ case 'select':
260
+ $column_type = 'VARCHAR(255)';
261
+ break;
262
+ case 'date':
263
+ $column_type = 'INT(10) UNSIGNED';
264
+ break;
265
+ default:
266
+ $column_type = 'VARCHAR(255)';
267
+ break;
268
+ }
269
+ return $column_type;
270
+ }
271
+
272
+ /*
273
+ Deletes the user column in the user table.
274
+ Needed when we remove a custom field.
275
+ */
276
+ private function delete_user_col( $custom_field_id ) {
277
+ global $wpdb;
278
+ $cf_column = 'cf_' . $custom_field_id;
279
+ $result = $wpdb->query( "ALTER TABLE $this->user_table DROP COLUMN $cf_column" );
280
+ return $result;
281
+ }
282
+
283
+ }
classes/WJ_FieldHandler.php ADDED
@@ -0,0 +1,59 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ Class WJ_FieldHandler
5
+ It handles the custom fields in a controller.
6
+ */
7
+ class WJ_FieldHandler {
8
+
9
+ public function __construct() {
10
+ }
11
+
12
+ /*
13
+ Handler to save all the fields, by giving an array
14
+ that specifies the custom fields columns names, and
15
+ the ID of the user.
16
+ WJ_FieldHandler::handle_all(array(
17
+ 'cf_1' => 'Value',
18
+ 'cf_2' => 'Value 2'
19
+ ), 1
20
+ );
21
+ */
22
+ public static function handle_all(array $fields_values, $user_id) {
23
+ $user_fields = WJ_FieldUser::get_all($user_id);
24
+
25
+ if(isset($user_fields) && !empty($user_fields)) {
26
+ foreach ($user_fields as $user_field) {
27
+ $key = $user_field->column_name();
28
+
29
+ // check if there is a value for this custom field
30
+ if(array_key_exists($key, $fields_values)) {
31
+
32
+ // set value
33
+ $new_value = $fields_values[$key];
34
+
35
+ // extra process for specific types
36
+ if($user_field->field->type === 'checkbox') {
37
+ // limit the value between [0,1]
38
+ $new_value = min(max(0, (int)$new_value), 1);
39
+
40
+ } else if($user_field->field->type === 'date') {
41
+ // get date parameters
42
+ $year = (isset($fields_values[$key]['year'])) ? (int)$fields_values[$key]['year'] : (int)strftime('%Y');
43
+ $month = (isset($fields_values[$key]['month'])) ? (int)$fields_values[$key]['month'] : 1;
44
+ $day = (isset($fields_values[$key]['day'])) ? (int)$fields_values[$key]['day'] : 1;
45
+
46
+ $new_value = null;
47
+ if($year !== 0 && $month !== 0 && $day !== 0) {
48
+ // make timestamp from date parameters
49
+ $new_value = mktime(0, 0, 0, $month, $day, $year);
50
+ }
51
+ }
52
+
53
+ // update value
54
+ $user_field->update($new_value);
55
+ }
56
+ }
57
+ }
58
+ }
59
+ }
classes/WJ_FieldRender.php ADDED
@@ -0,0 +1,249 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ Class WJ_FieldRender
5
+ It is able to render Custom Fields in a form.
6
+ */
7
+
8
+ class WJ_FieldRender {
9
+
10
+ // WJ_FieldUser Object.
11
+ private $field_user;
12
+ // The column, like 'cf_1'
13
+ private $identifier;
14
+ // Name of the field.
15
+ private $name;
16
+ // Value of the field.
17
+ private $value;
18
+
19
+ public function __construct($field_user) {
20
+ $this->field_user = $field_user;
21
+ $this->identifier = $field_user->column_name();
22
+ $this->name = esc_attr($field_user->field->name);
23
+ $this->value = esc_attr($field_user->value());
24
+ }
25
+
26
+ public function validation() {
27
+ $rules = array();
28
+ $validation_class = '';
29
+
30
+ // If there are any validations, add correct class names.
31
+ if (!empty($this->field_user->field->settings['validate'])) {
32
+ $validation_value = $this->field_user->field->settings['validate'];
33
+ $rules[] = 'custom[' . $validation_value . ']';
34
+ }
35
+
36
+ // If there's any validation, join all classes.
37
+ if (!empty($rules)) {
38
+ $validation_class = 'class="validate[' . join(',', $rules) . ']"';
39
+ }
40
+
41
+ return $validation_class;
42
+ }
43
+
44
+ /*
45
+ Returns the HTML label for this field, to be used
46
+ in a form.
47
+ $field_render->label();
48
+ # => '<label ...>Address</label>'
49
+ */
50
+ public function label() {
51
+ $form_field_name = $this->identifier;
52
+ $label =
53
+ '<label for="' . $form_field_name . '">' .
54
+ $this->name .
55
+ '</label>';
56
+ return $label;
57
+ }
58
+
59
+ /*
60
+ Returns the input related to the type of the field,
61
+ to be used in a form.
62
+ $field_render->input();
63
+ # => '<input type=..../>
64
+ */
65
+ public function input() {
66
+ $input = '';
67
+
68
+ switch ($this->field_user->field->type) {
69
+ case 'input':
70
+ $input =
71
+ '<input type="text" size="40" id="'. $this->identifier . '"' .
72
+ 'value="' . $this->value .
73
+ '" name="wysija[field][' . $this->identifier . ']" ' .
74
+ $this->validation() .
75
+ ' />';
76
+ break;
77
+ case 'textarea':
78
+ $input =
79
+ '<textarea id="'. $this->identifier . '"' .
80
+ 'name="wysija[field][' . $this->identifier . ']" ' .
81
+ $this->validation() .
82
+ ' />' .
83
+ $this->value .
84
+ '</textarea>';
85
+ break;
86
+ case 'checkbox':
87
+ $check_value = '';
88
+ $label = $this->field_user->field->settings['values'][0]['value'];
89
+ if ($this->value == 1) {
90
+ $check_value = ' checked="checked"';
91
+ }
92
+ $input =
93
+ '<label for="' . $this->identifier . '">' .
94
+ '<input type="hidden" '.
95
+ $check_value .
96
+ ' name="wysija[field][' . $this->identifier . ']"' .
97
+ ' value="0" ' .
98
+ ' />' .
99
+ '<input type="checkbox" id="'. $this->identifier . '"' .
100
+ $check_value .
101
+ ' name="wysija[field][' . $this->identifier . ']"' .
102
+ ' value="1" ' .
103
+ $this->validation() .
104
+ ' />' . $label . '</label>';
105
+ break;
106
+ case 'radio':
107
+ $field = $this->field_user->field;
108
+ foreach ($field->settings['values'] as $index => $content) {
109
+ $check_value = '';
110
+ if ($this->value == $content['value']) {
111
+ $check_value = 'checked="checked"';
112
+ }
113
+ $local_identifier = $this->identifier . '_' . $content['value'];
114
+ $input .=
115
+ '<label for="' . $local_identifier . '">' .
116
+ '<input type="radio" id="'. $local_identifier . '"' .
117
+ $check_value .
118
+ ' name="wysija[field][' . $this->identifier . ']"' .
119
+ ' value="' . $content['value'] . '" />' .
120
+ $content['value'] .
121
+ '</label>';
122
+ }
123
+ break;
124
+ case 'select':
125
+ $input = '<select id="' . $this->identifier . '"' .
126
+ ' name="wysija[field][' . $this->identifier . ']" ' .
127
+ $this->validation() .
128
+ ' />';
129
+ $field = $this->field_user->field;
130
+ foreach ($field->settings['values'] as $index => $content) {
131
+ $check_value = '';
132
+ if ($this->value == $content['value']) {
133
+ $check_value = 'selected="selected"';
134
+ }
135
+ $input .=
136
+ '<option ' . $check_value .
137
+ ' value="' . $content['value'] . '" >' .
138
+ $content['value'] .
139
+ '</option>';
140
+ }
141
+ $input .= '</select>';
142
+ break;
143
+
144
+ case 'date':
145
+ // get date format from field settings
146
+ $field = $this->field_user->field;
147
+
148
+ // get timestamp value
149
+ $value = ((int)$this->value > 0) ? (int)$this->value : null;
150
+
151
+ // get date type (defaults to year + month + day)
152
+ $date_type = (isset($field->settings['date_type'])) ? $field->settings['date_type'] : 'year_month_day';
153
+ // get an array of all required date components (year, month, day)
154
+ $display_date_fields = explode('_', $date_type);
155
+ // form engine to get date data
156
+ $helper_form_engine = WYSIJA::get('form_engine', 'helper');
157
+
158
+ // year selection
159
+ if(in_array('year', $display_date_fields)) {
160
+ $years = $helper_form_engine->get_years();
161
+
162
+ $selected_year = null;
163
+ if($value !== null) {
164
+ $selected_year = (int)strftime('%Y', $value);
165
+ }
166
+
167
+ // select
168
+ $input .= '<select name="wysija[field]['.$this->identifier.'][year]">';
169
+ $input .= '<option value="">'.__('Year').'</option>';
170
+ foreach($years as $year) {
171
+ $is_selected = ((int)$year['year'] === $selected_year) ? ' selected="selected"' : '';
172
+ $input .= '<option value="'.$year['year'].'"'.$is_selected.'>'.$year['year'].'</option>';
173
+ }
174
+ $input .= '</select>';
175
+ }
176
+
177
+ // month selection
178
+ if(in_array('month', $display_date_fields)) {
179
+ $months = $helper_form_engine->get_months();
180
+
181
+ $selected_month = null;
182
+ if($value !== null) {
183
+ $selected_month = (int)strftime('%m', $value);
184
+ }
185
+
186
+ // select
187
+ $input .= '<select name="wysija[field]['.$this->identifier.'][month]">';
188
+ $input .= '<option value="">'.__('Month').'</option>';
189
+ foreach($months as $month) {
190
+ $is_selected = ((int)$month['month'] === $selected_month) ? ' selected="selected"' : '';
191
+ $input .= '<option value="'.$month['month'].'"'.$is_selected.'>'.$month['month_name'].'</option>';
192
+ }
193
+ $input .= '</select>';
194
+ }
195
+
196
+ // day selection
197
+ if(in_array('day', $display_date_fields)) {
198
+ $days = $helper_form_engine->get_days();
199
+
200
+ $selected_day = null;
201
+ if($value !== null) {
202
+ $selected_day = (int)strftime('%d', $value);
203
+ }
204
+
205
+ // select
206
+ $input .= '<select name="wysija[field]['.$this->identifier.'][day]">';
207
+ $input .= '<option value="">'.__('Day').'</option>';
208
+ foreach($days as $day) {
209
+ $is_selected = ((int)$day['day'] === $selected_day) ? ' selected="selected"' : '';
210
+ $input .= '<option value="'.$day['day'].'"'.$is_selected.'>'.$day['day'].'</option>';
211
+ }
212
+ $input .= '</select>';
213
+ }
214
+ break;
215
+ default:
216
+ $input = '';
217
+ break;
218
+ }
219
+ return $input;
220
+ }
221
+
222
+ /*
223
+ Render all custom fields in a table, given the user id.
224
+ $field_render::render_all(1);
225
+ # => '<tr><th><label...<input...</td></tr>'
226
+ */
227
+ public static function render_all($user_id) {
228
+ $fields = WJ_FieldUser::get_all($user_id);
229
+ if (isset($fields)) {
230
+ $output = '';
231
+ foreach ($fields as $field) {
232
+ $field_render = new self($field);
233
+ $output .=
234
+ '<tr>' .
235
+ '<th scope="row">' .
236
+ $field_render->label() .
237
+ '</th><td>' .
238
+ $field_render->input() .
239
+ '</td></tr>';
240
+ }
241
+ return $output;
242
+ } else {
243
+ return null;
244
+ }
245
+ }
246
+
247
+
248
+ }
249
+
classes/WJ_FieldUser.php ADDED
@@ -0,0 +1,130 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /*
4
+ An user field is a custom field identified by ID,
5
+ linked to a particular user, identified by ID.
6
+ */
7
+
8
+ class WJ_FieldUser {
9
+
10
+ // User Table.
11
+ private $user_table;
12
+ // Custom fields table.
13
+ private $field_table;
14
+ // User ID.
15
+ public $user_id;
16
+ // The field object.
17
+ public $field;
18
+ // The field value.
19
+ public $value;
20
+
21
+ /*
22
+ $field_user = new WJ_FieldUser();
23
+ Just setup correct tables names.
24
+ */
25
+ function __construct() {
26
+ $this->user_table = WJ_Settings::db_prefix('user');
27
+ $this->field_table = WJ_Settings::db_prefix('custom_field');
28
+ }
29
+
30
+ /*
31
+ After object creation, you can set the user id,
32
+ and the field id. The object will now contain the right
33
+ custom field, and the user id.
34
+ $field_user->set(array(
35
+ 'user_id' => 1,
36
+ 'field_id' => 2
37
+ ));
38
+ */
39
+ public function set($args) {
40
+ $this->user_id = $args['user_id'];
41
+ $this->field = WJ_Field::get($args['field_id']);
42
+ }
43
+
44
+ /*
45
+ Updates the field user value.
46
+ $field_user->update('Main Street');
47
+ */
48
+ public function update($value) {
49
+ global $wpdb;
50
+ $column_name = $this->field->user_column_name();
51
+ // Cast value to the correct column type.
52
+ switch ($this->field->type) {
53
+ case 'checkbox':
54
+ $validation = '%d';
55
+ $value = (int)$value;
56
+ break;
57
+ default:
58
+ // We default to a string.
59
+ $validation = '%s';
60
+ $value = (string)$value;
61
+ break;
62
+ }
63
+ $result = $wpdb->update(
64
+ $this->user_table,
65
+ array(
66
+ $column_name => $value
67
+ ), array("user_id" => $this->user_id),
68
+ array($validation),
69
+ array("%d")
70
+ );
71
+ if ($result != false) {
72
+ $this->value = $value;
73
+ }
74
+ return $result;
75
+ }
76
+
77
+ /*
78
+ Get the user field value.
79
+ $field_user->value();
80
+ # => 'Main Street'
81
+ */
82
+ public function value() {
83
+ $value = '';
84
+ if (isset($this->value)) {
85
+ $value = $this->value;
86
+ } else {
87
+ $column_name = $this->field->user_column_name();
88
+ global $wpdb;
89
+ $result = $wpdb->get_row($wpdb->prepare(
90
+ "SELECT $column_name FROM $this->user_table
91
+ WHERE user_id = %d",
92
+ array($this->user_id)
93
+ ), ARRAY_A);
94
+ $this->value = $result[$column_name];
95
+ $value = $result[$column_name];
96
+ }
97
+ return $value;
98
+ }
99
+
100
+ /*
101
+ Get the user unique column name.
102
+ $field_user->column_name();
103
+ # => 'cf_1'
104
+ */
105
+ public function column_name() {
106
+ return $this->field->user_column_name();
107
+ }
108
+
109
+ /*
110
+ Get all UserFields by User ID.
111
+ $WJ_FieldUser::get_all();
112
+ # => Array of WJ_FieldUser
113
+ */
114
+ public static function get_all($user_id) {
115
+ $fields = WJ_Field::get_all();
116
+ if(isset($fields) && !empty($fields)) {
117
+ $collection = array();
118
+ foreach ($fields as $field) {
119
+ $user_field = new self();
120
+ $user_field->user_id = $user_id;
121
+ $user_field->field = $field;
122
+ $collection[] = $user_field;
123
+ }
124
+ return $collection;
125
+ } else {
126
+ return null;
127
+ }
128
+ }
129
+
130
+ }
classes/WJ_Import.php ADDED
@@ -0,0 +1,828 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class Import.
5
+ *
6
+ * Importing subscribers
7
+ */
8
+ class WJ_Import extends WYSIJA_object {
9
+
10
+ private $_header_row = array();
11
+ private $_csv_data = array();
12
+ private $_match = array();
13
+ private $_ignore_invalid_date = array(); // specific for date fields
14
+ private $_custom_fields = array();
15
+ private $_email_key = '';
16
+ private $_data_to_insert = array();
17
+ private $_number_list = 0;
18
+ private $_data_numbers = array();
19
+ private $_line_delimiter = "\n";
20
+ private $_duplicate_emails_count = array(); // detect the emails that are duplicates in the import file
21
+ private $_csv_array = array(); // containing the csv into an array
22
+ private $_ignored_row_count = 0; // the count of rows we ignore because there was no valid email present
23
+ private $_lines_count = 0; // count the number of valid lines inserted in the DB
24
+ private $_chunks_count = 0; // number of chunks we chopped from the csv
25
+ private $_first_row_is_data = false; // means that there is no header on that csv file
26
+ private $_emails_inserted_in_current_chunk = array(); // array of emails
27
+ private $_csv_file_string = '';
28
+ private $_data_result = array(); // used for importmatch refactor
29
+ private $_regex_new_field = "/^new_field\|([^\|]+)\|(.+)$/i";
30
+
31
+ function __construct() {
32
+ if (!empty($_POST['wysija']['match']))
33
+ $this->_match = $_POST['wysija']['match'];
34
+ if (!empty($_POST['wysija']['ignore_invalid_date']))
35
+ $this->_ignore_invalid_date = $_POST['wysija']['ignore_invalid_date'];
36
+ if (!empty($_REQUEST['wysija']['user_list']['list']))
37
+ $this->_number_list = count($_REQUEST['wysija']['user_list']['list']);
38
+ if (!empty($_POST['firstrowisdata']))
39
+ $this->_first_row_is_data = true;
40
+ $this->_data_numbers = array('invalid' => array(), 'inserted' => 0, 'valid_email_processed' => 0, 'list_added' => 0, 'list_user_ids' => 0, 'list_list_ids' => $this->_number_list, 'emails_queued' => 0);
41
+ }
42
+
43
+ /**
44
+ * loading file data passed in a global variable
45
+ * @return type
46
+ */
47
+ private function _get_temp_file_info() {
48
+ if (!empty($_REQUEST['wysija']['dataImport']))
49
+ return unserialize(base64_decode($_REQUEST['wysija']['dataImport']));
50
+ }
51
+
52
+ /**
53
+ * loading the file based on global parameters
54
+ * @return string
55
+ */
56
+ private function _loading_file_content() {
57
+ // try to access the temporary file created in the previous step
58
+ $this->_csv_data = $this->_get_temp_file_info();
59
+
60
+ $helper_file = WYSIJA::get('file', 'helper');
61
+ $result_file = $helper_file->get($this->_csv_data['csv'], 'import');
62
+
63
+ if (!$result_file) {
64
+ $upload_dir = wp_upload_dir();
65
+ $this->error(sprintf(__('Cannot access CSV file. Verify access rights to this directory "%1$s"', WYSIJA), $upload_dir['basedir']), true);
66
+ return false;
67
+ }
68
+
69
+ // get the temp csv file
70
+ $this->_csv_file_string = file_get_contents($result_file);
71
+ }
72
+
73
+ private function _set_custom_fields(){
74
+ $WJ_Field = new WJ_Field();
75
+ $_custom_fields = $WJ_Field->get_all();
76
+
77
+ if(!empty($_custom_fields)){
78
+ foreach($_custom_fields as $key => &$row){
79
+ $this->_custom_fields['cf_'.$row->id] = $row;
80
+ }
81
+ }
82
+ }
83
+
84
+ /**
85
+ * Validate if a column is already matched previously
86
+ * @param string $column_name
87
+ * @return boolean
88
+ */
89
+ private function _is_column_matched($column_name) {
90
+ if (empty($this->_data_to_insert)) {
91
+ return false;
92
+ }
93
+ $column_names = array_values($this->_data_to_insert);
94
+ return in_array(trim($column_name), $column_names);
95
+ }
96
+ /**
97
+ * match columns together with the csv data based on the data passed
98
+ */
99
+ private function _match_columns_to_insert() {
100
+
101
+ // we're going through all of the selected value in each dropdown when importing
102
+ foreach($this->_match as $csv_column_number => $column_in_user_table){
103
+ // Reduce matching twice the same column
104
+ if ($this->_is_column_matched($column_in_user_table))
105
+ continue;
106
+
107
+ // Ignore `nomatch` columns
108
+ if ($column_in_user_table == 'nomatch')
109
+ continue;
110
+
111
+ // Check if maybe it's a new field
112
+ preg_match($this->_regex_new_field, $column_in_user_table, $maybe_newfield);
113
+ if ( !empty($maybe_newfield) && in_array($maybe_newfield[1], array('date', 'input')) ){
114
+ // TODO need to change to WJ_Field I guess when Marco is done moving the files
115
+ // saving a new custom field
116
+ $custom_field = new WJ_Field();
117
+
118
+ $custom_field->set(array(
119
+ 'name' => $maybe_newfield[2],
120
+ 'type' => $maybe_newfield[1],
121
+ 'required' => false,
122
+ 'settings' => array(
123
+ 'label' => $maybe_newfield[2],
124
+ 'date_type' => 'year_month_day',
125
+ 'is_default_today' => 0,
126
+ 'date_order' => 'mm/dd/yyyy'
127
+ )
128
+ ));
129
+
130
+ $custom_field->save();
131
+
132
+ // this is the column name in the database so this is where we need to import that field
133
+ $column_in_user_table = $custom_field->user_column_name();
134
+ $this->_match[$csv_column_number] = $column_in_user_table;
135
+ }
136
+
137
+ // keep the match of CSV column number to column key in our database
138
+ // not sure why do we trim the column key ...
139
+ $this->_data_to_insert[$csv_column_number] = trim($column_in_user_table);
140
+
141
+ // this column is the email column, let's keep track of it for later validation etc..
142
+ if($column_in_user_table == 'email'){
143
+ $this->_email_key = $csv_column_number;
144
+ }
145
+ }
146
+
147
+ $this->_set_custom_fields();
148
+
149
+ // if the status column is not matched, we make sure that we have an entry for the status column so that we default it to some value on import
150
+ if(!in_array('status',$this->_data_to_insert)){
151
+ $this->_data_to_insert['status'] = 'status';
152
+ }
153
+ }
154
+
155
+ /**
156
+ * build the header of the import query
157
+ * @return type
158
+ */
159
+ private function _get_import_query_header() {
160
+ return 'INSERT IGNORE INTO [wysija]user (`' . implode('` ,`', $this->_data_to_insert) . '`,`created_at`) VALUES ';
161
+ }
162
+
163
+ /**
164
+ *
165
+ * @param type $array_csv
166
+ */
167
+ private function _check_duplicate_emails($array_csv) {
168
+ // look for duplicate emails
169
+ foreach ($array_csv as $keyline => $csv_line) {
170
+ if (isset($csv_line[$this->_email_key])) {
171
+ if (isset($this->_duplicate_emails_count[$csv_line[$this->_email_key]])) {
172
+ $this->_duplicate_emails_count[$csv_line[$this->_email_key]]++;
173
+ //$arra[$keyline]
174
+ } else {
175
+ $this->_duplicate_emails_count[$csv_line[$this->_email_key]] = 1;
176
+ }
177
+ } else {
178
+ //if the record doesn't have the attribute email then we just ignore it
179
+ $this->_ignored_row_count++;
180
+ unset($array_csv[$keyline]);
181
+ }
182
+ }
183
+ }
184
+
185
+ /**
186
+ * save new column/field match to improve usability the next time our admin
187
+ * import a field with similar headers/columns names
188
+ * @return boolean
189
+ */
190
+ private function _smart_column_match_recording() {
191
+ if ($this->_first_row_is_data === false) {
192
+ //save the importing fields to be able to match them the next time
193
+ $import_fields = get_option('wysija_import_fields');
194
+
195
+ foreach($this->_match as $csv_column_number => $column_in_user_table){
196
+ if($column_in_user_table != 'nomatch') {
197
+
198
+ // make a column name key
199
+ $column_name_key = str_replace(array(' ','-','_'),'',strtolower($this->_header_row[$csv_column_number]));
200
+ // fill in the array of "csv column name" / "user table column" matches
201
+ $import_fields[$column_name_key] = $column_in_user_table;
202
+
203
+ }
204
+ }
205
+
206
+ WYSIJA::update_option('wysija_import_fields' , $import_fields);
207
+ return true;
208
+ }
209
+ return false;
210
+ }
211
+
212
+ /**
213
+ * import a csv type into wysija's subscribers' table
214
+ * @return type
215
+ */
216
+ public function import_subscribers() {
217
+
218
+ // import the contacts
219
+ // 1-check that a list is selected and that there is a csv file pasted
220
+ // 2-save the list if necessary
221
+ // 3-save the contacts and record them for each list selected
222
+ $this->_loading_file_content();
223
+ // convert the csv file to an array of lines
224
+ $this->_csv_array = $this->_csv_to_array( $this->_csv_file_string , 0 , $this->_csv_data['fsep'] , $this->_csv_data['fenc']);
225
+
226
+ // check what columns of the csv have been matched together with our subscribers' table
227
+ $this->_match_columns_to_insert();
228
+
229
+ $this->_header_row = array_map('trim', $this->_csv_array[0]);
230
+
231
+ // we process the sql insertion 200 by 200 so that we are safe with the server's memory and cpu
232
+ $csv_chunks = array_chunk($this->_csv_array, 200);
233
+ $this->_csv_array = null;
234
+ $this->_chunks_count = 0;
235
+ $this->_lines_count = 0;
236
+
237
+ // setting up a timeout value on the sql side to avoid timeout when importing a lot of data apparently.
238
+ global $wpdb;
239
+ $wpdb->query('set session wait_timeout=600');
240
+
241
+ // loop and insert the data chunks by chunks
242
+ foreach ($csv_chunks as $key_chunk => $csv_chunk) {
243
+
244
+ $this->_check_duplicate_emails($csv_chunk);
245
+
246
+ $result = $this->_import_rows($csv_chunk);
247
+
248
+ if ($result !== false)
249
+ $this->_chunks_count++;
250
+ else {
251
+ // there was an error we try 3 more times the same chunk and se how it goes
252
+ $try = 0;
253
+ while ($result === false && $try < 3) {
254
+ $result = $this->_import_rows($csv_chunk);
255
+ if ($result !== false) {
256
+ $this->_chunks_count++;
257
+ break;
258
+ }
259
+ $try++;
260
+ }
261
+
262
+ if ($result === false) {
263
+ $this->error(__('There seems to be an error with the list you\'re trying to import.', WYSIJA), true);
264
+ return false;
265
+ }
266
+ }
267
+ // increment the lines count
268
+ $this->_lines_count += $result;
269
+ // free up some memory
270
+ unset($csv_chunks[$key_chunk]);
271
+ }
272
+
273
+ // useful the next time we import a file with the same format
274
+ $this->_smart_column_match_recording();
275
+
276
+ // refresh the total count of users in wysija
277
+ $helper_user = WYSIJA::get('user','helper');
278
+ $helper_user->refreshUsers();
279
+
280
+ // keep only the real duplicate emails unset the unique ones
281
+ // TODO check that this email duplicate function could be a memory sink hole
282
+ // especially that right now we don't use its value
283
+ foreach ($this->_duplicate_emails_count as $email_address => $times_email_in_csv) {
284
+ if ($times_email_in_csv == 1)
285
+ unset($this->_duplicate_emails_count[$email_address]);
286
+ }
287
+
288
+ // how come we need to do that sometimes? how a lines count could become negative?
289
+ if ($this->_lines_count < 0)
290
+ $this->_lines_count = 0;
291
+
292
+ // all of these numbers were useful at some point when we were showing more information after an import
293
+ $this->_data_numbers['ignored'] = ($this->_data_numbers['valid_email_processed'] - $this->_data_numbers['inserted']);
294
+ $this->_data_numbers['ignored_list'] = ( ($this->_data_numbers['list_user_ids'] * $this->_data_numbers['list_list_ids']) - $this->_data_numbers['list_added'] );
295
+
296
+
297
+ return $this->_data_numbers;
298
+ }
299
+
300
+ public function get_duplicate_emails_count() {
301
+ return $this->_duplicate_emails_count;
302
+ }
303
+
304
+ /**
305
+ * convert a csv string to an array
306
+ * @param type $csv_file_content
307
+ * @param type $rows_to_read
308
+ * @param type $delimiter
309
+ * @param type $enclosure
310
+ * @return array
311
+ */
312
+ private function _csv_to_array($csv_file_content, $rows_to_read = 0, $delimiter = ',', $enclosure = '') {
313
+ $data = array();
314
+
315
+ // the new way for splitting a string into an array of lines
316
+ $csv_data_array = explode( $this->_line_delimiter, $csv_file_content );
317
+
318
+ $i=1;
319
+ foreach($csv_data_array as $csv_line){
320
+ if($rows_to_read!=0 && $i> $rows_to_read) return $data;
321
+
322
+ // str_getcsv only exists in php5 and is a faster and cleaner function than our csv_explode
323
+ if (!function_exists('str_getcsv')) {
324
+ $data[] = $this->_lines_explode($csv_line, $delimiter, $enclosure);
325
+ } else {
326
+ $data[] = str_getcsv($csv_line, $delimiter, $enclosure);
327
+ }
328
+
329
+ $i++;
330
+ }
331
+
332
+ return $data;
333
+ }
334
+
335
+ /**
336
+ * explode lines to columns
337
+ * @param type $csv_line
338
+ * @param type $delimiter
339
+ * @param type $enclose
340
+ * @param type $preserve
341
+ * @return type
342
+ */
343
+ private function _lines_explode($csv_line, $delimiter, $enclose, $preserve = false) {
344
+ $resArr = array();
345
+ $n = 0;
346
+ if (empty($enclose)) {
347
+ $resArr = explode($delimiter, $csv_line);
348
+ } else {
349
+ $expEncArr = explode($enclose, $csv_line);
350
+ foreach ($expEncArr as $EncItem) {
351
+ if ($n++ % 2) {
352
+ array_push($resArr, array_pop($resArr) . ($preserve ? $enclose : '') . $EncItem . ( $preserve ? $enclose : ''));
353
+ } else {
354
+ $expDelArr = explode($delimiter, $EncItem);
355
+ array_push($resArr, array_pop($resArr) . array_shift($expDelArr));
356
+ $resArr = array_merge($resArr, $expDelArr);
357
+ }
358
+ }
359
+ }
360
+
361
+ return $resArr;
362
+ }
363
+
364
+ /**
365
+ * function processing a chunk of a csv array to import it in the DB
366
+ * @global object $wpdb
367
+ * @param array $csv_chunk
368
+ * @return boolean|string
369
+ */
370
+ private function _import_rows($csv_chunk) {
371
+
372
+ global $wpdb;
373
+
374
+ $this->_emails_inserted_in_current_chunk = array();
375
+ $time = time();
376
+ $lines = array();
377
+ $lines_count = count($csv_chunk);
378
+ $columns_count = count($this->_data_to_insert);
379
+
380
+ $query = $this->_get_import_query_header();
381
+
382
+ // make sure that each line has the right numbers of columns if it doesn't then we can skip it
383
+ foreach ($csv_chunk as $k => $line) {
384
+ if (!(count($line) >= (count($this->_data_to_insert) - 1))) {
385
+ unset($csv_chunk[$k]);
386
+ $lines_count--;
387
+ }
388
+ }
389
+
390
+ $valid_email_processed = 0;
391
+ $j = 1;
392
+
393
+ foreach ($csv_chunk as $key_line => $line) {
394
+
395
+ // if first row is not data but header then we just skip it only on the first chunk
396
+ if ($this->_first_row_is_data === false && $j == 1 && $this->_chunks_count == 0) {
397
+ $j++;
398
+ continue;
399
+ }
400
+
401
+ $i = 1;
402
+ $values = array();
403
+
404
+ // TODO maybe we should check the value of the status column so that if we export a wysija's subscribers' list
405
+ // and import it again in another site then we keep the status
406
+ if (isset($this->_data_to_insert['status']))
407
+ $line['status'] = 1;
408
+
409
+ foreach ($line as $key_column => &$value_column) {
410
+
411
+ // make sure this column is a column we want to insert in our DB
412
+ if (isset($this->_data_to_insert[$key_column])) {
413
+ $column_name = $this->_data_to_insert[$key_column];
414
+ $original_value_column = $value_column;
415
+ $value_column = $this->_validate_value($column_name, $value_column);
416
+
417
+ // if it is a a date column, we convert it as a unixtimestamp
418
+ if(isset($this->_custom_fields[$column_name]) && $this->_custom_fields[$column_name]->type == 'date'){
419
+ $value_column = strtotime($value_column);
420
+ }
421
+
422
+ // this kind of result invalidates the whole row
423
+ if ($value_column === false) {
424
+ // record the invalid row and continue with the loop
425
+ $this->_data_numbers['invalid'][] = $original_value_column;
426
+ unset($csv_chunk[$key_line]);
427
+ $lines_count--;
428
+ continue 2;
429
+ } else {
430
+ // only if this is the email row we record an entry in the recorded emails and the email processed count
431
+ if ($this->_email_key === $key_column) {
432
+ $this->_emails_inserted_in_current_chunk[] = $value_column;
433
+ $valid_email_processed++;
434
+ }
435
+ }
436
+
437
+ // prepare the query
438
+ $values[] = "'" . esc_sql($value_column, $wpdb->dbh) . "'";
439
+ }
440
+ }
441
+
442
+ $values[] = $time;
443
+ $lines[] .= "(" . implode(', ', $values) . ")";
444
+ }
445
+
446
+ $query .= implode(', ', $lines);
447
+
448
+ // replace query to import the subscribers
449
+ $model_wysija = new WYSIJA_model();
450
+ $import_query = $model_wysija->query($query);
451
+
452
+ $lines_count = $wpdb->rows_affected;
453
+ $this->_data_numbers['inserted'] += $wpdb->rows_affected;
454
+ $this->_data_numbers['valid_email_processed'] += $valid_email_processed;
455
+
456
+ if ($import_query === false) {
457
+ $this->error(__('Error when inserting emails.', WYSIJA), true);
458
+ return false;
459
+ }
460
+ $time_now = time();
461
+ $result_query_import_list = $this->_import_new_users_into_lists($time_now);
462
+
463
+ $this->_trigger_active_autoresponders($time_now);
464
+
465
+ if ($result_query_import_list === false) {
466
+ $this->error(__('Error when inserting list.', WYSIJA), true);
467
+ return false;
468
+ }
469
+
470
+ if ($import_query == 0)
471
+ return '0';
472
+
473
+ return $lines_count;
474
+ }
475
+
476
+ /**
477
+ * used to validate or cast values before importing
478
+ * TODO should we add a type for import of custom fields ?
479
+ * Comment : Marco, feel free to modify entirely
480
+ * @param type $column_name
481
+ * @param type $value
482
+ */
483
+ function _validate_value($column_name, $value) {
484
+ $value = trim($value);
485
+
486
+ switch ($column_name) {
487
+ case 'email':
488
+ return is_email($value);
489
+ break;
490
+ case 'status':
491
+
492
+ if (in_array(strtolower($value), array('subscribed', 'confirmed', 1, '1', 'true'))) {
493
+ return 1;
494
+ } elseif (in_array(strtolower($value), array('unsubscribed', -1, '-1', 'false'))) {
495
+ return -1;
496
+ } elseif (in_array(strtolower($value), array('unconfirmed', 0, '0'))) {
497
+ return 0;
498
+ }
499
+ else
500
+ return 1;
501
+ break;
502
+ default :
503
+ return $value;
504
+ }
505
+ }
506
+
507
+ /**
508
+ * take care of active autoresponders retro-activity
509
+ * @param type $time_now
510
+ * @return boolean
511
+ */
512
+ private function _trigger_active_autoresponders($time_now) {
513
+ $helper_email = WYSIJA::get('email', 'helper');
514
+ $model_wysija = new WYSIJA_model();
515
+
516
+ // list the active auto responders emails
517
+ $active_autoresponders_per_list = $helper_email->get_active_follow_ups(array('email_id', 'params'), true);
518
+
519
+ if (!empty($active_autoresponders_per_list)) {
520
+ foreach ($_REQUEST['wysija']['user_list']['list'] as $list_id) {
521
+ // checking if this list has a list of follow ups
522
+ if (isset($active_autoresponders_per_list[$list_id])) {
523
+ // for each follow up of that list we queu an email
524
+ foreach ($active_autoresponders_per_list[$list_id] as $key_queue => $follow_up) {
525
+ // insert query per active followup
526
+ $query_queue = 'INSERT IGNORE INTO [wysija]queue (`email_id` ,`user_id`,`send_at`) ';
527
+ $query_queue .= ' SELECT ' . $follow_up['email_id'] . ' , B.user_id , ' . ($time_now + $follow_up['delay']);
528
+ $query_queue .= ' FROM [wysija]user_list as B';
529
+ $query_queue .= ' WHERE B.list_id=' . (int) $list_id . ' AND sub_date=' . $time_now;
530
+
531
+ $model_wysija->query($query_queue);
532
+
533
+ $this->_data_numbers['emails_queued'] += $wpdb->rows_affected;
534
+ }
535
+ }
536
+ }
537
+ return true;
538
+ }
539
+ return false;
540
+ }
541
+
542
+ /**
543
+ *
544
+ * @global type $wpdb
545
+ * @param type $time_now
546
+ * @return type
547
+ */
548
+ private function _import_new_users_into_lists($time_now) {
549
+ global $wpdb;
550
+ $wpdb->rows_affected = 0;
551
+ $model_wysija = new WYSIJA_model();
552
+
553
+ $user_ids = $this->_get_imported_user_ids();
554
+
555
+ // insert query per list
556
+ $query = 'INSERT IGNORE INTO [wysija]user_list (`list_id` ,`user_id`,`sub_date`) VALUES ';
557
+
558
+ foreach ($_REQUEST['wysija']['user_list']['list'] as $keyl => $list_id) {
559
+ if (empty($list_id))
560
+ continue;
561
+ // for each list pre selected go through that process
562
+ foreach ($user_ids as $key => $user_data) {
563
+
564
+ // inserting each user id to this list
565
+ $query.='(' . $list_id . ' , ' . $user_data['user_id'] . ' , ' . $time_now . ')';
566
+
567
+ // if this is not the last row we put a comma for the next row
568
+ if (count($user_ids) > ($key + 1)) {
569
+ $query.=' , ';
570
+ }
571
+ }
572
+
573
+ // if this is not the last row we put a comma for the next row
574
+ if (count($_REQUEST['wysija']['user_list']['list']) > ($keyl + 1)) {
575
+ $query.=',';
576
+ }
577
+ }
578
+
579
+ $result_query = $model_wysija->query($query);
580
+
581
+ $this->_data_numbers['list_added']+=$wpdb->rows_affected;
582
+ $this->_data_numbers['list_user_ids']+=count($user_ids);
583
+ return $result_query;
584
+ }
585
+
586
+ /**
587
+ * get a list of user_ids freshly imported
588
+ * @return type
589
+ */
590
+ private function _get_imported_user_ids() {
591
+ $model_user = WYSIJA::get('user', 'model');
592
+ // select query to get all of the ids of the emails that have just been inserted
593
+ return $model_user->get(array('user_id'), array('email' => $this->_emails_inserted_in_current_chunk));
594
+ }
595
+
596
+
597
+ /**
598
+ * this save a default list of column matching to ease the import process, this is done only the first time when the
599
+ * field is not populated yet
600
+ */
601
+ private function _save_default_import_field_match(){
602
+ $import_fields = get_option('wysija_import_fields');
603
+ if (!$import_fields) {
604
+ $import_fields = array(
605
+ 'fname' => 'firstname',
606
+ 'firstname' => 'firstname',
607
+ 'prenom' => 'firstname',
608
+ 'nom' => 'lastname',
609
+ 'name' => 'lastname',
610
+ 'lastname' => 'lastname',
611
+ 'lname' => 'lastname',
612
+ 'ipaddress' => 'ip',
613
+ 'ip' => 'ip',
614
+ 'addresseip' => 'ip',
615
+ );
616
+ WYSIJA::update_option('wysija_import_fields', $import_fields);
617
+ }
618
+ }
619
+
620
+
621
+ /**
622
+ * put the whole file or posted string into one string and clean up the string that may cause trouble during import
623
+ * @return boolean
624
+ */
625
+ private function _get_csv_file_cleaned_up(){
626
+ // is it a text import or a file import?
627
+ if($_POST['wysija']['import']['type'] == 'copy'){
628
+ if(!isset($_POST['wysija']['user_list']['csv'])){
629
+ // memory limit has been reached
630
+ $this->error(__('The list you\'ve pasted is too big for the browser. <strong>Upload the file</strong> instead.', WYSIJA), true);
631
+ return false;
632
+ }
633
+ $this->_csv_file_string = trim(stripslashes($_POST['wysija']['user_list']['csv']));
634
+
635
+ }else{
636
+ // move_uploaded_file($_importfile, $destination);
637
+ $this->_csv_file_string = trim(file_get_contents($_FILES['importfile']['tmp_name']));
638
+ }
639
+
640
+ $this->_csv_file_string = str_replace(array("\r", "\n\n", "\n\t\t\n\t\n\t\n\t\n", "\n\t\t\n\t\n\t\n", "\xEF\xBB\xBF", "\n\t\n", "\n(+1)"), array("\n", "\n", "\n ;", "\n", '', ';', ''), $this->_csv_file_string);
641
+
642
+
643
+ // this might be gmail recipients(copy-paste from a gmail account) rare paste ...
644
+ if(!preg_match_all('/<([a-z0-9_\'&\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,10})+>/i' , $this->_csv_file_string , $matches)){
645
+ //return false;
646
+ }else{
647
+
648
+ if (substr($this->_csv_file_string, -1) != ",")
649
+ $this->_csv_file_string = trim($this->_csv_file_string) . ',';
650
+
651
+
652
+ if (count($matches[0]) == count($matches)) {
653
+ //this is gmail simple paste
654
+ $this->_csv_file_string = str_replace(array('>,', '<'), array("\n", ','), $this->_csv_file_string);
655
+ }
656
+ $this->_csv_file_string = trim($this->_csv_file_string);
657
+ }
658
+ }
659
+
660
+
661
+ /**
662
+ * try to figure out the format of that CSV file, which separators and enclosure strings does it use
663
+ * @return boolean
664
+ */
665
+ private function _run_test_on_csv_file(){
666
+ // try different set of enclosure and separator for the csv which can have different look depending on the data carried
667
+ $field_separators_to_test = array( ',', ';', "\t" );
668
+ $field_enclosers_to_test = array( '"', '' );
669
+ $this->_csv_data['fsep'] = false;
670
+ $this->_csv_data['fenc'] = '';
671
+ $helper_user = WYSIJA::get('user','helper');
672
+
673
+ foreach($field_enclosers_to_test as $enclosure){
674
+ foreach($field_separators_to_test as $fsep){
675
+
676
+ // testing different combinations of separator and enclosers
677
+ $this->_csv_array = $this->_csv_to_array( $this->_csv_file_string, 10, $fsep, $enclosure );
678
+
679
+ // make sure that our CSV has more than one row and that it has the same number of values in the first row and the second row
680
+ if ( ( count( $this->_csv_array ) > 1 && count( $this->_csv_array[0] ) == count( $this->_csv_array[1] ) ) ) {
681
+ if ( count( $this->_csv_array[0] ) > 1 || $helper_user->validEmail( trim( $this->_csv_array[0][0] ) ) || $helper_user->validEmail( trim( $this->_csv_array[1][0] ) ) ) {
682
+ $this->_csv_data['fsep'] = $fsep;
683
+ $this->_csv_data['fenc'] = $enclosure;
684
+ break(2);
685
+ }
686
+ }
687
+ }
688
+ }
689
+
690
+ // if we didn't manage to find a separator in that file then it is not a csv file and we come out
691
+ if(empty($this->_csv_data['fsep'])){
692
+ $this->notice( sprintf(
693
+ "%s <a href='http://support.mailpoet.com/knowledgebase/importing-subscribers-with-a-csv-file/' target='_blank'>%s</a>",
694
+ __("The data you are trying to import doesn't appear to be in the CSV format (Comma Separated Values).", WYSIJA),
695
+ __("Read More", WYSIJA)
696
+ ) );
697
+ $this->notice(__('The first line of a CSV file should be the column headers : "email","lastname","firstname".',WYSIJA));
698
+ $this->notice(__('The second line of a CSV file should be a set of values : "joeeg@example.com","Average","Joe".',WYSIJA));
699
+
700
+ $this->notice(__('The two first lines of the file you\'ve uploaded are as follow:', WYSIJA));
701
+
702
+ $arraylines = explode("\n", $this->_csv_file_string);
703
+
704
+ if (empty($arraylines[0]))
705
+ $text = __('Line is empty', WYSIJA);
706
+ else
707
+ $text = $arraylines[0];
708
+ $this->notice('<strong>' . $text . '</strong>');
709
+
710
+ if (empty($arraylines[1]))
711
+ $text = __('Line is empty', WYSIJA);
712
+ else
713
+ $text = $arraylines[1];
714
+ $this->notice('<strong>' . $text . '</strong>');
715
+
716
+ return false;
717
+ }
718
+
719
+ // test the size of the file
720
+ $temp_csv_array = $this->_csv_to_array($this->_csv_file_string, 0, $this->_csv_data['fsep'], $this->_csv_data['fenc']);
721
+
722
+ $this->_data_result['totalrows'] = count($temp_csv_array);
723
+ end($temp_csv_array);
724
+ $this->_data_result['lastrow'] = current($temp_csv_array);
725
+ }
726
+
727
+
728
+ /**
729
+ * save the CSV string into a file so that we can use it later in the next step of the process
730
+ * @return boolean|string
731
+ */
732
+ private function _save_csv_file(){
733
+ // try to make a wysija dir to save the import file
734
+ $helper_file = WYSIJA::get('file', 'helper');
735
+ $result_dir = $helper_file->makeDir('import');
736
+ if (!$result_dir) {
737
+ return false;
738
+ }
739
+
740
+ $file_name = 'import-' . time() . '.csv';
741
+ $handle = fopen($result_dir . $file_name, 'w');
742
+ fwrite($handle, $this->_csv_file_string);
743
+ fclose($handle);
744
+
745
+ return $file_name;
746
+ }
747
+
748
+
749
+ /**
750
+ * detect which column is an email one
751
+ */
752
+ private function _test_csv_emails(){
753
+ $found_email = 0;
754
+ $this->_email_key = array();
755
+ $helper_user = WYSIJA::get('user', 'helper');
756
+ foreach ($this->_csv_array as $csv_row) {
757
+ foreach ($csv_row as $key_column => $value_column) {
758
+ if ($helper_user->validEmail(trim($value_column))) {
759
+ $found_email++;
760
+
761
+ $this->_email_key[$key_column] = $this->_csv_array[0][$key_column];
762
+ }
763
+ }
764
+ }
765
+
766
+ $this->_data_result['errormatch'] = false;
767
+ $check_again = __('Check again what you\'re trying to import.',WYSIJA);
768
+ if (($found_email < 1)) {
769
+ $this->error(__('We couldn\'t find any valid addresses in the first 10 rows.', WYSIJA).' '.$check_again, true);
770
+ }
771
+
772
+ if ((count($this->_csv_array) < 2)) {
773
+ $this->error(__('You\'re import file is not valid.', WYSIJA).' '.$check_again, true);
774
+ }
775
+ }
776
+
777
+
778
+ /**
779
+ * function used to scan the CSV before trying to match each column with our own fields
780
+ * @return boolean
781
+ */
782
+ public function scan_csv_file(){
783
+ $this->_data_result = array();
784
+
785
+ // make sure the import match will be as easy as possible with default matches
786
+ if( $this->_save_default_import_field_match() === false) return false;
787
+ // get the csv into a string and check for messy email address etc
788
+ if( $this->_get_csv_file_cleaned_up() === false) return false;
789
+ // find out the format of that CSV file comma semi colon etc ..
790
+ if( $this->_run_test_on_csv_file() === false) return false;
791
+
792
+ // save the string into a file for later use
793
+ $file_name = $this->_save_csv_file();
794
+ if ($file_name === false)
795
+ return false;
796
+
797
+ // look for the email column
798
+ $this->_test_csv_emails();
799
+
800
+ // stock the data we will use in the next page
801
+ $this->_data_result['csv'] = $this->_csv_array;
802
+
803
+ $data_import = array(
804
+ 'csv' => $file_name,
805
+ 'fsep' => $this->_csv_data['fsep'],
806
+ 'fenc' => $this->_csv_data['fenc']);
807
+ $this->_data_result['dataImport'] = base64_encode(serialize($data_import));
808
+
809
+ $this->_data_result['keyemail'] = $this->_email_key;
810
+
811
+ //test if the first row is data or not
812
+ //test the email column
813
+ foreach ($this->_data_result['keyemail'] as $k)
814
+ $this->_email_key = $k;
815
+
816
+
817
+ // test whether the first row is a data row or is a descriptive header row
818
+ $helper_user = WYSIJA::get('user','helper');
819
+ if($helper_user->validEmail( $this->_email_key )){
820
+ $this->_data_result['firstrowisdata']=true;
821
+ }else{
822
+ $this->_data_result['totalrows']--;
823
+ }
824
+
825
+ return $this->_data_result;
826
+ }
827
+
828
+ }
classes/WJ_Migrator.php ADDED
@@ -0,0 +1,53 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ // We need the dbDelta migrator from Wordpress.
4
+ require_once( ABSPATH . 'wp-admin/includes/upgrade.php' );
5
+
6
+ /**
7
+ Migrator.
8
+ A class that uses Wordpress dbDelta function
9
+ to handle incremental migrations.
10
+ Beware that deltas have specific syntax, not
11
+ identical to SQL syntax.
12
+ $migrator = new WJ_Migrator('2.1.5');
13
+ $migrator->setup();
14
+ */
15
+ class WJ_Migrator {
16
+
17
+ private $db_prefix;
18
+ private $new_version;
19
+
20
+ function __construct($new_version) {
21
+ // Global Wordpress db object.
22
+ $this->db_prefix = WJ_Settings::db_prefix();
23
+ $this->new_version = $new_version;
24
+ }
25
+
26
+ /*
27
+ Add here your specific version number case.
28
+ It will be executed on version change.
29
+ */
30
+ public function setup() {
31
+
32
+ $sql = '';
33
+
34
+ switch ($this->new_version) {
35
+ case '2.5.2.1':
36
+ $table_name = $this->db_prefix . 'custom_field';
37
+ $sql = "CREATE TABLE $table_name (
38
+ id mediumint(9) NOT NULL AUTO_INCREMENT,
39
+ name tinytext NOT NULL,
40
+ type tinytext NOT NULL,
41
+ required tinyint(1) DEFAULT '0' NOT NULL,
42
+ default_value text,
43
+ field_values text,
44
+ PRIMARY KEY (id)
45
+ );";
46
+ break;
47
+ }
48
+
49
+ return dbDelta($sql);
50
+
51
+ }
52
+
53
+ }
classes/WJ_Option.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Option.
5
+ * It creates and modifies Wordpress options.
6
+ * $option = new WJ_Option('my_option');
7
+ * $option->set('my_value');
8
+ * # => true
9
+ * $option->get();
10
+ * # => 'my_value'
11
+ */
12
+ class WJ_Option {
13
+
14
+ private $prefix = 'wysija_premium_';
15
+ private $option_name;
16
+
17
+ function __construct($name) {
18
+ $this->option_name = $this->prefix . $name;
19
+ }
20
+
21
+ public function get() {
22
+ return get_option($this->option_name);
23
+ }
24
+
25
+ public function set($option_value) {
26
+ return update_option($this->option_name, $option_value);
27
+ }
28
+
29
+ }
classes/WJ_Settings.php ADDED
@@ -0,0 +1,30 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Settings.
5
+ * Global Wysija Premium settings singleton.
6
+ */
7
+ class WJ_Settings {
8
+
9
+ static private $db_prefix;
10
+ static private $name = 'wysija';
11
+
12
+ private function __construct() {
13
+ }
14
+
15
+ // db_prefix();
16
+ // # => wp_wysija_
17
+ // db_prefix('custom_field');
18
+ // # => wp_wysija_custom_field
19
+ static function db_prefix($table_name = false) {
20
+ global $wpdb;
21
+ self::$db_prefix = $wpdb->prefix . self::$name . '_';
22
+ if ($table_name) {
23
+ $prefixed = self::$db_prefix . $table_name;
24
+ } else {
25
+ $prefixed = self::$db_prefix;
26
+ }
27
+ return $prefixed;
28
+ }
29
+
30
+ }
classes/WJ_Stats.php ADDED
@@ -0,0 +1,474 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Class Stats.
5
+ *
6
+ * Handling subscribers click and open action of an email
7
+ */
8
+ class WJ_Stats extends WYSIJA_object {
9
+
10
+ public $email_id = null;
11
+ public $user_id = null;
12
+ public $clicked_url = '';
13
+ public $is_preview = false;
14
+
15
+ /**
16
+ * Email object
17
+ * @var Wysija_email
18
+ */
19
+ private $_email;
20
+
21
+ /**
22
+ * User object
23
+ * @var Wysija_user
24
+ */
25
+ private $_user;
26
+
27
+ private $_url_id = null;
28
+ private $_unique_click = false;
29
+ public $decoded_url = '';
30
+
31
+
32
+ /**
33
+ * load some global variables into the class
34
+ */
35
+ function __construct() {
36
+ if (!empty($_REQUEST['email_id']))
37
+ $this->email_id = (int) $_REQUEST['email_id'];
38
+ if (!empty($_REQUEST['user_id']))
39
+ $this->user_id = (int) $_REQUEST['user_id'];
40
+ if (!empty($_REQUEST['demo']))
41
+ $this->is_preview = true;
42
+ $this->_get_clicked_url();
43
+
44
+ // $this->_user can be empty, it's helpful in case an email was sent as a preview to a non-existing user, then a link is opened from there
45
+ $this->_user = WYSIJA::get('user', 'model')->getOne(false,(int)$this->user_id);
46
+
47
+ $this->_email = WYSIJA::get('email', 'model')->getOne(false,(int)$this->email_id);
48
+ if (empty($this->_email))
49
+ exit;
50
+
51
+ // consider to get / insert URL record here
52
+ // $this->_url = $this->_get_url($this->clicked_url);
53
+ }
54
+
55
+ /**
56
+ * Get user object
57
+ * @param type $user_id
58
+ */
59
+ public function get_user() {
60
+ return $this->_user;
61
+ }
62
+
63
+ /**
64
+ * Get email object
65
+ * @param type $user_id
66
+ */
67
+ public function get_email() {
68
+ return $this->_email;
69
+ }
70
+
71
+ /**
72
+ * count the action as an open and display the empty picture
73
+ */
74
+ public function subscriber_opened() {
75
+ if (!$this->_is_open_action())
76
+ exit;
77
+
78
+ $model_email_user_stat = WYSIJA::get('email_user_stat', 'model');
79
+ $model_email_user_stat->reset();
80
+ $model_email_user_stat->update(
81
+ array('status' => 1, 'opened_at' => time()), array('email_id' => $this->email_id, 'user_id' => $this->user_id, 'status' => 0));
82
+
83
+ $this->_update_user(array('last_opened' => time()));
84
+
85
+ header('Cache-Control: no-store, no-cache, must-revalidate');
86
+ header('Cache-Control: post-check=0, pre-check=0', false);
87
+ header('Pragma: no-cache');
88
+
89
+ if (empty($picture))
90
+ $picture = WYSIJA_DIR_IMG . 'statpicture.png';
91
+ $handle = fopen($picture, 'r');
92
+
93
+ if (!$handle)
94
+ exit;
95
+ header('Content-type: image/png');
96
+ $contents = fread($handle, filesize($picture));
97
+ fclose($handle);
98
+ echo $contents;
99
+ exit;
100
+ }
101
+
102
+ public function subscriber_clicked() {
103
+ if (!$this->_is_click_action())
104
+ exit;
105
+
106
+ if ($this->email_id && $this->is_preview === false) { //if not email_id that means it is an email preview
107
+ $this->_record_url();
108
+
109
+ $this->_record_user_url();
110
+
111
+ $this->_record_url_mail();
112
+
113
+ $redirect = $this->_record_email_user_stat();
114
+ if (!empty($redirect))
115
+ $this->decoded_url = $redirect;
116
+ $this->_update_user(array('last_clicked' => time()));
117
+ }else {
118
+ $this->_get_url_preview();
119
+ }
120
+ //sometimes this will be a life saver :)
121
+ $this->decoded_url = str_replace('&amp;', '&', $this->decoded_url);
122
+ if ($this->is_browser_link($this->decoded_url)) {
123
+ $this->decoded_url = $this->attach_user($this->decoded_url);
124
+ }
125
+ return $this->decoded_url;
126
+ }
127
+
128
+ /**
129
+ * Attach user_id as a param of an url
130
+ * @param string $url
131
+ * @param int $user_id
132
+ * @return string
133
+ */
134
+ protected function attach_user($url) {
135
+ if (!empty($this->_user) && !empty($this->_user['user_id'])) {
136
+ $url_components = parse_url($url);
137
+ $arr_params = array();
138
+ if (!empty($url_components['query']))
139
+ parse_str($url_components['query'],$arr_params);
140
+ if (empty($arr_params['user_id'])) {
141
+ $url .= ((strpos($url, '?') !== false) ? '&' : '?');
142
+ $url .= 'user_id='.$this->_user['user_id'];
143
+ }
144
+ }
145
+ return $url;
146
+ }
147
+
148
+ /**
149
+ * record entry into the table email_user_url
150
+ */
151
+ private function _record_user_url() {
152
+ //look for email_user_url entry and insert if not exists
153
+ $model_email_user_url = WYSIJA::get('email_user_url', 'model');
154
+ $data_email_user_url = array('email_id' => $this->email_id, 'user_id' => $this->user_id, 'url_id' => $this->_url_id);
155
+ $email_user_url_array = $model_email_user_url->getOne(false, $data_email_user_url);
156
+
157
+ if (!$email_user_url_array && $this->email_id > 0 && $this->user_id > 0 && $this->_url_id > 0) {
158
+ //we need to insert in email_user_url
159
+ $model_email_user_url->reset();
160
+ $query_EmailUserUrl = 'INSERT IGNORE INTO [wysija]email_user_url (`email_id` ,`user_id`,`url_id`) ';
161
+ $query_EmailUserUrl .= 'VALUES (' . $this->email_id . ', ' . $this->user_id . ', ' . $this->_url_id . ')';
162
+
163
+ $model_email_user_url->query($query_EmailUserUrl);
164
+
165
+ //$modelEmailUserUrl->insert($dataEmailUserUrl);
166
+ $this->_unique_click = true;
167
+ }
168
+
169
+ //increment stats counter on email_user_url clicked
170
+ $model_email_user_url = WYSIJA::get('email_user_url', 'model');
171
+ $model_email_user_url->update(array('clicked_at' => time(), 'number_clicked' => '[increment]'), $data_email_user_url);
172
+ }
173
+
174
+ /**
175
+ * record entry into the table url_mail
176
+ */
177
+ private function _record_url_mail() {
178
+ //look for url_mail entry and insert if not exists
179
+ $model_url_mail = WYSIJA::get('url_mail', 'model');
180
+ $data_url_mail = array('email_id' => $this->email_id, 'url_id' => $this->_url_id);
181
+ $urlMailObj = $model_url_mail->getOne(false, $data_url_mail);
182
+ if (!$urlMailObj) {
183
+ //we need to insert in url_mail
184
+ $model_url_mail->reset();
185
+ $model_url_mail->insert($data_url_mail);
186
+ }
187
+
188
+ $data_update = array('total_clicked' => '[increment]');
189
+ if (!$this->_unique_click)
190
+ $data_update['unique_clicked'] = '[increment]';
191
+ //increment stats counter on url_mail clicked
192
+ $model_url_mail->update($data_update, $data_url_mail);
193
+ }
194
+
195
+ /**
196
+ * record entry into the table email_user_stat
197
+ */
198
+ private function _record_email_user_stat() {
199
+ // clicked status
200
+ $status_email_user_stat = 2;
201
+
202
+ // this is the system url case (unsubscribe, view in browser and subscriptions)
203
+ if (in_array($this->clicked_url, array('[unsubscribe_link]', '[subscriptions_link]', '[view_in_browser_link]'))) {
204
+ $this->subscriberClass = WYSIJA::get('user', 'model');
205
+ $this->subscriberClass->getFormat = OBJECT;
206
+
207
+ //check if the security hash is passed to insure privacy
208
+ $receiver = $link = false;
209
+ if (isset($_REQUEST['hash'])) {
210
+ if ($_REQUEST['hash'] == md5(AUTH_KEY . $this->clicked_url . $this->user_id)) {
211
+ $receiver = $this->subscriberClass->getOne(array('user_id' => $this->user_id));
212
+ } else {
213
+ die('Security check failure.');
214
+ }
215
+ } else {
216
+ //link is not valid anymore
217
+ //propose to resend the newsletter with good links ?
218
+ $link = $this->subscriberClass->old_get_new_link_for_expired_links($this->user_id, $this->email_id);
219
+ }
220
+
221
+
222
+ switch ($this->clicked_url) {
223
+ case '[unsubscribe_link]':
224
+ //we need to make sure that this link belongs to that user
225
+ if ($receiver) {
226
+ $link = $this->subscriberClass->getUnsubLink($receiver, true);
227
+ // unsubscribe status
228
+ $status_email_user_stat = 3;
229
+ }
230
+ break;
231
+ case '[subscriptions_link]':
232
+ if ($receiver) {
233
+ $link = $this->subscriberClass->getEditsubLink($receiver, true);
234
+ }
235
+ break;
236
+ case '[view_in_browser_link]':
237
+ $model_email = WYSIJA::get('email', 'model');
238
+ $data_email = $model_email->getOne(false, array('email_id' => $this->email_id));
239
+ $helper_email = WYSIJA::get('email', 'helper');
240
+ $link = $helper_email->getVIB($data_email);
241
+ break;
242
+ }
243
+
244
+ //if the subscriber still exists in the DB we will have a link
245
+ if ($link) {
246
+ $this->decoded_url = $link;
247
+ } else {
248
+ //the subscriber doesn't appear in the DB we can redirect to the web version
249
+ $this->decoded_url = $this->_get_browser_link();
250
+
251
+ return $this->decoded_url;
252
+ }
253
+ } else {
254
+ // this is the standard non-system url case
255
+ if (strpos($this->decoded_url, 'http://') === false && strpos($this->decoded_url, 'https://') === false)
256
+ $this->decoded_url = 'http://' . $this->decoded_url;
257
+ // check that there is no broken unsubscribe link such as http://[unsubscribe_link]
258
+ if (strpos($this->decoded_url, '[unsubscribe_link]') !== false) {
259
+ $this->subscriberClass = WYSIJA::get('user', 'model');
260
+ $this->subscriberClass->getFormat = OBJECT;
261
+ $receiver = $this->subscriberClass->getOne($this->user_id);
262
+ $this->decoded_url = $this->subscriberClass->getUnsubLink($receiver, true);
263
+ }
264
+
265
+ if (strpos($this->decoded_url, '[view_in_browser_link]') !== false) {
266
+ $link = $this->_get_browser_link();
267
+ $this->decoded_url = $link;
268
+ }
269
+ }
270
+
271
+ $model_email_user_stat = WYSIJA::get('email_user_stat', 'model');
272
+ $exists = $model_email_user_stat->getOne(false, array('equal' => array('email_id' => $this->email_id, 'user_id' => $this->user_id), 'less' => array('status' => $status_email_user_stat)));
273
+ $data_update = array('status' => $status_email_user_stat);
274
+ if ($exists && isset($exists['opened_at']) && !(int) $exists['opened_at']) {
275
+ $data_update['opened_at'] = time();
276
+ }
277
+
278
+ $model_email_user_stat->reset();
279
+ $model_email_user_stat->colCheck = false;
280
+ $model_email_user_stat->update($data_update, array('equal' => array('email_id' => $this->email_id, 'user_id' => $this->user_id), 'less' => array('status' => $status_email_user_stat)));
281
+ }
282
+
283
+ /**
284
+ * update the user last_clicked or last_opened parameter
285
+ * @param type $data_update
286
+ */
287
+ private function _update_user($data_update) {
288
+ if (!empty($data_update)) {
289
+ $model_user = WYSIJA::get('user', 'model');
290
+ $model_user->update($data_update, array('user_id' => $this->user_id));
291
+ }
292
+ }
293
+
294
+ /**
295
+ * when the email sent is a preview email, we just need to emulate actions, no need to count stats or to unsubscribe user etc ...
296
+ * @return boolean
297
+ */
298
+ private function _get_url_preview() {
299
+ // we're in the case of an email preview
300
+ if (in_array($this->clicked_url, array('[unsubscribe_link]', '[subscriptions_link]', '[view_in_browser_link]'))) {
301
+ $model_user = WYSIJA::get('user', 'model');
302
+ $model_user->getFormat = OBJECT;
303
+ $user_object = $model_user->getOne(false, array('wpuser_id' => get_current_user_id()));
304
+ switch ($this->clicked_url) {
305
+ case '[unsubscribe_link]':
306
+ $link = $model_user->getConfirmLink($user_object, 'unsubscribe', false, true) . '&demo=1';
307
+
308
+ break;
309
+ case '[subscriptions_link]':
310
+ $link = $model_user->getConfirmLink($user_object, 'subscriptions', false, true) . '&demo=1';
311
+ break;
312
+ case 'view_in_browser_link':
313
+ case '[view_in_browser_link]':
314
+ if (!$this->email_id)
315
+ $this->email_id = $_REQUEST['id'];
316
+
317
+ $link = $this->_get_browser_link();
318
+ break;
319
+ }
320
+
321
+ $this->decoded_url = $link;
322
+ }else {
323
+ if (strpos($this->decoded_url, 'http://') === false && strpos($this->decoded_url, 'https://') === false)
324
+ $this->decoded_url = 'http://' . $this->decoded_url;
325
+ }
326
+ return true;
327
+ }
328
+
329
+ /**
330
+ * construct the view in your browser link
331
+ * @return type
332
+ */
333
+ private function _get_browser_link() {
334
+ $params_url = array(
335
+ 'wysija-page' => 1,
336
+ 'controller' => 'email',
337
+ 'action' => 'view',
338
+ 'email_id' => $this->email_id,
339
+ 'user_id' => 0
340
+ );
341
+ $config = WYSIJA::get('config', 'model');
342
+ return WYSIJA::get_permalink($config->getValue('confirm_email_link'), $params_url);
343
+ }
344
+
345
+ /**
346
+ * Detect if the current link is a browser link
347
+ * @param string $url
348
+ * @return boolean
349
+ */
350
+ protected function is_browser_link($url) {
351
+ $flag = false;
352
+ $helper_toolbox = WYSIJA::get('toolbox', 'helper');
353
+ if ($helper_toolbox->is_internal_link($url)) {
354
+ $url_components = parse_url($url);
355
+ if (!empty($url_components['query'])) {
356
+ $params = array();
357
+ parse_str($url_components['query'], $params);
358
+ if (!empty($params['controller']) && strtolower($params['controller']) == 'email'
359
+ && !empty($params['action']) && strtolower($params['action']) == 'view'
360
+ ) {
361
+ $flag = true;
362
+ }
363
+ }
364
+ }
365
+ return $flag;
366
+ }
367
+
368
+ /**
369
+ * check that this is a valid open action
370
+ * @return boolean
371
+ */
372
+ private function _is_open_action() {
373
+ if (empty($this->email_id) || empty($this->user_id))
374
+ return false;
375
+
376
+ return true;
377
+ }
378
+
379
+ /**
380
+ * check that this is a valid click action
381
+ * @return boolean
382
+ */
383
+ private function _is_click_action() {
384
+ if ((empty($this->email_id) || empty($this->user_id) || empty($this->clicked_url)) && $this->is_preview === false)
385
+ return false;
386
+
387
+ return true;
388
+ }
389
+
390
+ /**
391
+ * record the url into the db if not recorded already
392
+ * @return boolean
393
+ */
394
+ private function _record_url() {
395
+ //look for url entry and insert if not exists
396
+ $model_url = WYSIJA::get('url', 'model');
397
+ $url_found = $model_url->getOne(false, array('url' => $this->clicked_url));
398
+
399
+ if ($url_found) {
400
+ // we need to keep it
401
+ $this->_url_id = $url_found['url_id'];
402
+ } else {
403
+ // we need to record in database
404
+ $this->_url_id = $model_url->insert(array('url' => $this->clicked_url));
405
+ }
406
+ }
407
+
408
+ /**
409
+ * get/alter clicked url based on the global parameters
410
+ */
411
+ private function _get_clicked_url() {
412
+
413
+ if (isset($_REQUEST['urlencoded'])) {
414
+ $this->clicked_url = $_REQUEST['urlencoded'];
415
+ } elseif (isset($_REQUEST['urlpassed'])) {
416
+ $this->clicked_url = $_REQUEST['urlpassed'];
417
+ }
418
+
419
+ // make sure the url is or is not base64 encoded, some server cannot handle long url or url with encoded parameter which is the default behaviour
420
+ if (isset($_REQUEST['no64'])) {
421
+ $this->decoded_url = $this->clicked_url;
422
+ } else {
423
+ $this->clicked_url = $this->decoded_url = base64_decode($this->clicked_url);
424
+ }
425
+
426
+ if (strpos($this->clicked_url, 'utm_source') !== false) {
427
+ $this->clicked_url = $this->_clean_params_url(array('utm_source', 'utm_campaign', 'utm_medium'), $this->clicked_url);
428
+ }
429
+ return true;
430
+ }
431
+
432
+ /**
433
+ * remove any params from a url
434
+ * @param array $params_to_remove
435
+ * @param string $url
436
+ * @return string
437
+ */
438
+ private function _clean_params_url($params_to_remove = array(), $url = '') {
439
+ if (!$url){
440
+ return $url;
441
+ }
442
+
443
+ $url_splitted = explode('?', $url);
444
+ $params_in_url = array();
445
+
446
+ // lets parse the parameters of the url
447
+ parse_str($url_splitted[1], $params_in_url);
448
+
449
+ foreach ($params_to_remove as $param_key){
450
+ unset($params_in_url[$param_key]);
451
+ }
452
+
453
+ // let's use the base of that url to rebuild it without the cleaned out parameters.
454
+ $new_url = $url_splitted[0];
455
+
456
+ // when there are params left other than the ones we cleaned out of the url, we stick them back together
457
+ if($params_in_url) {
458
+ $new_url .= '?';
459
+ $i = 0;
460
+ foreach ($params_in_url as $k => $v) {
461
+ if ($i > 0){
462
+ $new_url .= '&';
463
+ }
464
+
465
+ // parse_str keeps the ampersand as a html number, let's clean it out so that the url look good when recorded
466
+ $new_url .= str_replace($k,'&#38;','') . '=' . $v;
467
+ $i++;
468
+ }
469
+ }
470
+
471
+ return $new_url;
472
+ }
473
+
474
+ }
classes/WJ_Upgrade.php ADDED
@@ -0,0 +1,390 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ class WJ_Upgrade extends WYSIJA_object {
3
+ /**
4
+ * A static variable that holds a dinamic instance of the class
5
+ * @var [object||null]
6
+ */
7
+ public static $instance = null;
8
+
9
+ public static $plugins = array( 'wysija-newsletters/index.php', 'wysija-newsletters-premium/index.php' );
10
+
11
+ public static $baseurl = array(
12
+ 'core' => 'https://downloads.wordpress.org/plugin/',
13
+ 'packager' => 'http://packager.mailpoet.com/release/',
14
+ );
15
+
16
+ public static function hook(){
17
+ null === self::$instance and self::$instance = new self;
18
+
19
+ if ( ! is_admin() ) {
20
+ return;
21
+ }
22
+
23
+ self::$baseurl = (object) self::$baseurl;
24
+
25
+ add_action( 'current_screen', array( self::$instance, 'setup_bulk_screen' ) );
26
+ add_action( 'shutdown', array( self::$instance, 'setup_bulk_screen_footer' ) );
27
+ add_action( 'current_screen', array( self::$instance, 'iframe_intercept' ) );
28
+
29
+ add_action( 'init', array( self::$instance, 'update_warning' ) );
30
+
31
+ add_filter( 'pre_set_site_transient_update_plugins', array( self::$instance, 'pre_set_site_transient_update_plugins' ), 100 );
32
+ }
33
+
34
+ public function update_warning() {
35
+ if ( ! is_admin() ){
36
+ return;
37
+ }
38
+
39
+ if ( defined( 'DOING_AJAX' ) && DOING_AJAX ) {
40
+ return;
41
+ }
42
+
43
+ if ( ! ( ( is_multisite() && current_user_can( 'manage_network' ) ) || current_user_can( 'update_plugins' ) ) ){
44
+ return;
45
+ }
46
+
47
+ if ( ! function_exists( 'get_plugin_data' ) ){
48
+ include_once ABSPATH . 'wp-admin/includes/plugin.php';
49
+ }
50
+
51
+ $current = get_site_transient( 'update_plugins' );
52
+
53
+ foreach ( self::$plugins as $plugin ){
54
+ if ( isset( $current->response[$plugin] ) ){
55
+ $data = self::get_plugin_data( $plugin );
56
+
57
+ if ( version_compare( $current->response[$plugin]->new_version, $data->info->Version, '<=' ) ){
58
+ continue;
59
+ }
60
+
61
+ $this->notice(
62
+ sprintf(
63
+ __( 'Hey! %1$s has an update (version %2$s), <a href="%3$s">click here to update</a>.', WYSIJA ),
64
+ '<strong>' . esc_attr( $data->info->Name ) . '</strong>',
65
+ $current->response[$plugin]->new_version,
66
+ wp_nonce_url( self_admin_url( 'update.php?action=upgrade-plugin&plugin=' ) . $plugin, 'upgrade-plugin_' . $plugin )
67
+ ),
68
+ true,
69
+ true
70
+ );
71
+ }
72
+ }
73
+ }
74
+
75
+ public function iframe_intercept( $current_screen ) {
76
+ if ( $current_screen->base !== 'mailpoet_page_wysija_config' ){
77
+ return;
78
+ }
79
+
80
+ if ( ! isset( $_GET['action'] ) || $_GET['action'] !== 'packager-switch' ){
81
+ return;
82
+ }
83
+
84
+ // Verify if it's has been created within the last 12 hours (nonce)
85
+ if ( wp_verify_nonce( $_GET['_wpnonce'], $_GET['action'] ) !== 1 ){
86
+ return;
87
+ }
88
+
89
+ // Require the Updater classes
90
+ include_once ABSPATH . 'wp-admin/includes/class-wp-upgrader.php';
91
+
92
+ $to = (isset($_GET['stable']) && $_GET['stable']?'stable':'beta');
93
+
94
+ add_filter( 'pre_site_transient_update_plugins', array( $this, 'pre_site_transient_update_plugins' ) );
95
+
96
+ $plugins = array();
97
+
98
+ // Check for the action, it might be upgrading or installing
99
+ $action = 'upgrade';
100
+ if ( isset( $_GET['_mp_action'] ) && in_array( $_GET['_mp_action'], array( 'upgrade', 'install' ) ) ){
101
+ $action = strtolower( $_GET['_mp_action'] );
102
+ }
103
+
104
+ foreach ( self::$plugins as $k => $plugin ) {
105
+ if ( is_plugin_active( $plugin ) ){
106
+ $plugins[] = $plugin;
107
+ }
108
+ }
109
+
110
+ // Ajust the Padding/margin of the iFrame
111
+ define( 'IFRAME_REQUEST', true );
112
+ echo "<div style='margin: 0 20px;'>";
113
+
114
+ // Thats how WordPress calls for an iFrame page
115
+ wp_enqueue_script( 'jquery' );
116
+ iframe_header();
117
+
118
+ if ( $action === 'upgrade' ) {
119
+ $upgrader = new Plugin_Upgrader( new Bulk_Plugin_Upgrader_Skin( compact( 'nonce', 'url' ) ) );
120
+ $upgrader->bulk_upgrade( $plugins );
121
+ } elseif ( $action === 'install' ) {
122
+ // If the action is install, it will only happen if it's the Premium
123
+ $upgrader = new Plugin_Upgrader( new Plugin_Installer_Skin() );
124
+ $result = $upgrader->install( self::get_url( self::$plugins[1], WYSIJA::is_beta(), 'zip' ) );
125
+ }
126
+
127
+ iframe_footer();
128
+ echo "</div>";
129
+
130
+ remove_filter( 'pre_site_transient_update_plugins', array( $this, 'pre_site_transient_update_plugins' ) );
131
+
132
+ $model_config = WYSIJA::get( 'config', 'model' );
133
+ $model_config->save( array( 'beta_mode' => ( $to === 'stable' ? false : true ) ) );
134
+ set_site_transient( 'update_plugins', '' );
135
+
136
+ exit();
137
+ }
138
+
139
+ /**
140
+ * A static method to grab the url from the packager to grab the ZIP
141
+ * or the version of the plugin there.
142
+ *
143
+ * @uses bool_from_yn
144
+ * @uses esc_url
145
+ * @uses add_query_arg
146
+ *
147
+ * @param string $package Which package you want to grab
148
+ * @param boolean|string $beta Beta URL or not
149
+ * @param string $action Which kind of URL you need? [zip|check]
150
+ * @param string $version The version you want the URL to be related to
151
+ * @return string|null It will return the URL from the packager related to the asked action
152
+ */
153
+ public static function get_url( $package = null, $beta = false, $action = 'zip', $version = null ){
154
+ if ( is_string( $beta ) ){
155
+ if ( $beta === 'beta' ) {
156
+ $beta = true;
157
+ } else {
158
+ $beta = bool_from_yn( $beta );
159
+ }
160
+ } else {
161
+ $beta = (bool) $beta;
162
+ }
163
+
164
+ if ( ! in_array( $action, array( 'zip', 'check' ) ) ) {
165
+ return null;
166
+ }
167
+
168
+ $slug = self::get_slug( $package );
169
+
170
+ if ( true === $beta || 'wysija-newsletters-premium' === $slug ) {
171
+ $url = self::$baseurl->packager . $action;
172
+
173
+ $params = array(
174
+ 'key' => self::get_slug( $package ),
175
+ );
176
+
177
+ if ( $beta === true )
178
+ $params['beta'] = 'true';
179
+
180
+ $url = add_query_arg( $params, $url );
181
+
182
+ return (string) $url;
183
+ } else {
184
+ return (string) self::$baseurl->core . $slug . '.zip';
185
+ }
186
+ }
187
+
188
+ public static function get_version( $package = null, $beta = false ){
189
+ $request = wp_remote_get( self::get_url( $package, $beta, 'check' ) );
190
+
191
+ if ( is_wp_error( $request ) )
192
+ return false;
193
+
194
+ $version = wp_remote_retrieve_body( $request );
195
+
196
+ return $version;
197
+ }
198
+
199
+ public static function get_slug( $package = null ){
200
+ switch ( $package ) {
201
+ case self::$plugins[1]:
202
+ case 'premium':
203
+ case 'wysija-newsletters-premium':
204
+ return 'wysija-newsletters-premium';
205
+ break;
206
+
207
+ case self::$plugins[0]:
208
+ case 'base':
209
+ case 'wysija-newsletters':
210
+ default:
211
+ return 'wysija-newsletters';
212
+ break;
213
+ }
214
+ }
215
+
216
+ public static function get_plugin_data( $package = null, $beta = false, $new_version = false ){
217
+ $data = (object) array();
218
+ if ( is_null( $package ) )
219
+ return $data;
220
+
221
+ $data->id = 27505;
222
+ $data->slug = self::get_slug( $package );
223
+ $data->package = self::get_url( $package, $beta, 'zip' );
224
+
225
+ if ( function_exists( 'get_plugin_data' ) ){
226
+ $data->info = (object) get_plugin_data( plugin_dir_path( dirname( dirname( __FILE__ ) ) ) . $package );
227
+ }
228
+
229
+ if ( $data->slug === 'wysija-newsletters' ){
230
+ $data->url = "https://wordpress.org/plugins/{$data->slug}/";
231
+ } else {
232
+ $data->url = 'http://www.mailpoet.com/wordpress-newsletter-plugin-premium/';
233
+ }
234
+ $data->url = esc_url( $data->url );
235
+
236
+ if ( $new_version !== false ){
237
+ $data->new_version = (string) $new_version;
238
+ }
239
+
240
+ return $data;
241
+ }
242
+
243
+ public function pre_set_site_transient_update_plugins( $update_data ){
244
+
245
+ if ( ! function_exists( 'get_plugin_data' ) ){
246
+ return (object) array();
247
+ }
248
+
249
+ if ( ! is_object( $update_data ) && strlen( trim( $update_data ) ) === 0 ){
250
+ return (object) array();
251
+ }
252
+
253
+ if ( ! isset( $update_data->last_checked ) ){
254
+ $update_data->last_checked = 0;
255
+ }
256
+
257
+ if ( ( time() - ( 60 * 60 * 12 ) ) > ( $update_data->last_checked ) ) { // Just check once every 12 hours
258
+ return $update_data;
259
+ }
260
+
261
+ foreach ( self::$plugins as $plugin ){
262
+ if ( ! function_exists( 'is_plugin_active' ) ) {
263
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
264
+ }
265
+
266
+ if ( ! is_plugin_active( $plugin ) ){
267
+ continue;
268
+ }
269
+
270
+ if ( ! WYSIJA::is_beta() && $plugin === 'wysija-newsletter' ) {
271
+ continue;
272
+ }
273
+
274
+ $version = self::get_version( $plugin, WYSIJA::is_beta() );
275
+ $update_data->last_checked = time();
276
+
277
+ if ( version_compare( WYSIJA::get_version( $plugin ), $version, '>=' ) ){
278
+ continue;
279
+ }
280
+
281
+ $update_data->response[$plugin] = self::get_plugin_data( $plugin, WYSIJA::is_beta(), $version );
282
+ }
283
+
284
+ return $update_data;
285
+ }
286
+
287
+ public function pre_site_transient_update_plugins( $transient ) {
288
+ $update_data = (object) array(
289
+ 'last_checked' => time() - 10,
290
+ 'response' => array()
291
+ );
292
+ $to = (isset($_GET['stable']) && $_GET['stable']?'stable':'beta');
293
+
294
+ foreach ( self::$plugins as $plugin ) {
295
+ if ( ! function_exists( 'is_plugin_active' ) ){
296
+ include_once( ABSPATH . 'wp-admin/includes/plugin.php' );
297
+ }
298
+
299
+ if ( ! is_plugin_active( $plugin ) ) {
300
+ continue;
301
+ }
302
+
303
+ $update_data->response[$plugin] = self::get_plugin_data( $plugin, $to, self::get_version( $plugin, $to ) );
304
+ }
305
+
306
+ return $update_data;
307
+ }
308
+
309
+ public function setup_bulk_screen( $current_screen ) {
310
+ global $title, $parent_file, $submenu_file;
311
+
312
+ if ( strtoupper( $_SERVER['REQUEST_METHOD'] ) === 'POST' && in_array( $current_screen->id, array( 'update-core', 'plugins' ) ) ) {
313
+ if ( !isset( $_POST['checked'] ) ){
314
+ return;
315
+ }
316
+
317
+ $plugins = (array) $_POST['checked'];
318
+ $plugins = array_map( 'urldecode', $plugins );
319
+
320
+ $__intersection = array_intersect( $plugins, self::$plugins );
321
+
322
+ if ( empty( $__intersection ) )
323
+ return;
324
+
325
+ switch ( $_POST['action'] ){
326
+ case 'delete-selected':
327
+ break;
328
+
329
+ case 'deactivate-selected':
330
+ if ( in_array( self::$plugins[0], $plugins ) && ! in_array( self::$plugins[1], $plugins ) && is_plugin_active( self::$plugins[1] ) ){
331
+ $plugins[] = self::$plugins[1];
332
+ }
333
+ break;
334
+
335
+ case 'update-selected':
336
+ case 'activate-selected':
337
+ if ( in_array( self::$plugins[1], $plugins ) && ! in_array( self::$plugins[0], $plugins ) ){
338
+ $plugins[] = self::$plugins[0];
339
+ }
340
+
341
+ break;
342
+ }
343
+
344
+ $_POST['checked'] = $plugins;
345
+
346
+ return;
347
+ }
348
+
349
+
350
+ if ( $current_screen->id !== 'update' ){
351
+ return;
352
+ }
353
+
354
+ if ( $_GET['action'] !== 'upgrade-plugin' ){
355
+ return;
356
+ }
357
+
358
+ if ( $_GET['action'] === 'upgrade-plugin' && ! in_array( $_GET['plugin'], self::$plugins ) ){
359
+ return;
360
+ }
361
+
362
+ foreach ( self::$plugins as $plugin ) {
363
+ if ( ! is_plugin_active( $plugin ) ) {
364
+ return;
365
+ }
366
+ }
367
+
368
+ $_GET['action'] = $_REQUEST['action'] = 'update-selected';
369
+ $_GET['plugins'] = $_REQUEST['plugins'] = implode( ',', array_map( 'urlencode', self::$plugins ) );
370
+ $_GET['_wpnonce'] = $_REQUEST['_wpnonce'] = wp_create_nonce( 'bulk-update-plugins' );
371
+ $_GET['_wysija_bulk_screen'] = $_REQUEST['_wysija_bulk_screen'] = true;
372
+
373
+ $title = esc_attr__( 'Update Plugin' );
374
+ $parent_file = 'plugins.php';
375
+ $submenu_file = 'plugins.php';
376
+ require_once(ABSPATH . 'wp-admin/admin-header.php');
377
+ echo
378
+ "<div class='wrap'>" .
379
+ "<h2>{$title}</h2>";
380
+
381
+ }
382
+
383
+ public function setup_bulk_screen_footer(){
384
+ if ( ! isset( $_GET['_wysija_bulk_screen'] ) ){
385
+ return;
386
+ }
387
+ echo "</div>";
388
+ include(ABSPATH . 'wp-admin/admin-footer.php');
389
+ }
390
+ }
classes/WJ_Utils.php ADDED
@@ -0,0 +1,69 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * Wysija Premium Utils.
5
+ * Utilities singleton not related to a specific model.
6
+ */
7
+ class WJ_Utils {
8
+
9
+ private function __construct() {
10
+ }
11
+
12
+ public static function to_int($value) {
13
+ $boolean = (bool) $value;
14
+ if ($boolean) {
15
+ $int = 1;
16
+ } else {
17
+ $int = 0;
18
+ }
19
+ return $int;
20
+ }
21
+
22
+ public static function to_bool($value) {
23
+ $int = (int) $value;
24
+ if ($int == 0) {
25
+ $boolean = false;
26
+ } else {
27
+ $boolean = true;
28
+ }
29
+ return $boolean;
30
+ }
31
+
32
+ /**
33
+ * Retuns plain domain name.
34
+ *
35
+ * @return string $domain
36
+ */
37
+ public static function get_domain() {
38
+ if(isset($_SERVER['SERVER_NAME']) && strlen(trim($_SERVER['SERVER_NAME'])) > 0) {
39
+ $domain = strtolower($_SERVER['SERVER_NAME']);
40
+ } else {
41
+ $domain = preg_replace('@http[s]?:\/\/@', '', get_site_url());
42
+ }
43
+
44
+ return preg_replace('@^www\.@', '', $domain);
45
+ }
46
+
47
+ /**
48
+ * Reruns necessary data for tooltip.
49
+ *
50
+ * @return array $data
51
+ */
52
+ public static function get_tip_data() {
53
+ $model_config = WYSIJA::get('config', 'model');
54
+ $is_gmail = 'false';
55
+
56
+ if ('gmail' === $model_config->getValue('sending_method')) {
57
+ $is_gmail = 'true';
58
+ }
59
+
60
+ $data = array(
61
+ 'text' => sprintf(__('Use an email from your domain, like <strong>info@%s</strong> to avoid the spam folder, or even be blocked.', WYSIJA), self::get_domain()),
62
+ 'gmailText' => sprintf(__('If you want to use a Gmail address, you need to send with Gmail. Check <a id="tip-send-with" href="%s">sending settings</a>.', WYSIJA), admin_url('admin.php?page=wysija_config#tab-sendingmethod')),
63
+ 'domain' => self::get_domain(),
64
+ 'isGmail' => $is_gmail
65
+ );
66
+
67
+ return $data;
68
+ }
69
+ }
{js/amcharts/images → classes}/index.html RENAMED
File without changes
controllers/ajax/campaigns.php CHANGED
@@ -2,855 +2,1003 @@
2
  defined('WYSIJA') or die('Restricted access');
3
  class WYSIJA_control_back_campaigns extends WYSIJA_control{
4
 
5
- function WYSIJA_control_back_campaigns(){
6
- if(!WYSIJA::current_user_can('wysija_newsletters')) die('Action is forbidden.');
7
- parent::WYSIJA_control();
8
- }
9
-
10
- function switch_theme() {
11
- if(isset($_POST['wysijaData'])) {
12
- $rawData = $_POST['wysijaData'];
13
- // avoid using stripslashes as it's not reliable depending on the magic quotes settings
14
- $rawData = str_replace('\"', '"', $rawData);
15
- // decode JSON data
16
- $rawData = json_decode($rawData, true);
17
-
18
- $theme = (isset($rawData['theme'])) ? $rawData['theme'] : 'default';
19
-
20
- $wjEngine = WYSIJA::get('wj_engine', 'helper');
21
- $res['templates'] = $wjEngine->renderTheme($theme);
22
-
23
- $email_id = (int)$_REQUEST['id'];
24
-
25
- $campaignsHelper = WYSIJA::get('campaigns', 'helper');
26
-
27
- if(isset($res['templates']['divider_options'])) {
28
- // save divider
29
- $campaignsHelper->saveParameters($email_id, 'divider', $res['templates']['divider_options']);
30
- }
31
-
32
- // save theme used
33
- $campaignsHelper->saveParameters($email_id, 'theme', $theme);
34
-
35
- $res['templates']['theme'] = $theme;
36
- $res['styles'] = $wjEngine->renderThemeStyles($theme);
37
- } else {
38
- $res['msg'] = __("The theme you selected could not be loaded.",WYSIJA);
39
- $res['result'] = false;
40
- }
41
- return $res;
42
- }
43
-
44
- function save_editor() {
45
- // decode json data and convert to array
46
- $rawData = '';
47
- if(isset($_POST['wysijaData'])) {
48
- $rawData = $_POST['wysijaData'];
49
- // avoid using stripslashes as it's not reliable depending on the magic quotes settings
50
- $rawData = str_replace('\"', '"', $rawData);
51
- // decode JSON data
52
- $rawData = json_decode($rawData, true);
53
- }
54
-
55
- if(!$rawData){
56
- $this->error('Error saving',false);
57
- return array('result' => false);
58
- }
59
-
60
- $wjEngine = WYSIJA::get('wj_engine', 'helper');
61
- $wjEngine->setData($rawData);
62
- $result = false;
63
-
64
- // get email id
65
- $email_id = (int)$_REQUEST['id'];
66
-
67
- $modelEmail = WYSIJA::get('email', 'model');
68
- $emailData = $modelEmail->getOne(array('wj_styles', 'subject', 'params', 'email_id'), array('email_id' => $email_id));
69
-
70
- $wjEngine->setStyles($emailData['wj_styles'], true);
71
-
72
- $values = array('wj_data' => $wjEngine->getEncoded('data'));
73
- $values['body'] = $wjEngine->renderEmail($emailData);
74
- $values['email_id']=$email_id;
75
-
76
- // wtf is that? could it explain the Sent On being updated for no reason?
77
- $modelEmail->columns['modified_at']['autoup']=1;
78
-
79
- // update data in DB
80
- $result = $modelEmail->update($values, array('email_id' => $email_id));
81
-
82
- if(!$result) {
83
- // throw error
84
- $this->error(__('Your email could not be saved', WYSIJA));
85
- } else {
86
- // save successful
87
- $this->notice(__('Your email has been saved', WYSIJA));
88
- }
89
-
90
- return array('result' => $result);
91
- }
92
-
93
- function save_styles() {
94
- // decode json data and convert to array
95
- $rawData = '';
96
- if(isset($_POST['wysijaStyles'])) {
97
- $rawData = $_POST['wysijaStyles'];
98
- // avoid using stripslashes as it's not reliable depending on the magic quotes settings
99
- $rawData = str_replace('\"', '"', $rawData);
100
- // decode JSON data
101
- $rawData = json_decode($rawData, true);
102
-
103
- }
104
-
105
- // handle checkboxes
106
- if(array_key_exists('a-underline', $rawData) === false) {
107
- $rawData['a-underline'] = -1;
108
- }
109
-
110
- $wjEngine = WYSIJA::get('wj_engine', 'helper');
111
- $wjEngine->setStyles($wjEngine->formatStyles($rawData));
112
-
113
- $result = false;
114
-
115
- $values = array(
116
- 'wj_styles' => $wjEngine->getEncoded('styles')
117
- );
118
-
119
- // get email id
120
- $email_id = (int)$_REQUEST['id'];
121
-
122
- // update data in DB
123
- $modelEmail = WYSIJA::get('email', 'model');
124
- $result = $modelEmail->update($values, array('email_id' => $email_id));
125
-
126
- if(!$result) {
127
- // throw error
128
- $this->error(__('Styles could not be saved', WYSIJA));
129
- } else {
130
- // save successful
131
- $this->notice(__('Styles have been saved', WYSIJA));
132
- }
133
-
134
- return array(
135
- 'styles' => $wjEngine->renderStyles(),
136
- 'result' => $result
137
- );
138
- }
139
-
140
- function deleteimg(){
141
-
142
- if(isset($_REQUEST['imgid']) && $_REQUEST['imgid']>0){
143
- /* delete the image with id imgid */
144
- $result=wp_delete_attachment($_REQUEST['imgid'],true);
145
- if($result){
146
- $this->notice(__('Image has been deleted.',WYSIJA));
147
- }
148
- }
149
-
150
- $res=array();
151
- $res['result'] = $result;
152
- return $res;
153
- }
154
-
155
- function deleteTheme(){
156
- if(isset($_REQUEST['themekey']) && $_REQUEST['themekey']){
157
- /* delete the image with id imgid */
158
- $helperTheme=WYSIJA::get('themes','helper');
159
- $result=$helperTheme->delete($_REQUEST['themekey']);
160
- }
161
-
162
- $res=array();
163
- $res['result'] = $result;
164
- return $res;
165
- }
166
-
167
- // set newsletter default theme
168
- function setDefaultTheme() {
169
- if(isset($_REQUEST['theme']) && $_REQUEST['theme']) {
170
- // check that the theme exists
171
- // TODO
172
- $theme_exists = true;
173
- if($theme_exists === true) {
174
- // update config
175
- $model_config = WYSIJA::get('config', 'model');
176
- $model_config->save(array('newsletter_default_theme' => $_REQUEST['theme']));
177
-
178
- $result = true;
179
- } else {
180
- $result = false;
181
- }
182
- }
183
-
184
- return array('result' => $result);
185
- }
186
-
187
- function save_IQS() {
188
- // decode json data and convert to array
189
- $wysijaIMG = '';
190
- if(isset($_POST['wysijaIMG'])) {
191
- $wysijaIMG = json_decode(stripslashes($_POST['wysijaIMG']), TRUE);
192
- }
193
- $values = array(
194
- 'params' => array('quickselection'=>$wysijaIMG)
195
- );
196
-
197
- // get email id
198
- $email_id = (int)$_REQUEST['id'];
199
- $values['email_id']=$email_id;
200
-
201
- // update data in DB
202
- $modelEmail = WYSIJA::get('email', 'model');
203
- $result = $modelEmail->update($values, array('email_id' => $email_id));
204
-
205
- if(!$result) {
206
- // throw error
207
- $this->error(__('Image selection has not been saved.', WYSIJA));
208
- } else {
209
- // save successful
210
- $this->notice(__('Image selection has been saved.', WYSIJA));
211
- }
212
-
213
- return array('result' => $result);
214
- }
215
-
216
-
217
- function view_NL() {
218
- // get campaign id
219
- $email_id = (int)$_REQUEST['id'];
220
-
221
- // update data in DB
222
- $modelEmail = WYSIJA::get('email', 'model');
223
- $result = $modelEmail->getOne(false,array('email_id' => $email_id));
224
-
225
- echo $result['body'];
226
- exit;
227
- }
228
-
229
- function display_NL() {
230
- // get email id
231
- $email_id = (int)$_REQUEST['id'];
232
-
233
- // update data in DB
234
- $modelEmail = WYSIJA::get('email', 'model');
235
- $email= $modelEmail->getOne(false,array('email_id' => $email_id));
236
-
237
- $wjEngine = WYSIJA::get('wj_engine', 'helper');
238
- $wjEngine->setStyles($result['wj_styles'], true);
239
- $wjEngine->setData($result['wj_data'], true);
240
- $html = $wjEngine->renderEmail($email);
241
- print $html;
242
- exit;
243
- }
244
-
245
- /**
246
- * returns a list of articles to the popup in the visual editor
247
- * @global type $wpdb
248
- * @return boolean
249
- */
250
- function get_articles(){
251
- // fixes issue with pcre functions
252
- @ini_set('pcre.backtrack_limit', 1000000);
253
-
254
- $model=WYSIJA::get('user','model');
255
-
256
- //Carefull WordPress global
257
- global $wpdb;
258
- $mConfig=WYSIJA::get('config','model');
259
- $isFullArticle=$mConfig->getValue('editor_fullarticle');
260
-
261
- //test to set the default value
262
- if(!$isFullArticle && isset($_REQUEST['fullarticle'])){
263
- $mConfig->save(array('editor_fullarticle'=>true));
264
- }
265
-
266
- if($isFullArticle && !isset($_REQUEST['fullarticle'])){
267
- $mConfig->save(array('editor_fullarticle'=>false));
268
- }
269
- $cpt = array('post');
270
- if(isset($_REQUEST['cpt'])){
271
- $cpt = array();
272
- if($_REQUEST['cpt'] === 'all') {
273
- $hWPTools = WYSIJA::get('wp_tools','helper');
274
- $post_types = $hWPTools->get_post_types();
275
- $cpt = array_keys($post_types);
276
- $cpt[] = 'post';
277
- $cpt[] = 'page';
278
- } else {
279
- $cpt = $_REQUEST['cpt'];
280
- }
281
-
282
- $query_cpt = '';
283
- if(is_array($cpt)) {
284
- $query_cpt = ' '.$wpdb->posts.'.post_type IN ("'. implode('", "', $cpt).'")';
285
- } else {
286
- $query_cpt = ' '.$wpdb->posts.'.post_type="'.$cpt.'"';
287
- }
288
- }
289
- $hWPTools = WYSIJA::get('wp_tools','helper');
290
- $post_statuses = $hWPTools->get_post_statuses();
291
- if(isset($_REQUEST['status'])){
292
- $statuses = array();
293
- if($_REQUEST['status'] === 'all') {
294
-
295
- $statuses = array_keys($post_statuses);
296
- $statuses[] = 'future';
297
- } else {
298
- $statuses = $_REQUEST['status'];
299
- }
300
-
301
- $query_statuses = '';
302
- if(is_array($statuses)) {
303
- $query_statuses = ' AND '.$wpdb->posts.'.post_status IN ("'. implode('", "', $statuses).'")';
304
- } else {
305
- $query_statuses = ' AND '.$wpdb->posts.'.post_status="'.$statuses.'"';
306
- }
307
- }
308
-
309
- $limitquery='';
310
- $res=array();
311
- $res['append']=false;
312
-
313
- if(isset($_REQUEST['query_offset']) && (int)$_REQUEST['query_offset']){
314
- $res['append']=true;
315
- $limitquery = ' LIMIT '.(int)($_REQUEST['query_offset']).',10';
316
- } else {
317
- $limitquery = ' LIMIT 0,10';
318
- }
319
-
320
- if(isset($_REQUEST['search']) && strlen(trim($_REQUEST['search'])) > 0) {
321
- $querystr = "SELECT $wpdb->posts.ID , $wpdb->posts.post_type, $wpdb->posts.post_title, $wpdb->posts.post_content, $wpdb->posts.post_excerpt , $wpdb->posts.post_status
322
- FROM $wpdb->posts
323
- WHERE $wpdb->posts.post_title like '%".addcslashes(mysql_real_escape_string($_REQUEST['search'],$wpdb->dbh), '%_' )."%'";
324
-
325
- $querystr.= ' AND '.$query_cpt.$query_statuses;
326
-
327
- $querystr.=" ORDER BY $wpdb->posts.post_date DESC";
328
- $querystr.=$limitquery;
329
- // query to count total rows
330
- $queryCount = "SELECT COUNT(*) as total FROM $wpdb->posts WHERE $wpdb->posts.post_title like '%".addcslashes(mysql_real_escape_string($_REQUEST['search'],$wpdb->dbh), '%_' )."%' AND ".$query_cpt.$query_statuses;
331
- }else{
332
- $querystr = "SELECT $wpdb->posts.ID , $wpdb->posts.post_type, $wpdb->posts.post_title, $wpdb->posts.post_content, $wpdb->posts.post_excerpt , $wpdb->posts.post_status
333
- FROM $wpdb->posts WHERE";
334
-
335
- $querystr.= $query_cpt.$query_statuses;
336
-
337
- $querystr.= " ORDER BY $wpdb->posts.post_date DESC";
338
- $querystr.=$limitquery;
339
-
340
- // query to count total rows
341
- $queryCount = "SELECT COUNT(*) as total FROM $wpdb->posts WHERE ".$query_cpt.$query_statuses;
342
- }
343
-
344
- $res['posts']=$model->query('get_res',$querystr);
345
- $count = $model->query('get_row', $queryCount);
346
- $res['total'] = (int)$count['total'];
347
-
348
- $helper_engine=WYSIJA::get('wj_engine','helper');
349
- $helper_articles = WYSIJA::get('articles', 'helper');
350
-
351
- // set params for post format
352
- $params = array('post_content' => 'full');
353
-
354
- //if excerpt has been requested then we try to provide it */
355
- if(!isset($_REQUEST['fullarticle'])) {
356
- $params['post_content'] = 'excerpt';
357
- }
358
-
359
- if($res['posts']){
360
- $res['result'] = true;
361
- foreach($res['posts'] as $k =>$v){
362
- if($mConfig->getValue('interp_shortcode')) $res['posts'][$k]['post_content']=apply_filters('the_content',$res['posts'][$k]['post_content']);
363
-
364
- $res['posts'][$k]['post_status']=$post_statuses[$res['posts'][$k]['post_status']];
365
-
366
-
367
- // get thumbnail
368
- $res['posts'][$k]['post_image'] = $helper_articles->getImage($v);
369
-
370
- // convert post data into block data
371
- $block = $helper_articles->convertPostToBlock($res['posts'][$k], $params);
372
-
373
- // make editor block from post data
374
- $res['posts'][$k]['html'] = base64_encode($helper_engine->renderEditorBlock($block));
375
- }
376
- }else {
377
- $res['msg'] = __('There are no posts corresponding to that search.',WYSIJA);
378
- $res['result'] = false;
379
- }
380
-
381
- return $res;
382
- }
383
-
384
- function send_preview($spamtest=false){
385
- $mailer=WYSIJA::get('mailer','helper');
386
- $email_id = $_REQUEST['id'];
387
- $resultarray=array();
388
-
389
- // update data in DB
390
- $model_email = WYSIJA::get('email', 'model');
391
- $model_email->getFormat=OBJECT;
392
- $email_object = $model_email->getOne(false,array('email_id' => $email_id));
393
- $mailer->testemail=true;
394
-
395
-
396
- if(isset($_REQUEST['data'])){
397
- $dataTemp=$_REQUEST['data'];
398
- $_REQUEST['data']=array();
399
- foreach($dataTemp as $val) $_REQUEST['data'][$val['name']]=$val['value'];
400
- unset($dataTemp);
401
- foreach($_REQUEST['data'] as $k =>$v){
402
- $newkey=str_replace(array('wysija[email][',']'),'',$k);
403
- $configVal[$newkey]=$v;
404
- }
405
- if(isset($configVal['from_name'])){
406
- $params=array(
407
- 'from_name'=>$configVal['from_name'],
408
- 'from_email'=>$configVal['from_email'],
409
- 'replyto_name'=>$configVal['replyto_name'],
410
- 'replyto_email'=>$configVal['replyto_email']);
411
- if(isset($configVal['subject'])) $email_object->subject=$configVal['subject'];
412
- }
413
-
414
- }else{
415
- $params=array(
416
- 'from_name'=>$email_object->from_name,
417
- 'from_email'=>$email_object->from_email,
418
- 'replyto_name'=>$email_object->replyto_name,
419
- 'replyto_email'=>$email_object->replyto_email
420
- );
421
- }
422
- if(strpos($_REQUEST['receiver'], ',')) {
423
- $receivers = explode(',',$_REQUEST['receiver']);
424
- } else if(strpos($_REQUEST['receiver'], ';')) {
425
- $receivers = explode(';',$_REQUEST['receiver']);
426
- } else {
427
- $receivers = array($_REQUEST['receiver']);
428
- }
429
-
430
- $user_model = WYSIJA::get('user', 'model');
431
- foreach($receivers as $key => $receiver){
432
- $receiver = trim($receiver);
433
- $dummy_receiver = $user_model->get_object_by_email($receiver);
434
- if(empty($dummy_receiver)){
435
- $dummy_receiver = new stdClass();
436
- $dummy_receiver->user_id = 0;
437
- $dummy_receiver->email = $receiver;
438
- $dummy_receiver->status = 1;
439
- $dummy_receiver->lastname = $dummy_receiver->firstname = '';
440
- }
441
-
442
- if($spamtest){
443
- $langextra = '';
444
- $dummy_receiver->firstname ='Mail Tester';
445
- if(defined('WPLANG') && WPLANG) $langextra ='&lang='.WPLANG;
446
- $resultarray['urlredirect']='http://www.mail-tester.com/check.php?id='.urlencode($dummy_receiver->email).$langextra;
447
- }
448
- $receivers[$key] = $dummy_receiver;
449
-
450
- }
451
-
452
- $email_clone=array();
453
- foreach($email_object as $kk=>$vv) $email_clone[$kk]=$vv;
454
-
455
-
456
- $wj_engine = WYSIJA::get('wj_engine', 'helper');
457
- // set data & styles
458
- if(isset($email_clone['wj_data'])) { $wj_engine->setData($email_clone['wj_data'], true); } else { $wj_engine->setData(); }
459
- if(isset($email_clone['wj_styles'])) { $wj_engine->setStyles($email_clone['wj_styles'], true); } else { $wj_engine->setStyles(); }
460
-
461
- // generate email html body
462
- $body = $wj_engine->renderEmail($email_clone);
463
-
464
- // get back email data as it will be updated during the rendering (articles ids + articles count)
465
- $email_child = $wj_engine->getEmailData();
466
-
467
- // [total] [number] and [post_title] are only valid for post notifications newsletter
468
- if((int)$email_child['type'] === 2 && isset($email_child['params']['autonl']['event']) &&
469
- $email_child['params']['autonl']['event'] === 'new-articles' && isset($email_child['params']['autonl']['articles'])){
470
-
471
- $item_count = 0;
472
- $total_count = 1;
473
- $first_subject = '';
474
-
475
- if(isset($email_child['params']['autonl']['articles']['count'])) $item_count = (int)$email_child['params']['autonl']['articles']['count'];
476
- if(isset($email_child['params']['autonl']['articles']['first_subject'])) $first_subject = $email_child['params']['autonl']['articles']['first_subject'];
477
- if(isset($email_clone['params']['autonl']['total_child'])) $total_count = (int)$email_clone['params']['autonl']['total_child'] + 1;
478
-
479
- if(empty($first_subject)) {
480
- $this->error(__('There are no articles to be sent in this email.',WYSIJA),1);
481
- return array('result' => false);
482
- }
483
- $email_object->subject = str_replace(
484
- array('[total]','[number]','[post_title]'),
485
- array($item_count, $total_count, $first_subject),
486
- $email_child['subject']);
487
- }
488
-
489
- $successmsg = __('Your email preview has been sent to %1$s', WYSIJA);
490
-
491
- if(isset($email_object->params)) {
492
- $params['params']=$email_object->params;
493
-
494
- if(isset($configVal['params[googletrackingcode'])){
495
- $paramsemail=array();
496
- if(!is_array($email_object->params)) $paramsemail=unserialize(base64_decode($email_object->params));
497
-
498
- if(trim($configVal['params[googletrackingcode'])) {
499
- $paramsemail['googletrackingcode']=$configVal['params[googletrackingcode'];
500
- }
501
- else {
502
- unset($paramsemail['googletrackingcode']);
503
- }
504
- $params['params'] = base64_encode(serialize($paramsemail));
505
- }
506
- }
507
-
508
- $params['email_id'] = $email_object->email_id;
509
- $receiversList = array();
510
- $res = false;
511
- foreach($receivers as $receiver){
512
- if($mailer->sendSimple($receiver, stripslashes($email_object->subject),$email_object->body,$params)) {
513
- $res = true;
514
- $receiversList[] = $receiver->email;
515
- }
516
- WYSIJA::log('preview_sent', $mailer, 'manual');
517
- }
518
-
519
- if($res === true) {
520
- $this->notice(sprintf($successmsg, implode(', ', $receiversList)));
521
- }
522
-
523
- $resultarray['result'] = $res;
524
- return $resultarray;
525
- }
526
-
527
- /**
528
- * send spam test function step 2 of the newsletter edition process
529
- */
530
- function send_spamtest(){
531
- return apply_filters('wysija_send_spam_test','',$this);
532
- }
533
-
534
- function set_divider()
535
- {
536
- $src = isset($_POST['wysijaData']['src']) ? $_POST['wysijaData']['src'] : NULL;
537
- $width = isset($_POST['wysijaData']['width']) ? (int)$_POST['wysijaData']['width'] : NULL;
538
- $height = isset($_POST['wysijaData']['height']) ? (int)$_POST['wysijaData']['height'] : NULL;
539
-
540
- if($src === NULL OR $width === NULL OR $height === NULL) {
541
- // there is a least one missing parameter, fallback to default divider
542
- $dividersHelper = WYSIJA::get('dividers', 'helper');
543
- $divider = $dividersHelper->getDefault();
544
- } else {
545
- // use provided params
546
- $divider = array(
547
- 'src' => $src,
548
- 'width' => $width,
549
- 'height' => $height
550
- );
551
- }
552
-
553
- // update campaign parameters
554
- $email_id = (int)$_REQUEST['id'];
555
- $campaignsHelper = WYSIJA::get('campaigns', 'helper');
556
- $campaignsHelper->saveParameters($email_id, 'divider', $divider);
557
-
558
- // set params
559
- $block = array_merge(array('no-block' => true, 'type' => 'divider'), $divider);
560
-
561
- $helper_engine=WYSIJA::get('wj_engine','helper');
562
- return base64_encode($helper_engine->renderEditorBlock($block));
563
- }
564
-
565
- function get_social_bookmarks() {
566
- $size = isset($_POST['wysijaData']['size']) ? $_POST['wysijaData']['size'] : NULL;
567
- $theme = isset($_POST['wysijaData']['theme']) ? $_POST['wysijaData']['theme'] : NULL;
568
-
569
- $bookmarksHelper = WYSIJA::get('bookmarks', 'helper');
570
- $bookmarks = $bookmarksHelper->getAll($size, $theme);
571
- return json_encode(array('icons' => $bookmarks));
572
- }
573
-
574
- function generate_social_bookmarks() {
575
-
576
- $size = 'medium';
577
- $iconset = '01';
578
-
579
- if(isset($_POST['wysijaData']) && !empty($_POST['wysijaData'])) {
580
- $data = $_POST['wysijaData'];
581
- $items = array();
582
-
583
- foreach($data as $key => $values) {
584
- if($values['name'] === 'bookmarks-size') {
585
- // get size
586
- $size = $values['value'];
587
- } else if($values['name'] === 'bookmarks-theme') {
588
- // get theme name
589
- $theme = $values['value'];
590
- } else if($values['name'] === 'bookmarks-iconset') {
591
- // get iconset
592
- $iconset = $values['value'];
593
- if(strlen(trim($iconset)) === 0) {
594
- $this->error('No iconset specified', false);
595
- return false;
596
- }
597
- } else {
598
- $keys = explode('-', $values['name']);
599
- $network = $keys[1];
600
- $property = $keys[2];
601
- if(array_key_exists($network, $items)) {
602
- $items[$network][$property] = $values['value'];
603
- } else {
604
- $items[$network] = array($property => $values['value']);
605
- }
606
- }
607
- }
608
- }
609
-
610
- $urls = array();
611
- // check data and remove network with an empty url
612
- foreach($items as $network => $item) {
613
- if(strlen(trim($item['url'])) === 0) {
614
- // empty url
615
- unset($items[$network]);
616
- } else {
617
- // url specified
618
- $urls[$network] = $item['url'];
619
- }
620
- }
621
-
622
- // check if there's at least one url left
623
- if(empty($urls)) {
624
- $this->error('No url specified', false);
625
- return false;
626
- }
627
-
628
- // save url in config
629
- $config=WYSIJA::get('config','model');
630
- $config->save(array('social_bookmarks' => $urls));
631
-
632
- // get iconset icons
633
- $bookmarksHelper = WYSIJA::get('bookmarks', 'helper');
634
-
635
- // if the iconset is 00, then it's the theme's bookmarks
636
- if($iconset === '00') {
637
- $icons = $bookmarksHelper->getAllByTheme($theme);
638
- } else {
639
- // otherwise it's a basic iconset
640
- $icons = $bookmarksHelper->getAllByIconset($size, $iconset);
641
- }
642
-
643
-
644
- // format data
645
- $block = array(
646
- 'position' => 1,
647
- 'type' => 'gallery',
648
- 'items' => array(),
649
- 'alignment' => 'center'
650
- );
651
-
652
- $width = 0;
653
- foreach($items as $key => $item) {
654
- $block['items'][] = array_merge($item, $icons[$key], array('alt' => ucfirst($key)));
655
- $width += (int)$icons[$key]['width'];
656
- }
657
- // add margin between icons
658
- $width += (count($block['items']) - 1) * 10;
659
- // set optimal width
660
- $block['width'] = max(0, min($width, 564));
661
-
662
- $helper_engine=WYSIJA::get('wj_engine','helper');
663
- return base64_encode($helper_engine->renderEditorBlock($block));
664
- }
665
-
666
- function install_theme() {
667
- if( isset($_REQUEST['theme_id'])){
668
-
669
- //check if theme is premium if you have the premium licence
670
- if(isset($_REQUEST['premium']) && $_REQUEST['premium']){
671
- $getpremiumtheme=apply_filters('wysija_install_theme_premium', false);
672
-
673
- if(!$getpremiumtheme){
674
- $wjEngine = WYSIJA::get('wj_engine', 'helper');
675
- $themes = $wjEngine->renderThemes();
676
- return array('result'=>false, 'themes' => $themes);
677
- }
678
- }
679
-
680
-
681
- $httpHelp=WYSIJA::get('http','helper');
682
- $url=admin_url('admin.php');
683
-
684
- $helperToolbox=WYSIJA::get('toolbox','helper');
685
- $domain_name=$helperToolbox->_make_domain_name($url);
686
-
687
- $request='http://api.wysija.com/download/zip/'.$_REQUEST['theme_id'].'?domain='.$domain_name;
688
-
689
- $ZipfileResult = $httpHelp->request($request);
690
-
691
- if(!$ZipfileResult){
692
- $result=false;
693
- $this->error(__('We were unable to contact the API, the site may be down. Please try again later.',WYSIJA),true);
694
- }else{
695
- $themesHelp=WYSIJA::get('themes','helper');
696
- $result = $themesHelp->installTheme($ZipfileResult);
697
-
698
- // refresh themes list
699
- $wjEngine = WYSIJA::get('wj_engine', 'helper');
700
- $themes = $wjEngine->renderThemes();
701
- }
702
- }else{
703
- $result=false;
704
- $this->notice('missing info');
705
- }
706
-
707
- return array('result'=>$result, 'themes' => $themes);
708
- }
709
-
710
- function refresh_themes() {
711
- // refresh themes list
712
- $wjEngine = WYSIJA::get('wj_engine', 'helper');
713
- return array('result'=>true, 'themes' => $wjEngine->renderThemes());
714
- }
715
-
716
- function generate_auto_post() {
717
- // get params and generate html
718
- $wjEngine = WYSIJA::get('wj_engine', 'helper');
719
- $helper_articles = WYSIJA::get('articles', 'helper');
720
-
721
- // get parameters
722
- $block_params = array();
723
- if(isset($_POST['wysijaData'])) {
724
- foreach($_POST['wysijaData'] as $pairs) {
725
- // special cases
726
- switch($pairs['name']) {
727
- case 'readmore':
728
- case 'nopost_message':
729
- $block_params[] = array('key' => $pairs['name'], 'value' => base64_encode(stripslashes($pairs['value'])));
730
- break;
731
- default:
732
- $block_params[] = array('key' => $pairs['name'], 'value' => $pairs['value']);
733
- }
734
- }
735
- }
736
-
737
- if(empty($block_params)) {
738
- // an error occurred, do something!
739
- return false;
740
- } else {
741
- $data = array(
742
- 'type' => 'auto-post',
743
- 'params' => $block_params
744
- );
745
- return base64_encode($wjEngine->renderEditorBlock($data));
746
- }
747
- }
748
-
749
- function load_auto_post() {
750
- $params = array();
751
-
752
- if(isset($_POST['wysijaData'])) {
753
-
754
- $pairs = explode('&', $_POST['wysijaData']);
755
-
756
- foreach($pairs as $pair) {
757
- list($key, $value) = explode('=', $pair);
758
-
759
-
760
- switch($key) {
761
- case 'autopost_count':
762
- $params[$key] = (int)$value;
763
- break;
764
- case 'readmore':
765
- case 'nopost_message':
766
- $params[$key] = base64_decode($value);
767
- break;
768
- case 'exclude':
769
- $params[$key] = explode(',', $value);
770
- break;
771
- default:
772
- $params[$key] = $value;
773
- }
774
- }
775
- }
776
-
777
- if(empty($params)) {
778
- // an error occurred, do something!
779
- return false;
780
- } else {
781
- // get email params
782
- $email_id = (int)$_REQUEST['id'];
783
- $modelEmail = WYSIJA::get('email', 'model');
784
- $email = $modelEmail->getOne(array('params','sent_at','campaign_id'), array('email_id' => $email_id));
785
-
786
- $articlesHelper = WYSIJA::get('articles', 'helper');
787
- $wjEngine = WYSIJA::get('wj_engine', 'helper');
788
-
789
- // see if posts have already been sent
790
- if(!empty($email['params']['autonl']['articles']['ids'])) {
791
-
792
- if(!isset($params['exclude'])) { $params['exclude'] = array(); }
793
-
794
- $params['exclude'] = array_unique(array_merge($email['params']['autonl']['articles']['ids'], $params['exclude']));
795
- }
796
-
797
- //we set the post_date to filter articles only older than that one
798
- if(isset($email['params']['autonl']['firstSend'])){
799
- $params['post_date'] = $email['params']['autonl']['firstSend'];
800
- }
801
-
802
- // if immediate let it know to the get post
803
- if(isset($email['params']['autonl']['articles']['immediatepostid'])){
804
- $params['include'] = $email['params']['autonl']['articles']['immediatepostid'];
805
- $params['post_limit'] = 1;
806
- }else{
807
- //we set the post_date to filter articles only older than the last time we sent articles
808
- if(isset($email['params']['autonl']['lastSend'])){
809
- $params['post_date'] = $email['params']['autonl']['lastSend'];
810
- }else{
811
- //get the latest child newsletter sent_at value
812
- $mEmail=WYSIJA::get('email','model');
813
- $mEmail->reset();
814
- $mEmail->orderBy('email_id','DESC');
815
- $lastEmailSent=$mEmail->getOne(false,array('campaign_id'=>$email['campaign_id'],'type'=>'1'));
816
-
817
- if(isset($data['sent_at'])) $params['post_date'] = $lastEmailSent['sent_at'];
818
- }
819
- }
820
-
821
-
822
-
823
- $posts = $articlesHelper->getPosts($params);
824
-
825
- // used to keep track of post ids present in the auto post
826
- $post_ids = array();
827
-
828
- // cleanup post and get image
829
- foreach($posts as $key => $post) {
830
- if($params['image_alignment'] !== 'none') {
831
- // attempt to get post image
832
- $posts[$key]['post_image'] = $articlesHelper->getImage($post);
833
- }
834
-
835
- $posts[$key] = $articlesHelper->convertPostToBlock($posts[$key], $params);
836
-
837
- // store article id
838
- $post_ids[] = $post['ID'];
839
- }
840
- // store article ids
841
- $params['post_ids'] = join(',', $post_ids);
842
-
843
- // get divider if necessary
844
- if($params['show_divider'] === 'yes') {
845
- if(isset($email['params']['divider'])) {
846
- $params['divider'] = $email['params']['divider'];
847
- } else {
848
- $dividersHelper = WYSIJA::get('dividers', 'helper');
849
- $params['divider'] = $dividersHelper->getDefault();
850
- }
851
- }
852
-
853
- return base64_encode($wjEngine->renderEditorAutoPost($posts, $params));
854
- }
855
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
856
  }
2
  defined('WYSIJA') or die('Restricted access');
3
  class WYSIJA_control_back_campaigns extends WYSIJA_control{
4
 
5
+ function WYSIJA_control_back_campaigns(){
6
+ if(!WYSIJA::current_user_can('wysija_newsletters')) die('Action is forbidden.');
7
+ parent::WYSIJA_control();
8
+ }
9
+
10
+ function save_poll(){
11
+ $model_config = WYSIJA::get('config','model');
12
+ $model_config->save(array('poll_origin' => $_REQUEST['how'] , 'poll_origin_url' => $_REQUEST['where']));
13
+
14
+ $res['result'] = true;
15
+ $res['msg'] = '<span><span class="checkmark">---</span>'. __('Thanks!',WYSIJA). '</span>';
16
+ return $res;
17
+ }
18
+
19
+ function search_terms( $request = null ){
20
+ $response = (object) array(
21
+ 'status' => false,
22
+ 'message' => __( 'Your request has failed', WYSIJA ),
23
+ 'results' => array(),
24
+ 'more' => true,
25
+ );
26
+
27
+ if ( ( ! defined( 'DOING_AJAX' ) && is_null( $request ) ) || ! is_user_logged_in() ){
28
+ return $response;
29
+ }
30
+
31
+ $request = (object) wp_parse_args(
32
+ $request,
33
+ array(
34
+ 'search' => isset( $_GET['search'] ) ? $_GET['search'] : '',
35
+ 'post_type' => isset( $_GET['post_type'] ) ? $_GET['post_type'] : null,
36
+ 'page' => absint( isset( $_GET['page'] ) ? $_GET['page'] : 0 ),
37
+ 'page_limit' => absint( isset( $_GET['page_limit'] ) ? $_GET['page_limit'] : 10 ),
38
+ )
39
+ );
40
+
41
+ if ( is_null( $request->post_type ) ){
42
+ return $response;
43
+ }
44
+
45
+ $response->status = true;
46
+ $response->message = __( 'Request successful', WYSIJA );
47
+
48
+ $response->post_type = get_post_types( array( 'name' => $request->post_type ) );
49
+ $response->post_type = reset( $response->post_type );
50
+
51
+ preg_match( '/@(\w+)/i', $request->search, $response->regex );
52
+
53
+ if ( ! empty( $response->regex ) ){
54
+ $request->search = array_filter( array_map( 'trim', explode( '|', str_replace( $response->regex[0], '|', $request->search ) ) ) );
55
+ $request->search = reset( $request->search );
56
+ $taxonomies = $response->regex[1];
57
+ } else {
58
+ $taxonomies = get_object_taxonomies( $response->post_type );
59
+ }
60
+ $response->taxonomies = get_object_taxonomies( $response->post_type, 'objects' );
61
+
62
+ $response->results = get_terms(
63
+ (array) $taxonomies,
64
+ array(
65
+ 'hide_empty' => false,
66
+ 'search' => $request->search,
67
+ 'number' => $request->page_limit,
68
+ 'offset' => $request->page_limit * ( $request->page - 1 ),
69
+ )
70
+ );
71
+
72
+ if ( empty( $response->results ) || count( $response->results ) < $request->page_limit ){
73
+ $response->more = false;
74
+ }
75
+
76
+ return $response;
77
+ }
78
+
79
+ function switch_theme() {
80
+ if(isset($_POST['wysijaData'])) {
81
+ $rawData = $_POST['wysijaData'];
82
+ // avoid using stripslashes as it's not reliable depending on the magic quotes settings
83
+ $rawData = str_replace('\"', '"', $rawData);
84
+ // decode JSON data
85
+ $rawData = json_decode($rawData, true);
86
+
87
+ $theme = (isset($rawData['theme'])) ? $rawData['theme'] : 'default';
88
+
89
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
90
+ $res['templates'] = $helper_wj_engine->renderTheme($theme);
91
+
92
+ $email_id = (int)$_REQUEST['id'];
93
+
94
+ $campaignsHelper = WYSIJA::get('campaigns', 'helper');
95
+
96
+ if(isset($res['templates']['divider_options'])) {
97
+ // save divider
98
+ $campaignsHelper->saveParameters($email_id, 'divider', $res['templates']['divider_options']);
99
+ }
100
+
101
+ // save theme used
102
+ $campaignsHelper->saveParameters($email_id, 'theme', $theme);
103
+
104
+ $res['templates']['theme'] = $theme;
105
+ $res['styles'] = $helper_wj_engine->renderThemeStyles($theme);
106
+ } else {
107
+ $res['msg'] = __("The theme you selected could not be loaded.",WYSIJA);
108
+ $res['result'] = false;
109
+ }
110
+ return $res;
111
+ }
112
+
113
+ function save_editor() {
114
+ // decode json data and convert to array
115
+ $rawData = '';
116
+ if(isset($_POST['wysijaData'])) {
117
+ $rawData = $_POST['wysijaData'];
118
+ // avoid using stripslashes as it's not reliable depending on the magic quotes settings
119
+ $rawData = str_replace('\"', '"', $rawData);
120
+ // decode JSON data
121
+ $rawData = json_decode($rawData, true);
122
+ }
123
+
124
+ if(!$rawData){
125
+ $this->error('Error saving',false);
126
+ return array('result' => false);
127
+ }
128
+
129
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
130
+ $helper_wj_engine->setData($rawData);
131
+ $result = false;
132
+
133
+ // get email id
134
+ $email_id = (int)$_REQUEST['id'];
135
+
136
+ $model_email = WYSIJA::get('email', 'model');
137
+ $emailData = $model_email->getOne(array('wj_styles', 'subject', 'params', 'email_id', 'campaign_id'), array('email_id' => $email_id));
138
+
139
+ $helper_wj_engine->setStyles($emailData['wj_styles'], true);
140
+
141
+ $values = array('wj_data' => $helper_wj_engine->getEncoded('data'));
142
+ $values['body'] = $helper_wj_engine->renderEmail($emailData);
143
+ $values['email_id'] = $email_id;
144
+
145
+ $updated_email = $helper_wj_engine->getEmailData();
146
+
147
+ // update modified_at timestamp
148
+ $model_email->columns['modified_at']['autoup']=1;
149
+
150
+ // update data in DB
151
+ $result = $model_email->update($values, array('email_id' => $email_id));
152
+
153
+ if(!$result) {
154
+ // throw error
155
+ $this->error(__('Your email could not be saved', WYSIJA));
156
+ } else {
157
+ // save successful
158
+ $this->notice(__('Your email has been saved', WYSIJA));
159
+ }
160
+
161
+ return array('result' => $result);
162
+ }
163
+
164
+ function save_styles() {
165
+ // decode json data and convert to array
166
+ $rawData = '';
167
+ if(isset($_POST['wysijaStyles'])) {
168
+ $rawData = $_POST['wysijaStyles'];
169
+ // avoid using stripslashes as it's not reliable depending on the magic quotes settings
170
+ $rawData = str_replace('\"', '"', $rawData);
171
+ // decode JSON data
172
+ $rawData = json_decode($rawData, true);
173
+
174
+ }
175
+
176
+ // handle checkboxes
177
+ if(array_key_exists('a-underline', $rawData) === false) {
178
+ $rawData['a-underline'] = -1;
179
+ }
180
+
181
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
182
+ $helper_wj_engine->setStyles($helper_wj_engine->formatStyles($rawData));
183
+
184
+ $result = false;
185
+
186
+ $values = array(
187
+ 'wj_styles' => $helper_wj_engine->getEncoded('styles')
188
+ );
189
+
190
+ // get email id
191
+ $email_id = (int)$_REQUEST['id'];
192
+
193
+ // update data in DB
194
+ $model_email = WYSIJA::get('email', 'model');
195
+ $result = $model_email->update($values, array('email_id' => $email_id));
196
+
197
+ if(!$result) {
198
+ // throw error
199
+ $this->error(__('Styles could not be saved', WYSIJA));
200
+ } else {
201
+ // save successful
202
+ $this->notice(__('Styles have been saved', WYSIJA));
203
+ }
204
+
205
+ return array(
206
+ 'styles' => $helper_wj_engine->renderStyles(),
207
+ 'result' => $result
208
+ );
209
+ }
210
+
211
+ function deleteimg(){
212
+
213
+ if(isset($_REQUEST['imgid']) && $_REQUEST['imgid']>0){
214
+ /* delete the image with id imgid */
215
+ $result=wp_delete_attachment($_REQUEST['imgid'],true);
216
+ if($result){
217
+ $this->notice(__('Image has been deleted.',WYSIJA));
218
+ }
219
+ }
220
+
221
+ $res=array();
222
+ $res['result'] = $result;
223
+ return $res;
224
+ }
225
+
226
+ function deleteTheme(){
227
+ if(isset($_REQUEST['themekey']) && $_REQUEST['themekey']){
228
+ /* delete the image with id imgid */
229
+ $helperTheme=WYSIJA::get('themes','helper');
230
+ $result=$helperTheme->delete($_REQUEST['themekey']);
231
+ }
232
+
233
+ $res=array();
234
+ $res['result'] = $result;
235
+ return $res;
236
+ }
237
+
238
+ // set newsletter default theme
239
+ function setDefaultTheme() {
240
+ if(isset($_REQUEST['theme']) && $_REQUEST['theme']) {
241
+ // check that the theme exists
242
+ // TODO
243
+ $theme_exists = true;
244
+ if($theme_exists === true) {
245
+ // update config
246
+ $model_config = WYSIJA::get('config', 'model');
247
+ $model_config->save(array('newsletter_default_theme' => $_REQUEST['theme']));
248
+
249
+ $result = true;
250
+ } else {
251
+ $result = false;
252
+ }
253
+ }
254
+
255
+ return array('result' => $result);
256
+ }
257
+
258
+ function save_IQS() {
259
+ // decode json data and convert to array
260
+ $wysijaIMG = '';
261
+ if(isset($_POST['wysijaIMG'])) {
262
+ $wysijaIMG = json_decode(stripslashes($_POST['wysijaIMG']), TRUE);
263
+ }
264
+ $values = array(
265
+ 'params' => array('quickselection'=>$wysijaIMG)
266
+ );
267
+
268
+ // get email id
269
+ $email_id = (int)$_REQUEST['id'];
270
+ $values['email_id']=$email_id;
271
+
272
+ // update data in DB
273
+ $model_email = WYSIJA::get('email', 'model');
274
+ $result = $model_email->update($values, array('email_id' => $email_id));
275
+
276
+ if(!$result) {
277
+ // throw error
278
+ $this->error(__('Image selection has not been saved.', WYSIJA));
279
+ } else {
280
+ // save successful
281
+ $this->notice(__('Image selection has been saved.', WYSIJA));
282
+ }
283
+
284
+ return array('result' => $result);
285
+ }
286
+
287
+
288
+ function view_NL() {
289
+ // get campaign id
290
+ $email_id = (int)$_REQUEST['id'];
291
+
292
+ // update data in DB
293
+ $model_email = WYSIJA::get('email', 'model');
294
+ $result = $model_email->getOne(false,array('email_id' => $email_id));
295
+
296
+ echo $result['body'];
297
+ exit;
298
+ }
299
+
300
+ function display_NL() {
301
+ // get email id
302
+ $email_id = (int)$_REQUEST['id'];
303
+
304
+ // update data in DB
305
+ $model_email = WYSIJA::get('email', 'model');
306
+ $email= $model_email->getOne(false,array('email_id' => $email_id));
307
+
308
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
309
+ $helper_wj_engine->setStyles($result['wj_styles'], true);
310
+ $helper_wj_engine->setData($result['wj_data'], true);
311
+ $html = $helper_wj_engine->renderEmail($email);
312
+ print $html;
313
+ exit;
314
+ }
315
+
316
+ /**
317
+ * returns the images attached to displayed posts
318
+ */
319
+ function get_post_images() {
320
+ // get parameters
321
+ $params = array(
322
+
323
+ );
324
+
325
+ $result = true;
326
+
327
+ if($params['post_id'] === null) {
328
+
329
+ }
330
+
331
+ return array(
332
+ 'result' => $result,
333
+ 'images' => $images
334
+ );
335
+ }
336
+
337
+ /**
338
+ * returns a list of articles to the popup in the visual editor
339
+ * @global type $wpdb
340
+ * @return boolean
341
+ */
342
+ function get_articles(){
343
+ // fixes issue with pcre functions
344
+ @ini_set('pcre.backtrack_limit', 1000000);
345
+
346
+ // get parameters
347
+ $raw_data = $_REQUEST['data'];
348
+ $params = array();
349
+ foreach ($raw_data as $value) {
350
+ $params[$value['name']] = $value['value'];
351
+ }
352
+
353
+ // get options
354
+ $model_config = WYSIJA::get('config', 'model');
355
+ $interpret_shortcode = (bool)$model_config->getValue('interp_shortcode');
356
+
357
+ // post statuses
358
+ $helper_wp_tools = WYSIJA::get('wp_tools', 'helper');
359
+ $post_statuses = $helper_wp_tools->get_post_statuses();
360
+ $post_types = $helper_wp_tools->get_post_types();
361
+
362
+ // filter by post_type
363
+ if(isset($params['post_type'])) {
364
+ $post_types_filter = array();
365
+ if(strlen(trim($params['post_type'])) === 0) {
366
+ $post_types_filter = array_keys($post_types);
367
+ $post_types_filter[] = 'post';
368
+ $post_types_filter[] = 'page';
369
+ } else {
370
+ $post_types_filter = trim($params['post_type']);
371
+ }
372
+ // set condition on post type
373
+ $params['post_type'] = $post_types_filter;
374
+ }
375
+
376
+ // query offset when doing incremental loading
377
+ $query_offset = (isset($_REQUEST['query_offset']) && (int)$_REQUEST['query_offset'] >= 0) ? (int)$_REQUEST['query_offset'] : 0;
378
+ $params['query_offset'] = $query_offset;
379
+
380
+ // fetch posts
381
+ $helper_articles = WYSIJA::get('articles', 'helper');
382
+
383
+ // set is_search_query (true) to get a count in addition to the results
384
+ $params['is_search_query'] = true;
385
+
386
+ $model_wp_posts = WYSIJA::get('wp_posts','model');
387
+ $data = $model_wp_posts->get_posts($params);
388
+
389
+ // extract data
390
+ $posts = $data['rows'];
391
+ // contains the total number of rows available
392
+ $count = $data['count'];
393
+
394
+ // return results
395
+ $result = array(
396
+ 'result' => true,
397
+ 'append' => ($query_offset > 0)
398
+ );
399
+
400
+ if(empty($posts) === false) {
401
+ foreach($posts as $key => $post) {
402
+ // interpret shortcodes
403
+ if($interpret_shortcode === true) {
404
+ $posts[$key]['post_content'] = apply_filters('the_content', $posts[$key]['post_content']);
405
+ }
406
+
407
+ // get thumbnail
408
+ $posts[$key]['post_image'] = $helper_articles->getImage($post);
409
+
410
+ // set post status
411
+ $post_status_label = '';
412
+ if(isset($post_statuses[$posts[$key]['post_status']])) {
413
+ $post_status_label = $post_statuses[$posts[$key]['post_status']];
414
+ }
415
+ $posts[$key]['post_status'] = $post_status_label;
416
+ }
417
+ $result['posts'] = $posts;
418
+ $result['total'] = (int)$count['total'];
419
+ }else {
420
+ $result['msg'] = __('There are no posts corresponding to that search.', WYSIJA);
421
+ $result['result'] = false;
422
+ }
423
+
424
+ return $result;
425
+ }
426
+
427
+ function insert_articles() {
428
+ // get raw params
429
+ $raw_params = $_REQUEST['data'];
430
+
431
+ // format params
432
+ $params = array();
433
+ foreach($raw_params as $value) {
434
+ $params[$value['name']] = $value['value'];
435
+ }
436
+
437
+ if($params['show_divider'] === 'yes') {
438
+ // get divider
439
+ $divider = $_REQUEST['divider'];
440
+ } else {
441
+ $divider = null;
442
+ }
443
+ $params['divider'] = $divider;
444
+
445
+ // get post ids
446
+ $post_ids = array();
447
+ if(isset($_REQUEST['post_ids']) && strlen(trim($_REQUEST['post_ids'])) > 0) {
448
+ $post_ids = explode(',', $_REQUEST['post_ids']);
449
+ }
450
+
451
+ if(empty($post_ids)) {
452
+ // return error
453
+ $res['msg'] = __('Please select an article.', WYSIJA);
454
+ $res['result'] = false;
455
+ return $res;
456
+ }
457
+
458
+ // specify custom fields to get from posts
459
+ $post_params = array('include' => $post_ids);
460
+
461
+ // include sort by parameter into post params
462
+ $post_params['sort_by'] = $params['sort_by'];
463
+
464
+ // get posts
465
+ $model_wp_posts = WYSIJA::get('wp_posts', 'model');
466
+ $posts = $model_wp_posts->get_posts($post_params);
467
+
468
+ // check if we need to interpret shortcodes
469
+ $model_config = WYSIJA::get('config', 'model');
470
+ $interpret_shortcode = (bool)$model_config->getValue('interp_shortcode');
471
+
472
+ // get some model and helpers
473
+ $helper_articles = WYSIJA::get('articles', 'helper');
474
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
475
+
476
+ $output = '';
477
+
478
+ // save parameters for next time
479
+ $model_config->save(array('insert_post_parameters' => $helper_wj_engine->encodeParameters($params)));
480
+
481
+ foreach($posts as $key => $post) {
482
+ if($interpret_shortcode === true) {
483
+ // interpret shortcodes
484
+ $posts[$key]['post_content'] = apply_filters('the_content', $post['post_content']);
485
+ }
486
+ // get thumbnail
487
+ $posts[$key]['post_image'] = $helper_articles->getImage($post);
488
+ }
489
+
490
+ $output .= base64_encode($helper_wj_engine->renderPostsToBlocks($posts, $params));
491
+
492
+ if(strlen($output) > 0) {
493
+ $res['result'] = true;
494
+ $res['posts'] = $output;
495
+ }else {
496
+ $res['msg'] = __('There are no posts corresponding to that search.',WYSIJA);
497
+ $res['result'] = false;
498
+ }
499
+
500
+ return $res;
501
+ }
502
+
503
+ function send_preview($spamtest=false){
504
+ $mailer=WYSIJA::get('mailer','helper');
505
+ $email_id = $_REQUEST['id'];
506
+ $resultarray=array();
507
+
508
+ // update data in DB
509
+ $model_email = WYSIJA::get('email', 'model');
510
+ $model_email->getFormat=OBJECT;
511
+ $email_object = $model_email->getOne(false,array('email_id' => $email_id));
512
+ $mailer->testemail=true;
513
+
514
+
515
+ if(isset($_REQUEST['data'])){
516
+ $dataTemp=$_REQUEST['data'];
517
+ $_REQUEST['data']=array();
518
+ foreach($dataTemp as $val) $_REQUEST['data'][$val['name']]=$val['value'];
519
+ unset($dataTemp);
520
+ foreach($_REQUEST['data'] as $k =>$v){
521
+ $newkey=str_replace(array('wysija[email][',']'),'',$k);
522
+ $configVal[$newkey]=$v;
523
+ }
524
+ if(isset($configVal['from_name'])){
525
+ $params=array(
526
+ 'from_name'=>$configVal['from_name'],
527
+ 'from_email'=>$configVal['from_email'],
528
+ 'replyto_name'=>$configVal['replyto_name'],
529
+ 'replyto_email'=>$configVal['replyto_email']);
530
+ if(isset($configVal['subject'])) $email_object->subject=$configVal['subject'];
531
+ }
532
+
533
+ }else{
534
+ $params=array(
535
+ 'from_name'=>$email_object->from_name,
536
+ 'from_email'=>$email_object->from_email,
537
+ 'replyto_name'=>$email_object->replyto_name,
538
+ 'replyto_email'=>$email_object->replyto_email
539
+ );
540
+ }
541
+ if(strpos($_REQUEST['receiver'], ',')) {
542
+ $receivers = explode(',',$_REQUEST['receiver']);
543
+ } else if(strpos($_REQUEST['receiver'], ';')) {
544
+ $receivers = explode(';',$_REQUEST['receiver']);
545
+ } else {
546
+ $receivers = array($_REQUEST['receiver']);
547
+ }
548
+
549
+ $user_model = WYSIJA::get('user', 'model');
550
+ foreach($receivers as $key => $receiver){
551
+ $receiver = trim($receiver);
552
+ $dummy_receiver = $user_model->get_object_by_email($receiver);
553
+ if(empty($dummy_receiver)){
554
+ $dummy_receiver = new stdClass();
555
+ $dummy_receiver->user_id = 0;
556
+ $dummy_receiver->email = $receiver;
557
+ $dummy_receiver->status = 1;
558
+ $dummy_receiver->lastname = $dummy_receiver->firstname = '';
559
+ }
560
+
561
+ if($spamtest){
562
+ $langextra = '';
563
+ $dummy_receiver->firstname ='Mail Tester';
564
+
565
+ $wp_lang = get_locale();
566
+ if(!empty($wp_lang)) $langextra ='&lang='.$wp_lang;
567
+ $resultarray['urlredirect']='http://www.mail-tester.com/check.php?id='.urlencode($dummy_receiver->email).$langextra;
568
+ }
569
+ $receivers[$key] = $dummy_receiver;
570
+
571
+ }
572
+
573
+ $email_clone=array();
574
+ foreach($email_object as $kk=>$vv) $email_clone[$kk]=$vv;
575
+
576
+
577
+ $wj_engine = WYSIJA::get('wj_engine', 'helper');
578
+ // set data & styles
579
+ if(isset($email_clone['wj_data'])) { $wj_engine->setData($email_clone['wj_data'], true); } else { $wj_engine->setData(); }
580
+ if(isset($email_clone['wj_styles'])) { $wj_engine->setStyles($email_clone['wj_styles'], true); } else { $wj_engine->setStyles(); }
581
+
582
+ // generate email html body
583
+ $body = $wj_engine->renderEmail($email_clone);
584
+
585
+ // get back email data as it will be updated during the rendering (articles ids + articles count)
586
+ $email_child = $wj_engine->getEmailData();
587
+
588
+ // [total] [number] and [post_title] are only valid for post notifications newsletter
589
+ if((int)$email_child['type'] === 2 && isset($email_child['params']['autonl']['event']) &&
590
+ $email_child['params']['autonl']['event'] === 'new-articles' && isset($email_child['params']['autonl']['articles'])){
591
+
592
+ $item_count = 0;
593
+ $total_count = 1;
594
+ $first_subject = '';
595
+
596
+ if(isset($email_child['params']['autonl']['articles']['count'])) $item_count = (int)$email_child['params']['autonl']['articles']['count'];
597
+ if(isset($email_child['params']['autonl']['articles']['first_subject'])) $first_subject = $email_child['params']['autonl']['articles']['first_subject'];
598
+ if(isset($email_child['params']['autonl']['total_child'])) $total_count = (int)$email_child['params']['autonl']['total_child'] + 1;
599
+
600
+ $email_object->subject = str_replace(
601
+ array('[total]','[number]','[post_title]'),
602
+ array($item_count, $total_count, $first_subject),
603
+ $email_child['subject']
604
+ );
605
+ }
606
+ $successmsg = __('Your email preview has been sent to %1$s', WYSIJA);
607
+
608
+ // correction added for post notifications with the tag [newsletter:post_title] failing to send
609
+ if(isset($email_object->params['autonl']) && isset($email_child['params']['autonl'])){
610
+ $email_object->params['autonl']=$email_child['params']['autonl'];
611
+ }
612
+
613
+ if(isset($email_object->params)) {
614
+ $params['params']=$email_object->params;
615
+
616
+ if(isset($configVal['params[googletrackingcode'])){
617
+ $paramsemail=array();
618
+ if(!is_array($email_object->params)) $paramsemail=unserialize(base64_decode($email_object->params));
619
+
620
+ if(trim($configVal['params[googletrackingcode'])) {
621
+ $paramsemail['googletrackingcode']=$configVal['params[googletrackingcode'];
622
+ }
623
+ else {
624
+ unset($paramsemail['googletrackingcode']);
625
+ }
626
+ $params['params'] = base64_encode(serialize($paramsemail));
627
+ }
628
+ }
629
+
630
+ $params['email_id'] = $email_object->email_id;
631
+ $receiversList = array();
632
+ $res = false;
633
+ foreach($receivers as $receiver){
634
+ if($mailer->sendSimple($receiver, stripslashes($email_object->subject),$email_object->body,$params)) {
635
+ $res = true;
636
+ $receiversList[] = $receiver->email;
637
+ }
638
+ WYSIJA::log('preview_sent', $mailer, 'manual');
639
+ }
640
+
641
+ if($res === true) {
642
+ $this->notice(sprintf($successmsg, implode(', ', $receiversList)));
643
+ }
644
+
645
+ $resultarray['result'] = $res;
646
+
647
+ return $resultarray;
648
+ }
649
+
650
+ /**
651
+ * send spam test function step 2 of the newsletter edition process
652
+ */
653
+ function send_spamtest(){
654
+ return apply_filters('wysija_send_spam_test','',$this);
655
+ }
656
+
657
+ function set_divider()
658
+ {
659
+ $src = isset($_POST['wysijaData']['src']) ? $_POST['wysijaData']['src'] : NULL;
660
+ $width = isset($_POST['wysijaData']['width']) ? (int)$_POST['wysijaData']['width'] : NULL;
661
+ $height = isset($_POST['wysijaData']['height']) ? (int)$_POST['wysijaData']['height'] : NULL;
662
+
663
+ if($src === NULL OR $width === NULL OR $height === NULL) {
664
+ // there is a least one missing parameter, fallback to default divider
665
+ $dividersHelper = WYSIJA::get('dividers', 'helper');
666
+ $divider = $dividersHelper->getDefault();
667
+ } else {
668
+ // use provided params
669
+ $divider = array(
670
+ 'src' => $src,
671
+ 'width' => $width,
672
+ 'height' => $height
673
+ );
674
+ }
675
+
676
+ // update campaign parameters
677
+ $email_id = (int)$_REQUEST['id'];
678
+ $campaignsHelper = WYSIJA::get('campaigns', 'helper');
679
+ $campaignsHelper->saveParameters($email_id, 'divider', $divider);
680
+
681
+ // set params
682
+ $block = array_merge(array('no-block' => true, 'type' => 'divider'), $divider);
683
+
684
+ $helper_wj_engine=WYSIJA::get('wj_engine','helper');
685
+ return base64_encode($helper_wj_engine->renderEditorBlock($block));
686
+ }
687
+
688
+ function get_social_bookmarks() {
689
+ $size = isset($_POST['wysijaData']['size']) ? $_POST['wysijaData']['size'] : NULL;
690
+ $theme = isset($_POST['wysijaData']['theme']) ? $_POST['wysijaData']['theme'] : NULL;
691
+
692
+ $bookmarksHelper = WYSIJA::get('bookmarks', 'helper');
693
+ $bookmarks = $bookmarksHelper->getAll($size, $theme);
694
+ return json_encode(array('icons' => $bookmarks));
695
+ }
696
+
697
+ function generate_social_bookmarks() {
698
+
699
+ $size = 'medium';
700
+ $iconset = '01';
701
+
702
+ if(isset($_POST['wysijaData']) && !empty($_POST['wysijaData'])) {
703
+ $data = $_POST['wysijaData'];
704
+ $items = array();
705
+
706
+ foreach($data as $key => $values) {
707
+ if($values['name'] === 'bookmarks-size') {
708
+ // get size
709
+ $size = $values['value'];
710
+ } else if($values['name'] === 'bookmarks-theme') {
711
+ // get theme name
712
+ $theme = $values['value'];
713
+ } else if($values['name'] === 'bookmarks-iconset') {
714
+ // get iconset
715
+ $iconset = $values['value'];
716
+ if(strlen(trim($iconset)) === 0) {
717
+ $this->error('No iconset specified', false);
718
+ return false;
719
+ }
720
+ } else {
721
+ $keys = explode('-', $values['name']);
722
+ $network = $keys[1];
723
+ $property = $keys[2];
724
+ if(array_key_exists($network, $items)) {
725
+ $items[$network][$property] = $values['value'];
726
+ } else {
727
+ $items[$network] = array($property => $values['value']);
728
+ }
729
+ }
730
+ }
731
+ }
732
+
733
+ $urls = array();
734
+ // check data and remove network with an empty url
735
+ foreach($items as $network => $item) {
736
+ if(strlen(trim($item['url'])) === 0) {
737
+ // empty url
738
+ unset($items[$network]);
739
+ } else {
740
+ // url specified
741
+ $urls[$network] = $item['url'];
742
+ }
743
+ }
744
+
745
+ // check if there's at least one url left
746
+ if(empty($urls)) {
747
+ $this->error('No url specified', false);
748
+ return false;
749
+ }
750
+
751
+ // save url in config
752
+ $config=WYSIJA::get('config','model');
753
+ $config->save(array('social_bookmarks' => $urls));
754
+
755
+ // get iconset icons
756
+ $bookmarksHelper = WYSIJA::get('bookmarks', 'helper');
757
+
758
+ // if the iconset is 00, then it's the theme's bookmarks
759
+ if($iconset === '00') {
760
+ $icons = $bookmarksHelper->getAllByTheme($theme);
761
+ } else {
762
+ // otherwise it's a basic iconset
763
+ $icons = $bookmarksHelper->getAllByIconset($size, $iconset);
764
+ }
765
+
766
+
767
+ // format data
768
+ $block = array(
769
+ 'position' => 1,
770
+ 'type' => 'gallery',
771
+ 'items' => array(),
772
+ 'alignment' => 'center'
773
+ );
774
+
775
+ $width = 0;
776
+ foreach($items as $key => $item) {
777
+ $block['items'][] = array_merge($item, $icons[$key], array('alt' => ucfirst($key)));
778
+ $width += (int)$icons[$key]['width'];
779
+ }
780
+ // add margin between icons
781
+ $width += (count($block['items']) - 1) * 10;
782
+ // set optimal width
783
+ $block['width'] = max(0, min($width, 564));
784
+
785
+ $helper_wj_engine=WYSIJA::get('wj_engine','helper');
786
+ return base64_encode($helper_wj_engine->renderEditorBlock($block));
787
+ }
788
+
789
+ function install_theme() {
790
+ if( isset($_REQUEST['theme_id'])){
791
+ global $wp_version;
792
+ //check if theme is premium if you have the premium licence
793
+ if(isset($_REQUEST['premium']) && $_REQUEST['premium']){
794
+ $getpremiumtheme=apply_filters('wysija_install_theme_premium', false);
795
+
796
+ if(!$getpremiumtheme){
797
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
798
+ $themes = $helper_wj_engine->renderThemes();
799
+ return array('result'=>false, 'themes' => $themes);
800
+ }
801
+ }
802
+
803
+ $helperToolbox = WYSIJA::get('toolbox','helper');
804
+ $domain_name = $helperToolbox->_make_domain_name(admin_url('admin.php'));
805
+
806
+ $request = 'http://api.mailpoet.com/download/zip/'.$_REQUEST['theme_id'].'?domain='.$domain_name;
807
+
808
+ $args = array(
809
+ 'timeout' => 30,
810
+ 'body' => array( ),
811
+ 'user-agent' => 'WordPress/' . $wp_version . '; ' . get_bloginfo( 'url' )
812
+ );
813
+ $raw_response = wp_remote_post( $request, $args );
814
+
815
+ if ( is_wp_error( $raw_response ) || 200 != wp_remote_retrieve_response_code( $raw_response ) ){
816
+ if(method_exists($raw_response, 'get_error_messages')){
817
+ $this->error($raw_response->get_error_messages());
818
+ }
819
+ $ZipfileResult = false;
820
+ }else{
821
+ $ZipfileResult = maybe_unserialize( wp_remote_retrieve_body( $raw_response ) );
822
+ }
823
+
824
+ if($ZipfileResult === false){
825
+ $result = false;
826
+ $this->error(__('We were unable to contact the API, the site may be down. Please try again later.',WYSIJA),true);
827
+ }else{
828
+ $themesHelp=WYSIJA::get('themes','helper');
829
+ $result = $themesHelp->installTheme($ZipfileResult);
830
+
831
+ // refresh themes list
832
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
833
+ $themes = $helper_wj_engine->renderThemes();
834
+ }
835
+ }else{
836
+ $result = false;
837
+ $themes = '';
838
+ $this->notice('missing info');
839
+ }
840
+
841
+ return array('result' => $result, 'themes' => $themes);
842
+ }
843
+
844
+ function refresh_themes() {
845
+ // refresh themes list
846
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
847
+ return array('result'=>true, 'themes' => $helper_wj_engine->renderThemes());
848
+ }
849
+
850
+ function generate_auto_post() {
851
+ // get params and generate html
852
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
853
+ $helper_articles = WYSIJA::get('articles', 'helper');
854
+
855
+ // get parameters
856
+ $block_params = array();
857
+ if(isset($_POST['wysijaData'])) {
858
+ // store category ids (TBR)
859
+ $category_ids = array();
860
+
861
+ foreach($_POST['wysijaData'] as $pairs) {
862
+ // special cases
863
+ switch($pairs['name']) {
864
+ case 'author_label':
865
+ case 'category_label':
866
+ case 'readmore':
867
+ case 'nopost_message':
868
+ $block_params[] = array('key' => $pairs['name'], 'value' => base64_encode(stripslashes($pairs['value'])));
869
+ break;
870
+ case 'category_ids':
871
+ $category_ids = array_filter( array_map( 'absint', explode( ',', $pairs['value'] ) ) );
872
+ break;
873
+ default:
874
+ $block_params[] = array('key' => $pairs['name'], 'value' => $pairs['value']);
875
+ }
876
+ }
877
+
878
+ // make sure we have only unique ids in categories
879
+ $block_params[] = array('key' => 'category_ids', 'value' => join(',', array_unique($category_ids)));
880
+ }
881
+
882
+ if(empty($block_params)) {
883
+ // an error occurred, do something!
884
+ return false;
885
+ } else {
886
+ $data = array(
887
+ 'type' => 'auto-post',
888
+ 'params' => $block_params
889
+ );
890
+ return base64_encode($helper_wj_engine->renderEditorBlock($data));
891
+ }
892
+ }
893
+
894
+ function load_auto_post() {
895
+ $params = array();
896
+
897
+ if(isset($_POST['wysijaData'])) {
898
+
899
+ $pairs = explode('&', $_POST['wysijaData']);
900
+
901
+ foreach($pairs as $pair) {
902
+ list($key, $value) = explode('=', $pair);
903
+ switch($key) {
904
+ case 'autopost_count':
905
+ $params[$key] = (int)$value;
906
+ break;
907
+ case 'readmore':
908
+ case 'author_label':
909
+ case 'category_label':
910
+ case 'nopost_message':
911
+ $params[$key] = base64_decode($value);
912
+ break;
913
+ case 'exclude':
914
+ $params[$key] = explode(',', $value);
915
+ break;
916
+ default:
917
+ $params[$key] = $value;
918
+ }
919
+ }
920
+ }
921
+
922
+ if(empty($params)) {
923
+ // an error occurred, do something!
924
+ return false;
925
+ } else {
926
+
927
+ // get email params
928
+ $email_id = (int)$_REQUEST['id'];
929
+ $model_email = WYSIJA::get('email', 'model');
930
+ $email = $model_email->getOne(array('params','sent_at','campaign_id'), array('email_id' => $email_id));
931
+
932
+ $helper_articles = WYSIJA::get('articles', 'helper');
933
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
934
+
935
+ // see if posts have already been sent
936
+ if(!empty($email['params']['autonl']['articles']['ids'])) {
937
+ if(!isset($params['exclude'])) { $params['exclude'] = array(); }
938
+
939
+ $params['exclude'] = array_unique(array_merge($email['params']['autonl']['articles']['ids'], $params['exclude']));
940
+ }
941
+
942
+ //we set the post_date to filter articles only older than that one
943
+ if(isset($email['params']['autonl']['firstSend'])){
944
+ $params['post_date'] = $email['params']['autonl']['firstSend'];
945
+ }
946
+
947
+ // if immediate let it know to the get post
948
+ if(isset($email['params']['autonl']['articles']['immediatepostid'])){
949
+ $params['include'] = $email['params']['autonl']['articles']['immediatepostid'];
950
+ $params['post_limit'] = 1;
951
+ }else{
952
+ //we set the post_date to filter articles only older than the last time we sent articles
953
+ if(isset($email['params']['autonl']['lastSend'])){
954
+ $params['post_date'] = $email['params']['autonl']['lastSend'];
955
+ }else{
956
+ //get the latest child newsletter sent_at value
957
+ $mEmail=WYSIJA::get('email','model');
958
+ $mEmail->reset();
959
+ $mEmail->orderBy('email_id','DESC');
960
+ $lastEmailSent=$mEmail->getOne(false,array('campaign_id'=>$email['campaign_id'],'type'=>'1'));
961
+
962
+ if(!empty($lastEmailSent)) $params['post_date'] = $lastEmailSent['sent_at'];
963
+ }
964
+ }
965
+
966
+ // get posts
967
+ $model_wp_posts = WYSIJA::get('wp_posts','model');
968
+ $posts = $model_wp_posts->get_posts($params);
969
+
970
+ if(empty($posts)) {
971
+ // nothing to display
972
+ $posts = array();
973
+ } else {
974
+ // used to keep track of post ids present in the auto post
975
+ $post_ids = array();
976
+
977
+ // cleanup post and get image
978
+ foreach($posts as $key => $post) {
979
+ if($params['image_alignment'] !== 'none') {
980
+ // attempt to get post image
981
+ $posts[$key]['post_image'] = $helper_articles->getImage($post);
982
+ }
983
+
984
+ // store article id
985
+ $post_ids[] = $post['ID'];
986
+ }
987
+ // store article ids
988
+ $params['post_ids'] = join(',', $post_ids);
989
+ }
990
+
991
+ // get divider if necessary (for immediate post notification, the "show_divider" parameter is not available)
992
+ if(isset($params['show_divider']) && $params['show_divider'] === 'yes') {
993
+ if(isset($email['params']['divider'])) {
994
+ $params['divider'] = $email['params']['divider'];
995
+ } else {
996
+ $helper_dividers = WYSIJA::get('dividers', 'helper');
997
+ $params['divider'] = $helper_dividers->getDefault();
998
+ }
999
+ }
1000
+
1001
+ return base64_encode($helper_wj_engine->renderEditorAutoPost($posts, $params));
1002
+ }
1003
+ }
1004
  }
controllers/ajax/config.php CHANGED
@@ -173,18 +173,154 @@ class WYSIJA_control_back_config extends WYSIJA_control{
173
 
174
  // WYSIJA Form Editor
175
  function wysija_form_generate_template() {
176
- $field = array();
177
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  if(isset($_POST['wysijaData'])) {
179
  // decode the data string
180
  $decoded_data = base64_decode($_POST['wysijaData']);
181
 
182
  // avoid using stripslashes as it's not reliable depending on the magic quotes settings
183
  $json_data = str_replace('\"', '"', $decoded_data);
184
- $field = json_decode($json_data, true);
 
 
 
185
 
186
- $helper_form_engine = WYSIJA::get('form_engine', 'helper');
187
- return base64_encode($helper_form_engine->render_editor_template($field));
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
188
  }
189
  }
190
 
@@ -297,7 +433,7 @@ class WYSIJA_control_back_config extends WYSIJA_control{
297
  '<a href="'.admin_url('widgets.php').'" target="_blank">',
298
  '</a>'
299
  ),
300
- __('Saved! Add this form to [link_widget]a widget[/link_widget]', WYSIJA)
301
  );
302
  }
303
 
@@ -312,10 +448,10 @@ class WYSIJA_control_back_config extends WYSIJA_control{
312
  // return response depending on db save result
313
  if(!$result) {
314
  // throw error
315
- $this->error(__('Your form could not be saved', WYSIJA));
316
  } else {
317
  // save successful
318
- $this->notice(__('Your form has been saved', WYSIJA));
319
  }
320
  }
321
 
173
 
174
  // WYSIJA Form Editor
175
  function wysija_form_generate_template() {
176
+ $data = $this->_wysija_form_get_data();
177
 
178
+ $helper_form_engine = WYSIJA::get('form_engine', 'helper');
179
+ return base64_encode($helper_form_engine->render_editor_template($data));
180
+ }
181
+
182
+ function wysija_form_manage_field() {
183
+ $response = array('result' => true, 'error' => null);
184
+
185
+ // get data
186
+ $data = $this->_wysija_form_get_data();
187
+ $form_id = (int)$_REQUEST['form_id'];
188
+
189
+ // check for required fields
190
+ if(!isset($data['type']) || isset($data['type']) && strlen(trim($data['type'])) === 0) {
191
+ $response['error'] = __('You need to select a type for this field', WYSIJA);
192
+ $response['result'] = false;
193
+ }
194
+ if(!isset($data['name']) || isset($data['name']) && strlen(trim($data['name'])) === 0) {
195
+ $response['error'] = __('You need to specify a name for this field', WYSIJA);
196
+ $response['result'] = false;
197
+ }
198
+
199
+ // only proceed if there is no error
200
+ if($response['error'] === null) {
201
+ $is_required = (isset($data['params']['required']) ? WJ_Utils::to_bool($data['params']['required']) : false);
202
+
203
+ if(isset($data['field_id']) && (int)$data['field_id'] > 0) {
204
+ // it's an update
205
+ $custom_field = WJ_Field::get($data['field_id']);
206
+
207
+ if($custom_field !== NULL) {
208
+ $data['params'] = array_merge($custom_field->settings, $data['params']);
209
+ // update fields
210
+ $custom_field->name = $data['name'];
211
+ $custom_field->type = $data['type'];
212
+ $custom_field->required = $is_required;
213
+ $custom_field->settings = $data['params'];
214
+ $custom_field->save();
215
+ } else {
216
+ // throw error if field does not exist
217
+ $response['error'] = __('This field does not exist', WYSIJA);
218
+ $response['result'] = false;
219
+ }
220
+ } else {
221
+ // create new custom field
222
+ $custom_field = new WJ_Field();
223
+ $custom_field->set(array(
224
+ 'name' => $data['name'],
225
+ 'type' => $data['type'],
226
+ 'required' => $is_required,
227
+ 'settings' => $data['params']
228
+ ));
229
+ $custom_field->save();
230
+ }
231
+
232
+ if($response['error'] === null) {
233
+ $helper_form_engine = WYSIJA::get('form_engine', 'helper');
234
+
235
+ // need to update each block instance of this custom field
236
+ $block = $helper_form_engine->refresh_custom_field($form_id, array(
237
+ 'name' => $data['name'],
238
+ 'field' => $custom_field->user_column_name(),
239
+ 'type' => $data['type'],
240
+ 'required' => $is_required,
241
+ 'settings' => $data['params']
242
+ ));
243
+
244
+ // render editor toolbar & templates
245
+ $response['data'] = array(
246
+ 'toolbar' => base64_encode($helper_form_engine->render_editor_toolbar()),
247
+ 'templates' => base64_encode($helper_form_engine->render_editor_templates())
248
+ );
249
+
250
+ if($block !== null) {
251
+ // refresh block using this custom field in the current form
252
+ $block_template = $helper_form_engine->render_editor_template($block);
253
+
254
+ if($block_template !== null) {
255
+ $response['data']['block'] = base64_encode($block_template);
256
+ }
257
+ }
258
+ }
259
+ }
260
+
261
+ return $response;
262
+ }
263
+
264
+ // get wysija form data from post (auto decoding)
265
+ private function _wysija_form_get_data() {
266
  if(isset($_POST['wysijaData'])) {
267
  // decode the data string
268
  $decoded_data = base64_decode($_POST['wysijaData']);
269
 
270
  // avoid using stripslashes as it's not reliable depending on the magic quotes settings
271
  $json_data = str_replace('\"', '"', $decoded_data);
272
+ return json_decode($json_data, true);
273
+ }
274
+ return array();
275
+ }
276
 
277
+ // remove a custom field
278
+ function form_field_delete() {
279
+ $data = $this->_wysija_form_get_data();
280
+
281
+ // check for field_id parameter
282
+ if(isset($data['field_id']) && (int)$data['field_id'] > 0) {
283
+ // get custom field by id
284
+ $custom_field = WJ_Field::get($data['field_id']);
285
+
286
+ // if the custom field exists
287
+ if($custom_field !== null) {
288
+ // we need to remove the field in any form
289
+ // get all forms
290
+ $model_forms = WYSIJA::get('forms', 'model');
291
+ $forms = $model_forms->getRows();
292
+
293
+ // get custom field name
294
+ $field_name = $custom_field->user_column_name();
295
+ if(is_array($forms) && count($forms) > 0) {
296
+ // loop through each form
297
+ foreach ($forms as $i => $form) {
298
+ $requires_update = false;
299
+
300
+ // decode form data
301
+ $data = unserialize(base64_decode($form['data']));
302
+
303
+ // loop through each block
304
+ foreach($data['body'] as $j => $block) {
305
+ // in case we find a text block
306
+ if($block['field'] === $field_name) {
307
+ unset($data['body'][$j]);
308
+ // flag form to be updated
309
+ $requires_update = true;
310
+ }
311
+ }
312
+
313
+ // if the form requires update, let's do it
314
+ if($requires_update === true) {
315
+ $model_forms->reset();
316
+ $model_forms->update(array('data' => base64_encode(serialize($data))), array('form_id' => (int)$form['form_id']));
317
+ }
318
+ }
319
+ }
320
+
321
+ // delete custom field
322
+ $custom_field->delete();
323
+ }
324
  }
325
  }
326
 
433
  '<a href="'.admin_url('widgets.php').'" target="_blank">',
434
  '</a>'
435
  ),
436
+ __('Saved! Add this form to [link_widget]a widget[/link_widget].', WYSIJA)
437
  );
438
  }
439
 
448
  // return response depending on db save result
449
  if(!$result) {
450
  // throw error
451
+ $this->error(__('Your form could not be saved.', WYSIJA));
452
  } else {
453
  // save successful
454
+ $this->notice(__('Your form has been saved.', WYSIJA));
455
  }
456
  }
457
 
controllers/ajax/statistics.php ADDED
@@ -0,0 +1,106 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
+
4
+ require_once(WYSIJA_CORE.'module'.DS.'statistics.php'); // @todo
5
+
6
+ class WYSIJA_control_back_statistics extends WYSIJA_control
7
+ {
8
+
9
+ /**
10
+ * Main model of this controller
11
+ * @var string
12
+ */
13
+ public $model = 'statistics';
14
+
15
+ /**
16
+ * Main view of this controller
17
+ * @var string
18
+ */
19
+ public $view = 'statistics';
20
+
21
+ /**
22
+ * Date format of filter
23
+ * @var string
24
+ */
25
+ protected $date_format = 'Y/m/d';
26
+
27
+ /**
28
+ * Render a hook of a specific module
29
+ * @return string
30
+ */
31
+ public function get_block()
32
+ {
33
+ if (empty($_REQUEST['block']))
34
+ return '';
35
+ $module = $_REQUEST['block'];
36
+ $hook_name = 'hook_stats';
37
+ return apply_filters('custom_module_hook', '', $module, $hook_name, $this->get_post_params());
38
+ }
39
+
40
+ protected function get_post_params()
41
+ {
42
+ $params = array( );
43
+ $order_by = !empty($_REQUEST['filter']['orderBy']) ? $_REQUEST['filter']['orderBy'] : null;
44
+ switch (strtolower($order_by))
45
+ {
46
+ case 'sent':
47
+ $order_by = WYSIJA_module_statistics::ORDER_BY_SENT;
48
+ break;
49
+ case 'open':
50
+ $order_by = WYSIJA_module_statistics::ORDER_BY_OPEN;
51
+ break;
52
+ case 'click':
53
+ $order_by = WYSIJA_module_statistics::ORDER_BY_CLICK;
54
+ break;
55
+ case 'unsubscribe':
56
+ $order_by = WYSIJA_module_statistics::ORDER_BY_UNSUBSCRIBE;
57
+ break;
58
+ default:
59
+ $order_by = null;
60
+ break;
61
+ }
62
+ $order_direction = !empty($_REQUEST['filter']['orderDirection']) ? $_REQUEST['filter']['orderDirection'] : null;
63
+ switch (strtolower($order_direction))
64
+ {
65
+ case 'asc':
66
+ $order_direction = WYSIJA_module_statistics::ORDER_DIRECTION_ASC;
67
+ break;
68
+ case 'desc':
69
+ default:
70
+ $order_direction = WYSIJA_module_statistics::ORDER_DIRECTION_DESC;
71
+ break;
72
+ }
73
+ $params['top'] = !empty($_REQUEST['filter']['itemPerPage']) ? (int)$_REQUEST['filter']['itemPerPage'] : WYSIJA_module_statistics::DEFAULT_TOP_RECORDS;
74
+ $params['from'] = !empty($_REQUEST['filter']['from']) ? $_REQUEST['filter']['from'] : null;
75
+ $params['to'] = !empty($_REQUEST['filter']['to']) ? $_REQUEST['filter']['to'] : null;
76
+ $params['order_by'] = $order_by;
77
+ $params['order_direction'] = $order_direction;
78
+
79
+ // this doesn't work when php is less than 5.3, this is the case on my host (ben) which is very popular in France, SPain and UK
80
+ // we cannot use functions from php 5.3
81
+ if (function_exists('date_diff'))
82
+ {
83
+ $this->data['date_interval'] = date_diff(date_create($params['from']), date_create($params['to']));
84
+ }
85
+ else
86
+ {
87
+ $duration = strtotime($params['to']) - strtotime($params['from']);
88
+ $helper_toolbox = WYSIJA::get('toolbox', 'helper');
89
+ $this->data['date_interval'] = (object)$helper_toolbox->convert_seconds_to_array($duration, false);
90
+ }
91
+ $params['group_by'] = ( $this->data['date_interval']->days == 0 || $this->data['date_interval']->days > WYSIJA_module_statistics::SWITCHING_DATE_TO_MONTH_THRESHOLD) ?
92
+ WYSIJA_module_statistics::GROUP_BY_MONTH :
93
+ WYSIJA_module_statistics::GROUP_BY_DATE; // $date_interval->days == 0, means, no begin date, no end date
94
+
95
+ // Hack!
96
+ $_REQUEST['limit_pp'] = $params['top'];// Pagination, mark current selected value
97
+
98
+ // Modify TO date to make sure we always count 23:59:59 of that day
99
+ $to = new DateTime($params['to']);
100
+ $to->modify('+1 day');
101
+ $params['to'] = $to->format($this->date_format);
102
+
103
+ return $params;
104
+ }
105
+
106
+ }
controllers/ajax/subscribers.php CHANGED
@@ -36,11 +36,19 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_front{
36
 
37
  $helperUser=WYSIJA::get('user','helper');
38
  if(!$helperUser->checkData($data))return false;
39
- $helperUser->addSubscriber($data);
 
 
 
 
 
 
 
40
 
41
  return true;
42
  }
43
 
 
44
  function convertUserData($datarequested){
45
  $data=array();
46
 
@@ -60,22 +68,35 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_front{
60
  }
61
  $data['user_list']['list_ids']=$listids;
62
 
 
 
 
63
  //get the user info and the rest of the data posted
64
  foreach($datarequested as $key => $val){
65
- if(strpos($key, 'wysija[user]')!== false){
66
  $keymodified=str_replace(array('wysija[','][',']'),array('','#',''),$key);
67
  $keystabcol=explode('#',$keymodified);
68
  switch(count($keystabcol)){
69
  case 2:
70
  $data[$keystabcol[0]][$keystabcol[1]]=$val;
71
- break;
72
  case 3:
73
  $data[$keystabcol[0]][$keystabcol[1]][$keystabcol[2]]=$val;
74
- break;
75
- default:
76
  }
 
 
 
77
 
78
- }else{
 
 
 
 
 
 
 
 
79
  if(!isset($data[$key])) $data[$key]=$val;
80
  }
81
  }
36
 
37
  $helperUser=WYSIJA::get('user','helper');
38
  if(!$helperUser->checkData($data))return false;
39
+ $user_id = $helperUser->addSubscriber($data);
40
+
41
+ if((int)$user_id > 0) {
42
+ // Handle custom fields
43
+ if(isset($data['user_field'])) {
44
+ WJ_FieldHandler::handle_all($data['user_field'], $user_id);
45
+ }
46
+ }
47
 
48
  return true;
49
  }
50
 
51
+ // REFACTOR: Insanely complicated and inefficient
52
  function convertUserData($datarequested){
53
  $data=array();
54
 
68
  }
69
  $data['user_list']['list_ids']=$listids;
70
 
71
+ // define array for custom user fields
72
+ $data['user_field'] = array();
73
+
74
  //get the user info and the rest of the data posted
75
  foreach($datarequested as $key => $val){
76
+ if(strpos($key, 'wysija[user]')!== false) {
77
  $keymodified=str_replace(array('wysija[','][',']'),array('','#',''),$key);
78
  $keystabcol=explode('#',$keymodified);
79
  switch(count($keystabcol)){
80
  case 2:
81
  $data[$keystabcol[0]][$keystabcol[1]]=$val;
82
+ break;
83
  case 3:
84
  $data[$keystabcol[0]][$keystabcol[1]][$keystabcol[2]]=$val;
85
+ break;
 
86
  }
87
+ } else if(strpos($key, 'wysija[field]')!== false){
88
+ $keymodified=str_replace(array('wysija[','][',']'),array('','#',''),$key);
89
+ $keystabcol=explode('#',$keymodified);
90
 
91
+ switch(count($keystabcol)){
92
+ case 2:
93
+ $data['user_field'][$keystabcol[1]] = $val;
94
+ break;
95
+ case 3:
96
+ $data['user_field'][$keystabcol[1]][$keystabcol[2]] = $val;
97
+ break;
98
+ }
99
+ } else {
100
  if(!isset($data[$key])) $data[$key]=$val;
101
  }
102
  }
controllers/ajax/tmce.php CHANGED
@@ -1,140 +1,139 @@
1
- <?php
2
- defined('WYSIJA') or die('Restricted access');
3
- class WYSIJA_control_back_tmce extends WYSIJA_control{
4
-
5
- function WYSIJA_control_back_tmce(){
6
- if(!WYSIJA::current_user_can('wysija_subscriwidget')) die('Action is forbidden.');
7
- parent::WYSIJA_control();
8
- $this->viewObj=WYSIJA::get('tmce','view');
9
- }
10
-
11
- function subscribersAdd(){
12
- $this->viewObj->title=__('Insert Total of Subscribers',WYSIJA);
13
- $data = array();
14
- $data['lists'] = WYSIJA::get('list','model')->getLists();
15
- foreach ($data['lists'] as $k => $list){
16
- if (empty($list['is_enabled']) OR empty($list['is_public'])) unset($data['lists'][$k]);
17
- }
18
- $data['confirm_dbleoptin'] = WYSIJA::get('config','model')->getValue('confirm_dbleoptin');
19
-
20
- $this->viewObj->subscribersAdd($data);
21
- exit;
22
- }
23
-
24
- function subscribersEdit(){
25
-
26
- }
27
-
28
- function registerAdd(){
29
- $this->viewObj->title=__('Insert Subscription Form',WYSIJA);
30
-
31
- $this->viewObj->registerAdd($this->getData());
32
- exit;
33
- }
34
-
35
- function registerEdit(){
36
- $this->viewObj->title=__('Insert Subscription Form',WYSIJA);
37
-
38
- $this->viewObj->registerAdd($this->getData(),true);
39
- exit;
40
- }
41
-
42
-
43
- function getData(){
44
- $data_widget=array();
45
-
46
- // if this parameter is passed that means we have an old widget let's import it and select
47
- if(isset($_REQUEST['widget-data64'])){
48
- $data_widget=unserialize(base64_decode($_REQUEST['widget-data64']));
49
- $post=get_post($_REQUEST['post_id']);
50
-
51
- // we need a title to identify the form
52
- $data_widget['title'] = 'Form on '.$post->post_type.': '.$post->post_title;
53
-
54
- $model_forms = WYSIJA::get('forms', 'model');
55
- $model_forms->reset();
56
- $form = $model_forms->getOne(false,array('name' => $data_widget['title']));
57
-
58
- // this form doesn't exist yet in the new format so let's try to import it
59
- if(empty($form)){
60
- $helper_update=WYSIJA::get('update','helper');
61
-
62
- $form_id = $helper_update->convert_widget_to_form($data_widget);
63
- if($form_id!==false) {
64
- $data_widget['default_form'] = $form_id;
65
- }
66
- }
67
- }
68
-
69
- if(isset($_POST['widget-wysija'])){
70
- $data_widget=array('widget_id'=>$_POST['widget_id'],'preview'=>true);
71
- $custom_fields=array();
72
-
73
- foreach($_POST['widget-wysija'] as $arra){
74
- foreach($arra as $k => $v) {
75
- switch($k){
76
- case 'lists':
77
- if(isset($data_widget[$k])) $data_widget[$k][]=$v[0];
78
- else $data_widget[$k]=array($v[0]);
79
- break;
80
- case 'lists_name':
81
- foreach($v as $kv=>$vv){
82
- if(isset($data_widget[$k])) $data_widget[$k][$kv]=$vv;
83
- else $data_widget[$k]=array($kv=>$vv);
84
- }
85
-
86
- break;
87
- case 'customfields':
88
-
89
- $found=false;
90
- foreach($custom_fields as $keycol => $params){
91
- if(isset($v[$keycol])){
92
- $custom_fields[$keycol]= array_merge($custom_fields[$keycol],$v[$keycol]);
93
- $found=true;
94
- }
95
- }
96
-
97
- if(!$found) $custom_fields=array_merge($custom_fields,$v);
98
- break;
99
-
100
- default:
101
- $data_widget[$k]=stripslashes($v);
102
- }
103
-
104
- }
105
- }
106
-
107
-
108
- $count=count($custom_fields);
109
- if($count>1){
110
- foreach($custom_fields as $keycol=>$paraval){
111
- if($keycol!='email' && !isset($paraval['column_name'])) unset($custom_fields[$keycol]);
112
- }
113
- }
114
-
115
- $count=count($custom_fields);
116
- if($count>0){
117
- if(!isset($custom_fields['email'])){
118
- $custom_fields['email']['column_name']='email';
119
- $custom_fields['email']['label']=__('Email',WYSIJA);
120
- }
121
- }
122
-
123
- $count=count($custom_fields);
124
- if($count==1 && isset($custom_fields['email'])){
125
-
126
- $custom_fields=array();
127
- }
128
-
129
- if($custom_fields) $data_widget['customfields']=$custom_fields;
130
-
131
- }
132
-
133
- if(!isset($data_widget['customfields']) && isset($data_widget['labelswithin']) && $data_widget['labelswithin']=='labels_within'){
134
- $data_widget['customfields']=array('email'=>array('label'=>__('Email',WYSIJA)));
135
- }
136
-
137
- return $data_widget;
138
- }
139
-
140
  }
1
+ <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
+ class WYSIJA_control_back_tmce extends WYSIJA_control{
4
+
5
+ function WYSIJA_control_back_tmce(){
6
+ parent::WYSIJA_control();
7
+ $this->viewObj=WYSIJA::get('tmce','view');
8
+ }
9
+
10
+ function subscribersAdd(){
11
+ $this->viewObj->title=__('Insert Total of Subscribers',WYSIJA);
12
+ $data = array();
13
+ $data['lists'] = WYSIJA::get('list','model')->getLists();
14
+ foreach ($data['lists'] as $k => $list){
15
+ if (empty($list['is_enabled']) OR empty($list['is_public'])) unset($data['lists'][$k]);
16
+ }
17
+ $data['confirm_dbleoptin'] = WYSIJA::get('config','model')->getValue('confirm_dbleoptin');
18
+
19
+ $this->viewObj->subscribersAdd($data);
20
+ exit;
21
+ }
22
+
23
+ function subscribersEdit(){
24
+
25
+ }
26
+
27
+ function registerAdd(){
28
+ $this->viewObj->title=__('Insert Subscription Form',WYSIJA);
29
+
30
+ $this->viewObj->registerAdd($this->getData());
31
+ exit;
32
+ }
33
+
34
+ function registerEdit(){
35
+ $this->viewObj->title=__('Insert Subscription Form',WYSIJA);
36
+
37
+ $this->viewObj->registerAdd($this->getData(),true);
38
+ exit;
39
+ }
40
+
41
+
42
+ function getData(){
43
+ $data_widget=array();
44
+
45
+ // if this parameter is passed that means we have an old widget let's import it and select
46
+ if(isset($_REQUEST['widget-data64'])){
47
+ $data_widget=unserialize(base64_decode($_REQUEST['widget-data64']));
48
+ $post=get_post($_REQUEST['post_id']);
49
+
50
+ // we need a title to identify the form
51
+ $data_widget['title'] = 'Form on '.$post->post_type.': '.$post->post_title;
52
+
53
+ $model_forms = WYSIJA::get('forms', 'model');
54
+ $model_forms->reset();
55
+ $form = $model_forms->getOne(false,array('name' => $data_widget['title']));
56
+
57
+ // this form doesn't exist yet in the new format so let's try to import it
58
+ if(empty($form)){
59
+ $helper_update=WYSIJA::get('update','helper');
60
+
61
+ $form_id = $helper_update->convert_widget_to_form($data_widget);
62
+ if($form_id!==false) {
63
+ $data_widget['default_form'] = $form_id;
64
+ }
65
+ }
66
+ }
67
+
68
+ if(isset($_POST['widget-wysija'])){
69
+ $data_widget=array('widget_id'=>$_POST['widget_id'],'preview'=>true);
70
+ $custom_fields=array();
71
+
72
+ foreach($_POST['widget-wysija'] as $arra){
73
+ foreach($arra as $k => $v) {
74
+ switch($k){
75
+ case 'lists':
76
+ if(isset($data_widget[$k])) $data_widget[$k][]=$v[0];
77
+ else $data_widget[$k]=array($v[0]);
78
+ break;
79
+ case 'lists_name':
80
+ foreach($v as $kv=>$vv){
81
+ if(isset($data_widget[$k])) $data_widget[$k][$kv]=$vv;
82
+ else $data_widget[$k]=array($kv=>$vv);
83
+ }
84
+
85
+ break;
86
+ case 'customfields':
87
+
88
+ $found=false;
89
+ foreach($custom_fields as $keycol => $params){
90
+ if(isset($v[$keycol])){
91
+ $custom_fields[$keycol]= array_merge($custom_fields[$keycol],$v[$keycol]);
92
+ $found=true;
93
+ }
94
+ }
95
+
96
+ if(!$found) $custom_fields=array_merge($custom_fields,$v);
97
+ break;
98
+
99
+ default:
100
+ $data_widget[$k]=stripslashes($v);
101
+ }
102
+
103
+ }
104
+ }
105
+
106
+
107
+ $count=count($custom_fields);
108
+ if($count>1){
109
+ foreach($custom_fields as $keycol=>$paraval){
110
+ if($keycol!='email' && !isset($paraval['column_name'])) unset($custom_fields[$keycol]);
111
+ }
112
+ }
113
+
114
+ $count=count($custom_fields);
115
+ if($count>0){
116
+ if(!isset($custom_fields['email'])){
117
+ $custom_fields['email']['column_name']='email';
118
+ $custom_fields['email']['label']=__('Email',WYSIJA);
119
+ }
120
+ }
121
+
122
+ $count=count($custom_fields);
123
+ if($count==1 && isset($custom_fields['email'])){
124
+
125
+ $custom_fields=array();
126
+ }
127
+
128
+ if($custom_fields) $data_widget['customfields']=$custom_fields;
129
+
130
+ }
131
+
132
+ if(!isset($data_widget['customfields']) && isset($data_widget['labelswithin']) && $data_widget['labelswithin']=='labels_within'){
133
+ $data_widget['customfields']=array('email'=>array('label'=>__('Email',WYSIJA)));
134
+ }
135
+
136
+ return $data_widget;
137
+ }
138
+
 
139
  }
controllers/back.php CHANGED
@@ -17,6 +17,7 @@ class WYSIJA_control_back extends WYSIJA_control{
17
  parent::WYSIJA_control();
18
  global $wysija_msg,$wysija_queries,$wysija_queries_errors;
19
  $wysija_msgTemp=get_option('wysija_msg');
 
20
  if(is_array($wysija_msgTemp) && count($wysija_msgTemp)>0){
21
  $wysija_msg=$wysija_msgTemp;
22
  }
@@ -66,9 +67,6 @@ class WYSIJA_control_back extends WYSIJA_control{
66
  add_action('wysija_various_check',array($this,'variousCheck'));
67
  do_action('wysija_various_check');
68
 
69
- // check if the plugin has an update available
70
- $updateH=WYSIJA::get('update','helper');
71
- $updateH->checkForNewVersion();
72
  $this->target_action_form = $this->data['target_action_form'] = $this->_getTargetActionForm(); // set default value of any form action
73
  }
74
 
@@ -82,7 +80,7 @@ class WYSIJA_control_back extends WYSIJA_control{
82
  // redirect instantly to a page with a javascript file where we check the domain is ok
83
  $data=get_option('wysijey');
84
  // remotely connect to host
85
- wp_enqueue_script('wysija-verif-licence', 'http://www.wysija.com/?wysijap=checkout&wysijashop-page=1&controller=customer&action=checkDomain&js=1&data='.$data, array( 'jquery' ), time());
86
  }
87
  }
88
 
@@ -249,7 +247,7 @@ class WYSIJA_control_back extends WYSIJA_control{
249
  $action =$datas['actionvar'];
250
  unset($datas['actionvar']);
251
  $this->action=$action;
252
-
253
  if(method_exists($this, $this->action)){
254
  $this->viewShow=$this->action;
255
  $this->$action($datas);
@@ -277,7 +275,7 @@ class WYSIJA_control_back extends WYSIJA_control{
277
  do_action('wysija_remove_action_check_total_subscribers');
278
  do_action('wysija_check_total_subscribers');
279
  }
280
-
281
  /**
282
  * Batch select process
283
  * - Currently, is for subscribers only
@@ -299,86 +297,37 @@ class WYSIJA_control_back extends WYSIJA_control{
299
  //
300
  //select all users which match to $_POST['wysija']['filter'] and create_at <= $_POST['wysija']['user']['timestamp']
301
  // - build query
302
- $this->filters = array();
303
- $config = WYSIJA::get('config','model');
304
- if(!empty($_REQUEST['search'])){
305
- $_REQUEST['wysija']['filter']['search'] = $_REQUEST['search'];
306
- }
307
 
308
- //link_fitler
309
- if (!empty($_REQUEST['wysija']['filter']['link_filter'])){
310
- switch($_REQUEST['wysija']['filter']['link_filter']){
311
- case 'unconfirmed':
312
- $this->filters['equal']['status'] = 0;
313
- break;
314
- case 'unsubscribed':
315
- $this->filters['equal']['status'] = -1;
316
- break;
317
- case 'subscribed':
318
- if($config->getValue('confirm_dbleoptin'))
319
- $this->filters['equal']['status'] = 1;
320
- else
321
- $this->filters['greater_eq']=array('status'=>0);
322
- break;
323
- case 'all':
324
- default:
325
- break;
326
- }
327
- }
328
- //filter_list
329
- $orphaned = $filter_join = false;
330
- if (!empty($_REQUEST['wysija']['filter']['filter_list'])){
331
- if ($_REQUEST['wysija']['filter']['filter_list'] == 'orphaned') {
332
- $this->filters['equal']['list_id'] = null;
333
- $orphaned = true;
334
- } elseif ((int)$_REQUEST['wysija']['filter']['filter_list']>0) {
335
- $this->filters['equal']['list_id'] = (int)$_REQUEST['wysija']['filter']['filter_list'];
336
- $filter_join = true;
337
- } else {
338
- // nothing to do
339
- }
340
- }
341
-
342
- if(!empty($_REQUEST['wysija']['filter']['search'])){
343
- $keyword = trim($_REQUEST['wysija']['filter']['search']);
344
- foreach(array('email','firstname', 'lastname') as $field)
345
- $this->filters['like'][$field] = $keyword;
346
- }
347
 
348
 
349
- //timestamp (max of create_at)
350
- $this->filters['less_eq']['created_at'] = $_REQUEST['wysija']['user']['timestamp'];
351
-
352
- $this->modelObj->noCheck = true; // force to not check column fields, just combine WHERE clause
353
- $this->modelObj->setConditions($this->filters);
354
  $this->_batch_select = array();
355
- $this->_batch_select['where'] = $this->modelObj->makeWhere();
356
- $from = 'FROM [wysija]user A';
357
- if($filter_join)
358
- $from .= ' JOIN [wysija]user_list B ON A.user_id = B.user_id';
359
- elseif($orphaned)
360
- $from .= ' LEFT JOIN [wysija]user_list B ON A.user_id = B.user_id';
361
- $this->_batch_select['from'] = $from;
362
- $this->_batch_select['select'] = 'SELECT DISTINCT A.user_id';
363
-
364
- $this->_batch_select['query'] = $this->_batch_select['select'] . ' ' . $this->_batch_select['from'] . ' ' . $this->_batch_select['where'];
365
-
366
  //Create a temporary table
367
- $temp_table_name = 'user'. time();
368
- $temp_table_create = 'CREATE TEMPORARY TABLE '.$temp_table_name . ' (user_id int (10) NOT NULL, PRIMARY KEY (user_id)) ENGINE=MyISAM';
369
- $temp_table_insert = 'INSERT INTO '.$temp_table_name.' ' . $this->_batch_select['query'];
370
  $model_user = WYSIJA::get('user','model');
371
- $model_user->query($temp_table_create);
372
- $model_user->query($temp_table_insert);
373
-
 
374
  //Override the queres with temporary table
375
  unset($this->_batch_select['where']);
376
- $row_count = $model_user->query('get_row', 'SELECT ROW_COUNT() as row_count');
377
  $this->_batch_select['original_query'] = $this->_batch_select['query']; // useful for export feature; in this case, we don't use temporary table
378
  $this->_batch_select['select'] = 'SELECT DISTINCT user_id';
379
  $this->_batch_select['from'] = 'FROM '.$temp_table_name . ' A';
380
  $this->_batch_select['query'] = 'SELECT user_id FROM '.$temp_table_name;
381
- $this->_batch_select['count'] = $row_count['row_count'];
382
  return true;
383
  }
384
 
@@ -388,17 +337,20 @@ class WYSIJA_control_back extends WYSIJA_control{
388
 
389
  $config=WYSIJA::get('config','model');
390
  $totalSubscribers=$config->getValue('total_subscribers');
 
391
 
392
  if((int)$totalSubscribers>1900){
393
  if((int)$totalSubscribers>2000){
 
394
  $this->error(str_replace(array('[link]','[/link]'),
395
- array('<a title="'.__('Get Premium now',WYSIJA).'" class="premium-tab" href="javascript:;">','</a>'),
396
- sprintf(__('Yikes. You\'re over the limit of 2000 subscribers for the free version of Wysija (%1$s in total). Sending is disabled now. Please upgrade your version to [link]premium[/link] to send without limits.',WYSIJA)
397
  ,$totalSubscribers)),true);
398
  }else{
 
399
  $this->notice(str_replace(array('[link]','[/link]'),
400
- array('<a title="'.__('Get Premium now',WYSIJA).'" class="premium-tab" href="javascript:;">','</a>'),
401
- sprintf(__('Yikes! You\'re near the limit of %1$s subscribers for Wysija\'s free version. Upgrade to [link]Premium[/link] to send without limits, and more.',WYSIJA)
402
  ,"2000")));
403
  }
404
  }
@@ -558,8 +510,12 @@ class WYSIJA_control_back extends WYSIJA_control{
558
  if($location)
559
  {
560
  $url = parse_url($location);
561
- if(!empty($url['query']))
562
  $location .= '&';
 
 
 
 
563
  $location .= 'redirect=1';
564
  }
565
  $wysi_location=$location;
@@ -584,7 +540,12 @@ class WYSIJA_control_back extends WYSIJA_control{
584
  }
585
 
586
  function popupContent(){
587
- wp_enqueue_style('custom_popup_css', WYSIJA_URL.'css/adminPopup.css');
 
 
 
 
 
588
  global $viewMedia;
589
  $viewMedia=$this->viewObj;
590
  $_GET['type']=$_REQUEST['type']='image';
@@ -674,41 +635,6 @@ class WYSIJA_control_back extends WYSIJA_control{
674
  return $location;
675
  }
676
 
677
- function __get_social_buttons($inline=true){
678
-
679
- if($inline){
680
- $class=' class="socials removeme"';
681
- }else{
682
- $class=' id="socials-block"';
683
- }
684
- $wysijaversion='<div '.$class.'>
685
- <div class="fb" >
686
- <div id="fb-root"></div>
687
- <script>(function(d, s, id) {
688
- var js, fjs = d.getElementsByTagName(s)[0];
689
- if (d.getElementById(id)) return;
690
- js = d.createElement(s); js.id = id;
691
- js.src = "//connect.facebook.net/en_US/all.js#xfbml=1";
692
- fjs.parentNode.insertBefore(js, fjs);
693
- }(document, \'script\', \'facebook-jssdk\'));</script>
694
- <div class="fb-like" data-href="http://www.facebook.com/wysija" data-send="false" data-layout="button_count" data-width="90" data-show-faces="false"></div></div>
695
- <div class="twitter">
696
- <a href="https://twitter.com/wysija" class="twitter-follow-button" data-show-count="true">Follow @wysija</a>
697
- <script>!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];if(!d.getElementById(id)){js=d.createElement(s);js.id=id;js.src="//platform.twitter.com/widgets.js";fjs.parentNode.insertBefore(js,fjs);}}(document,"script","twitter-wjs");</script>
698
- </div>
699
- <div class="gplus">
700
- <!-- Place this tag in your head or just before your close body tag -->
701
- <script type="text/javascript" src="https://apis.google.com/js/plusone.js"></script>
702
- <!-- Place this tag where you want the +1 button to render -->
703
- <g:plusone href="https://plus.google.com/104749849451537343615" size="medium"></g:plusone></div>
704
- ';
705
- if($inline) $wysijaversion.='<div id="hidesocials">
706
- <a class="linkignore socialfoot" href="javascript:;">'.__('Hide!',WYSIJA).'</a>
707
- </div>';
708
- $wysijaversion.= "<div style='clear:both;'></div></div><div style='clear:both;'></div>";
709
- return $wysijaversion;
710
- }
711
-
712
  /**
713
  * to remove the conflicts in wysija's interfaces
714
  * @param boolean $themes
17
  parent::WYSIJA_control();
18
  global $wysija_msg,$wysija_queries,$wysija_queries_errors;
19
  $wysija_msgTemp=get_option('wysija_msg');
20
+
21
  if(is_array($wysija_msgTemp) && count($wysija_msgTemp)>0){
22
  $wysija_msg=$wysija_msgTemp;
23
  }
67
  add_action('wysija_various_check',array($this,'variousCheck'));
68
  do_action('wysija_various_check');
69
 
 
 
 
70
  $this->target_action_form = $this->data['target_action_form'] = $this->_getTargetActionForm(); // set default value of any form action
71
  }
72
 
80
  // redirect instantly to a page with a javascript file where we check the domain is ok
81
  $data=get_option('wysijey');
82
  // remotely connect to host
83
+ wp_enqueue_script('wysija-verif-licence', 'http://www.mailpoet.com/?wysijap=checkout&wysijashop-page=1&controller=customer&action=checkDomain&js=1&data='.$data, array( 'jquery' ), time());
84
  }
85
  }
86
 
247
  $action =$datas['actionvar'];
248
  unset($datas['actionvar']);
249
  $this->action=$action;
250
+
251
  if(method_exists($this, $this->action)){
252
  $this->viewShow=$this->action;
253
  $this->$action($datas);
275
  do_action('wysija_remove_action_check_total_subscribers');
276
  do_action('wysija_check_total_subscribers');
277
  }
278
+
279
  /**
280
  * Batch select process
281
  * - Currently, is for subscribers only
297
  //
298
  //select all users which match to $_POST['wysija']['filter'] and create_at <= $_POST['wysija']['user']['timestamp']
299
  // - build query
 
 
 
 
 
300
 
301
+ $select = array( '[wysija]user.user_id');
302
+
303
+ // filters for unsubscribed
304
+ $filters = $this->modelObj->detect_filters();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
305
 
306
 
 
 
 
 
 
307
  $this->_batch_select = array();
308
+
309
+
310
+ $this->_batch_select['query'] = $this->modelObj->get_subscribers( $select, $filters, '', true );
311
+ $this->_batch_select['query_count'] = $this->modelObj->get_subscribers( array( 'COUNT(DISTINCT([wysija]user.user_id))'), $filters, '', true );
312
+
313
+
 
 
 
 
 
314
  //Create a temporary table
315
+ $temp_table_name = '[wysija]user'. time();
316
+ $temp_table_create = 'CREATE TEMPORARY TABLE IF NOT EXISTS '.$temp_table_name . ' (user_id int (10) NOT NULL, PRIMARY KEY (user_id)) ENGINE=MyISAM';
317
+ $temp_table_insert = 'INSERT IGNORE INTO '.$temp_table_name.' ' . $this->_batch_select['query'];
318
  $model_user = WYSIJA::get('user','model');
319
+
320
+ $model_user->query($temp_table_create);
321
+ $model_user->query($temp_table_insert);
322
+
323
  //Override the queres with temporary table
324
  unset($this->_batch_select['where']);
325
+ $row_count = $model_user->query('get_row', 'SELECT COUNT(*) as row_count FROM '.$temp_table_name);
326
  $this->_batch_select['original_query'] = $this->_batch_select['query']; // useful for export feature; in this case, we don't use temporary table
327
  $this->_batch_select['select'] = 'SELECT DISTINCT user_id';
328
  $this->_batch_select['from'] = 'FROM '.$temp_table_name . ' A';
329
  $this->_batch_select['query'] = 'SELECT user_id FROM '.$temp_table_name;
330
+ $this->_batch_select['count'] = $row_count['row_count'];
331
  return true;
332
  }
333
 
337
 
338
  $config=WYSIJA::get('config','model');
339
  $totalSubscribers=$config->getValue('total_subscribers');
340
+ $helper_licence = WYSIJA::get('licence','helper');
341
 
342
  if((int)$totalSubscribers>1900){
343
  if((int)$totalSubscribers>2000){
344
+ $url_checkout = $helper_licence->get_url_checkout('over200');
345
  $this->error(str_replace(array('[link]','[/link]'),
346
+ array('<a title="'.__('Get Premium now',WYSIJA).'" target="_blank" href="'.$url_checkout.'">','</a>'),
347
+ sprintf(__('Yikes. You\'re over the limit of 2000 subscribers for the free version of MailPoet (%1$s in total). Sending is disabled now. Please upgrade your version to [link]premium[/link] to send without limits.',WYSIJA)
348
  ,$totalSubscribers)),true);
349
  }else{
350
+ $url_checkout = $helper_licence->get_url_checkout('near200');
351
  $this->notice(str_replace(array('[link]','[/link]'),
352
+ array('<a title="'.__('Get Premium now',WYSIJA).'" target="_blank" href="'.$url_checkout.'">','</a>'),
353
+ sprintf(__('Yikes! You\'re near the limit of %1$s subscribers for MailPoet\'s free version. Upgrade to [link]Premium[/link] to send without limits, and more.',WYSIJA)
354
  ,"2000")));
355
  }
356
  }
510
  if($location)
511
  {
512
  $url = parse_url($location);
513
+ if(!empty($url['query'])) {
514
  $location .= '&';
515
+ } else {
516
+ $location .= '?';
517
+ }
518
+
519
  $location .= 'redirect=1';
520
  }
521
  $wysi_location=$location;
540
  }
541
 
542
  function popupContent(){
543
+ // remove auth check
544
+ remove_action('admin_enqueue_scripts', 'wp_auth_check_load');
545
+
546
+ // add popup css
547
+ wp_enqueue_style('custom_popup_css', WYSIJA_URL.'css/adminPopup.css', array(), WYSIJA::get_version(), 'screen');
548
+
549
  global $viewMedia;
550
  $viewMedia=$this->viewObj;
551
  $_GET['type']=$_REQUEST['type']='image';
635
  return $location;
636
  }
637
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
638
  /**
639
  * to remove the conflicts in wysija's interfaces
640
  * @param boolean $themes
controllers/back/campaigns.php CHANGED
@@ -2,2654 +2,2758 @@
2
 
3
  global $viewMedia;
4
  defined('WYSIJA') or die('Restricted access');
5
- class WYSIJA_control_back_campaigns extends WYSIJA_control_back{
6
- var $model='campaign';
7
- var $view='campaigns';
8
- var $list_columns=array('campaign_id','name', 'description');
9
- var $searchable=array('name', 'description');
10
- var $filters=array();
11
- var $base_url = 'admin.php';
12
-
13
- function WYSIJA_control_back_campaigns(){
14
-
15
- }
16
- function installation(){
17
- return '';
18
- }
19
- /**
20
- * Welcome page first time install
21
- * @return boolean
22
- */
23
- function welcome_new(){
24
- $this->title=$this->viewObj->title=__('Welcome Page!',WYSIJA);
25
- $this->jsTrans['instalwjp']=__('Installing Wysija Newsletter Premium plugin',WYSIJA);
26
- $helper_readme=WYSIJA::get('readme','helper');
27
- $helper_readme->scan();
28
- $this->data=array();
29
- $this->data['abouttext']=__('A Brand New Wysija. Let the Fun Begin.',WYSIJA);
30
-
31
- $model_config=WYSIJA::get('config','model');
32
- $is_multisite=is_multisite();
33
- $is_network_admin=WYSIJA::current_user_can('manage_network');
34
- if($is_multisite && $is_network_admin){
35
- $model_config->save(array('ms_wysija_whats_new'=>WYSIJA::get_version()));
36
- }else{
37
- $model_config->save(array('wysija_whats_new'=>WYSIJA::get_version()));
38
- }
39
-
40
- //add a new language code with a new video
41
- $video_language=array();
42
- $video_language['en_EN']='http://www.youtube.com/embed/pYzaHDTg5Jk';
43
- $video_language['fr_FR']='http://www.youtube.com/embed/W5EyW5w7aWQ';
44
- $video_language['sv_SE']='http://www.youtube.com/embed/O8_t_dekx74';
45
- $video_language['ar']='http://www.youtube.com/embed/cyDHlX_qgOo';
46
-
47
- if(defined('WPLANG') && WPLANG!='' && isset($video_language[WPLANG])){
48
- $welcome_video_link = $video_language[WPLANG];
49
- }else{
50
- $welcome_video_link = $video_language['en_EN'];
51
- }
52
-
53
- $this->data['sections'][]=array(
54
- 'title'=>__('First Time? See it in Action',WYSIJA),
55
- 'format'=>'normal',
56
- 'paragraphs'=>array(
57
- __('You can start by watching this video by one of our users.',WYSIJA),
58
- '<iframe width="853" height="480" src="'.$welcome_video_link.'" frameborder="0" allowfullscreen></iframe>'
59
- )
60
- );
61
-
62
- $this->data['sections'][]=array(
63
- 'title'=>__('What You Can Do',WYSIJA),
64
- 'cols'=>array(
65
- array(
66
- 'title'=>__('5 minute newbie guide',WYSIJA),
67
- 'content'=>__('Your Wysija comes with an example newsletter. You\'ll see it when you close this welcome page. Edit it to start playing with it.',WYSIJA)
68
- ),
69
- array(
70
- 'title'=>__('Share your data',WYSIJA),
71
- 'content'=> str_replace(
72
- array('[link]', '[/link]', '[ajaxlink]', '[/ajaxlink]'),
73
- array('<a title="Anonymous Data" target="_blank" href="http://support.wysija.com/knowledgebase/share-your-data/?utm_source=wpadmin&utm_campaign=welcome_page">', '</a>', '<a id="share_analytics" href="javascript:;">', '</a>'),
74
- __("We know too little about our users. We're looking for [link]anonymous data[/link] to build a better plugin. [ajaxlink]Yes, count me in![/ajaxlink]",WYSIJA))
75
- ),
76
- array(
77
- 'title'=>__('Help yourself. Or let us help you.',WYSIJA),
78
- 'content'=> str_replace(
79
- array('[link]','[/link]'),
80
- array('<a href="http://support.wysija.com/" target="_blank" title="On our blog!">','</a>'),
81
- __('We got documentation and a ticket system on [link]support.wysija.com[/link]. We answer within 24h.',WYSIJA))
82
- )
83
- ),
84
- 'format'=>'three-col',
85
- );
86
-
87
- $this->data['sections'][]=array(
88
- 'title'=>__('Wysi... what?',WYSIJA),
89
- 'format'=>'normal',
90
- 'paragraphs'=>array(
91
- str_replace(
92
- array('[link]','[/link]'),
93
- array('<a href="http://www.wysija.com/you-want-to-help-us-out/" target="_blank">','</a>'),
94
- __('So who are we? We\'re 4 guys who decided in 2011 that WordPress needed a better emailing solution. The tag line <em>What You Send Is Just Awesome</em> was born and the acronym Wysija became our name. If you like what we do, make sure [link]you spread the good word[/link].',WYSIJA))
95
- )
96
- );
97
-
98
- $this->viewObj->skip_header=true;
99
-
100
- return true;
101
- }
102
-
103
-
104
- /**
105
- * Welcome page for updaters
106
- * @return boolean
107
- */
108
- function whats_new(){
109
-
110
- $this->title=$this->viewObj->title=__('What\'s new?',WYSIJA);
111
- $this->jsTrans['instalwjp']=__('Installing Wysija Newsletter Premium plugin',WYSIJA);
112
- $helper_readme=WYSIJA::get('readme','helper');
113
- $helper_readme->scan();
114
- $this->data=array();
115
- $this->data['abouttext']=__('You updated! It\'s like having the next gadget, but better.',WYSIJA);
116
- // this is a flag to have a pretty clean update page where teh only call to action is our survey
117
- $show_survey=false;
118
-
119
- $is_multisite=is_multisite();
120
- $is_network_admin=WYSIJA::current_user_can('manage_network');
121
- $model_config=WYSIJA::get('config','model');
122
-
123
- if($is_multisite){
124
- if($is_network_admin){
125
- $model_config->save(array('ms_wysija_whats_new'=>WYSIJA::get_version()));
126
- }
127
- }else{
128
- $model_config->save(array('wysija_whats_new'=>WYSIJA::get_version()));
129
- }
130
-
131
-
132
- $major_release=true;
133
-
134
- // those are point release exceptions for which we were advertising the features. we probably can remove that now
135
- $except_version=array('2.4.1', '2.4.2');
136
- $wysija_version=WYSIJA::get_version();
137
- if(!in_array($wysija_version,$except_version) && count(explode('.', $wysija_version))>2) $major_release=false;
138
-
139
-
140
-
141
- if($major_release){
142
- $this->data['sections'][]=array(
143
- 'title'=>__('Added',WYSIJA),
144
- 'cols'=>array(
145
- array(
146
- 'title'=>__('Better subscriber management',WYSIJA),
147
- 'content'=>__('New batch actions: move, add & remove from lists. Confirm the unconfirmed. Select all subscribers in 1 click. Powerful.',WYSIJA)
148
- ),
149
- array(
150
- 'title'=>__('Undo unsubscribe',WYSIJA),
151
- 'content'=>__('A subscriber mistakenly hit the unsubscribe link in your newsletter? He can now undo this in 1 click. Hurray.',WYSIJA)
152
- ),
153
- array(
154
- 'title'=>__('Switch to beta',WYSIJA),
155
- 'content'=> str_replace(
156
- array('[link]', '[/link]'),
157
- array('<a href="admin.php?page=wysija_config&amp;scroll_to=beta_mode_setting#tab-advanced">', '</a>'),
158
- __('And make a difference. We\'re looking for feedback and bug reports on our upcoming features. [link]Activate the beta in your settings.[/link]',WYSIJA))
159
- ),
160
- ),
161
- 'format'=>'three-col',
162
- );
163
-
164
-
165
- $this->data['sections'][]=array(
166
- 'title'=>__('Improved',WYSIJA),
167
- 'cols'=>array(
168
- array(
169
- 'title'=>__('MS: bounce, only once',WYSIJA),
170
- 'content'=>__( 'Premium user on Multisite? Enjoy configuring the automated bounce for all sites, once. Too easy.', WYSIJA)
171
- ),
172
- array(
173
- 'title'=>__('Don\'t like my style?',WYSIJA),
174
- 'content'=>__('Well too bad! Remove the Styles and Themes tab in the visual editor for your site\'s other users. See the Advanced Settings.',WYSIJA)
175
- ),
176
- array(
177
- 'title'=>__('Share your data, help Wysija',WYSIJA),
178
- 'content'=> str_replace(
179
- array('[link]', '[/link]', '[ajaxlink]', '[/ajaxlink]'),
180
- array('<a title="Open in new tab" target="_blank" href="http://support.wysija.com/knowledgebase/share-your-data/?utm_source=wpadmin&utm_campaign=update_page">', '</a>', '<a id="share_analytics" href="javascript:;">', '</a>'),
181
- __("We're looking for [link]anonymous data[/link] to build a better plugin. [ajaxlink]<strong>Yes, count me in!</strong>[/ajaxlink]",WYSIJA))
182
- ),
183
- ),
184
- 'format'=>'three-col',
185
- );
186
- }else{
187
- $show_survey=true;
188
-
189
- if($show_survey){
190
- $this->data['sections'][] = array(
191
- 'title' => __('4 min survey to better understand what you need',WYSIJA),
192
- 'type' => 'survey'
193
- );
194
- }else{ // this is the part about the survey
195
- // list of polls from poll daddy
196
- $polls=array();
197
- $polls[7177099]=__('Where do you send your newsletters?', WYSIJA);
198
- $polls[7199642]=__('How many users on this site create and send newsletters?', WYSIJA);
199
- $polls[7199625]=__('You\'re installing this plugin for...', WYSIJA);
200
- $polls[7196766]=__('How would you feel if you could no longer use us?', WYSIJA);
201
- $polls[7196752]=__('Pick one improvement which is an absolute must', WYSIJA);
202
- $polls[7196784]=__('If our Premium was sold as a monthly payment, instead of a yearly payment, would you consider purchasing it?', WYSIJA);
203
- $polls[7196911]=__('On how many sites have you installed our plugin in the last year?', WYSIJA);
204
- $polls[7196646]=__('How many WordPress sites do you create every year?', WYSIJA);
205
- $polls[7196742]=__('When you installed our plugin, it was to...', WYSIJA);
206
- $polls[7196756]=__('How did you find out about Wysija?', WYSIJA);
207
- $polls[7196770]=__('How much money did you spend on Premium themes or plugins in the past year?', WYSIJA);
208
- $polls[7196783]=__('What other emailing solutions do you use?', WYSIJA);
209
- $polls[7196798]=__('What\'s the most annoying thing with our current version?', WYSIJA);
210
- $polls[7196805]=__('Have you had problems with your newsletters being marked as spam?', WYSIJA);
211
-
212
- // get the list of polls with the number of views for each
213
- $polls_views=get_option('wysija_polls_views');
214
- if(empty($polls_views)){
215
- $polls_views=array();
216
- // this one has been the first poll we've used so we consider that everyone viewed it already once
217
- $polls_views[7177099]=1;
218
- }
219
-
220
-
221
- // make sure that we record each poll
222
- foreach($polls as $poll_id => $poll_title){
223
- if(!isset($polls_views[$poll_id])) $polls_views[$poll_id]=0;
224
- }
225
-
226
- // group polls by total view
227
- $polls_grouped_by_total_view = array();
228
- foreach($polls_views as $pollid =>$views){
229
- $polls_grouped_by_total_view[$views][]=$pollid;
230
- }
231
- // order them
232
- ksort($polls_grouped_by_total_view);
233
-
234
- // get the series of polls that has been viewed the least
235
- $polls_with_least_views = array_shift($polls_grouped_by_total_view);
236
-
237
- // pull one poll out of that array
238
- $random_key = array_rand($polls_with_least_views);
239
- $poll_id_selected = $polls_with_least_views[$random_key];
240
- $polls_views[$poll_id_selected]++;
241
-
242
- WYSIJA::update_option('wysija_polls_views', $polls_views);
243
-
244
- $this->data['polls'][$poll_id_selected]= $polls[$poll_id_selected];
245
- // poll
246
- $this->data['sections'][] = array(
247
- 'title' => __('A new poll to get to know you better', WYSIJA),
248
- 'type' => 'poll'
249
- );
250
- }
251
- }
252
-
253
- $msg=$model_config->getValue('ignore_msgs');
254
- if(!isset($msg['ctaupdate']) && !$show_survey){
255
- $this->data['sections'][]=array(
256
- 'title'=>__('Keep this plugin essentially free',WYSIJA),
257
- 'review'=>array(
258
- 'title'=>'1. '.__('Love kittens?',WYSIJA).' '.__('We love stars...',WYSIJA),
259
- 'content'=>str_replace(
260
- array('[link]','[/link]'),
261
- array('<a href="http://wordpress.org/support/view/plugin-reviews/wysija-newsletters" target="_blank" title="On wordpress.org">','</a>'),
262
- __('Each time one of our users forgets to write a review, a kitten dies. It\'s sad and breaks our hearts. [link]Add your own review[/link] and save a kitten today.',WYSIJA))
263
-
264
-
265
- ),
266
- 'follow'=> array(
267
- 'title'=>'2. '.__('Follow us and don\'t miss anything!',WYSIJA),
268
- 'content'=>$this->__get_social_buttons(false)
269
- ),
270
- 'hidelink'=>'<a class="linkignore ctaupdate" href="javascript:;">'.__('Hide!',WYSIJA).'</a>',
271
- 'format'=>'review-follow',
272
- );
273
-
274
- }
275
-
276
-
277
-
278
-
279
-
280
- if(isset($helper_readme->changelog[WYSIJA::get_version()])){
281
- $this->data['sections'][]=array(
282
- 'title'=>__('Change log', WYSIJA),
283
- 'format'=>'bullets',
284
- 'paragraphs'=>$helper_readme->changelog[WYSIJA::get_version()]
285
- );
286
- }
287
-
288
-
289
-
290
-
291
- $this->viewObj->skip_header=true;
292
- return true;
293
- }
294
-
295
- /* START prem check hook */
296
- // when curl or any php remote function not available wysija.com returns lcheck to that function
297
- function licok() {
298
- parent::WYSIJA_control_back();
299
- $dt = get_option('wysijey');
300
-
301
- if(isset($_REQUEST['xtz']) && $dt === $_REQUEST['xtz']){
302
- $dataconf = array('premium_key'=> base64_encode(get_option('home').time()), 'premium_val' => time());
303
- $this->notice(__('Premium version is valid for your site.',WYSIJA));
304
- } else {
305
- $dataconf = array('premium_key' => '', 'premium_val' => '');
306
-
307
- $helper_licence=WYSIJA::get('licence','helper');
308
- $url_premium = 'http://www.wysija.com/checkout/?wysijadomain='.$dt.'&nc=1&utm_source=wpadmin&utm_campaign=error_licence_activation';
309
-
310
- $this->error(str_replace(array('[link]','[/link]'),array('<a href="'.$url_premium.'" target="_blank">','</a>'),
311
- __('Premium licence does not exist for your site. Purchase it [link]here[/link].',WYSIJA)), 1);
312
- }
313
- WYSIJA::update_option('wysicheck',false);
314
- $modelConf=WYSIJA::get('config','model');
315
- $modelConf->save($dataconf);
316
-
317
- $this->redirect('admin.php?page=wysija_config#tab-premium');
318
- }
319
- /* END prem check hook */
320
-
321
- function validateLic(){
322
- $helpLic=WYSIJA::get('licence','helper');
323
- $res = $helpLic->check();
324
-
325
- $this->redirect();
326
- }
327
-
328
- /**
329
- * this function is triggered when sending manually the emails with the "Don't wait and send right now" button
330
- * @param type $dataPost
331
- */
332
- function manual_send($dataPost=false){
333
- $modelQ=WYSIJA::get('queue','model');
334
- $config=WYSIJA::get('config','model');
335
- if( (int) $config->getValue('total_subscribers') < 2000 ){
336
- if($modelQ->count()>0){
337
- $helperQ=WYSIJA::get('queue','helper');
338
- $emailid=false;
339
- if($_REQUEST['emailid']){
340
- $emailid=$_REQUEST['emailid'];
341
- }
342
- $helperQ->process($emailid);
343
- }else{
344
- echo '<strong style="font-family: Arial; font-weight: bold; font-size: 12px;">'.__('Queue is empty!',WYSIJA).'</strong>';
345
- }
346
- exit;
347
- }else {
348
- //deprecated
349
- do_action('wysija_send_test_editor');
350
-
351
- do_action('wysija_manual_send');
352
- }
353
-
354
- exit;
355
- }
356
-
357
- /**
358
- * test the bounce handling maybe this should move somewhere else like config controller
359
- * @return boolean
360
- */
361
- function test_bounce(){
362
- // bounce handling
363
- $helper_bounce = WYSIJA::get('bounce','helper');
364
-
365
- // in a multisite case we process first the bounce recording into the bounce table
366
- if(is_multisite()){
367
- $helper_bounce->record_bounce_ms();
368
-
369
- // then we take actions from what has been returned by the bounce
370
- return $helper_bounce->process_bounce_ms();
371
- }else{
372
- return $helper_bounce->process_bounce();
373
- }
374
- }
375
-
376
- function add($dataPost=false){
377
- $this->title=sprintf(__('Step %1$s',WYSIJA),1);
378
- $this->js[]='wysija-validator';
379
-
380
- $this->js[]='wysija-edit-autonl';
381
- $this->js['admin-campaigns-edit']='admin-campaigns-edit';
382
- $this->jsTrans['descauto']=str_replace(array('[newsletter:number]','[newsletter:total]','[newsletter:post_title]'),array('<b>[newsletter:number]</b>','<b>[newsletter:total]</b>','<b>[newsletter:post_title]</b>'),__('Insert [newsletter:total] to show number of posts, [newsletter:post_title] to show the latest post\'s title & [newsletter:number] to display the issue number.',WYSIJA));
383
- $this->jsTrans['descstandard']=__('The first thing your subscribers see. Be creative and increase your open rate!',WYSIJA);
384
- $this->immediateWarning();
385
- $this->viewObj->title=__('First step: main details',WYSIJA);
386
- $this->viewShow='add';
387
- $this->data=array();
388
- $this->data['campaign']=array('name'=>'','description'=>'');
389
- $modelConfig=WYSIJA::get('config','model');
390
- $this->data['email']=array('subject'=>'','from_email'=>$modelConfig->getValue('from_email'),'from_name'=>$modelConfig->getValue('from_name'));
391
- $this->data['lists']=$this->__getLists(false,true,true);
392
-
393
- $this->dataAutoNl();
394
- $this->jsLoc['admin-campaigns-edit']['autofields']=$this->data['autonl']['fields'];
395
-
396
- }
397
-
398
- /**
399
- * get the fields and fields value necessary when dealing with automatic newsletters
400
- */
401
- function dataAutoNl(){
402
- $dataFrequencyNoImmediate=$dataFrequency=array('daily'=>__('once a day at...',WYSIJA),
403
- 'weekly'=>__('weekly on...',WYSIJA),
404
- 'monthly'=>__('monthly on the...',WYSIJA),
405
- 'monthlyevery'=>__('monthly every...',WYSIJA),
406
- 'immediate'=>__('immediately.',WYSIJA));
407
-
408
- unset($dataFrequencyNoImmediate['immediate']);
409
-
410
- $times = array();
411
- $time = strtotime('00:00:00');
412
- $toolboxH=WYSIJA::get('toolbox','helper');
413
- $times['00:00:00']=$toolboxH->localtime($time);
414
-
415
- for($i = 1;$i < 24;$i++) {
416
- $time = strtotime('+ 1hour',$time);
417
- $key = date('H:i:s',$time);
418
- $times[$key] = $toolboxH->localtime($time);
419
- }
420
-
421
- $daysvalues=$toolboxH->getday();
422
-
423
- $numberweeks=$toolboxH->getweeksnumber();
424
- $daynumbers=$toolboxH->getdaynumber();
425
-
426
-
427
- $dataLists=array();
428
-
429
- foreach($this->data['lists'] as $datal) {
430
- if($datal['is_enabled']) $dataLists[$datal['list_id']]=$datal['name'];
431
- }
432
-
433
- // Get all available roles
434
- $wptoolsH = WYSIJA::get('wp_tools','helper');
435
- $roles = $wptoolsH->wp_get_all_roles();
436
- $available_roles = array('any'=>__('in any role,',WYSIJA));
437
- foreach ($roles as $role => $name) {
438
- $available_roles[$role] = __('as ' . $name . ',',WYSIJA);
439
- }
440
-
441
- $this->data['autonl']['fields']=array(
442
- 'event'=>array(
443
- 'values'=>array(
444
- 'new-articles'=>__('there\'s new content, send...',WYSIJA),
445
- 'subs-2-nl'=>__('someone subscribes to the list...',WYSIJA),
446
- 'new-user'=>__('a new WordPress user is added to your site...',WYSIJA),
447
- ),
448
- 'valueshow'=>array(
449
- 'new-articles'=>array('when-article'),
450
- 'subs-2-nl'=>array('subscribetolist','numberafter','numberofwhat','unique_send'),
451
- 'new-user'=>array('roles','numberafter','numberofwhat','unique_send'),
452
- ),
453
- 'style'=>'width:300px;'
454
- ),
455
- 'when-article'=>array(
456
- 'values'=>$dataFrequency,
457
- 'valueshow'=>array(
458
- 'daily'=>array('time'),
459
- 'weekly'=>array('dayname','time'),
460
- 'monthly'=>array('daynumber','time'),
461
- 'monthlyevery'=>array('dayevery','dayname','time'),
462
- )
463
- ),
464
- 'subscribetolist'=>array(
465
- 'values'=>$dataLists,
466
- 'style'=>'width:300px;'
467
- ),
468
- 'roles'=>array(
469
- 'values'=>$available_roles
470
- ),
471
- 'numberafter'=>array(
472
- 'type'=>'input',
473
- 'style'=>'width:35px;',
474
- 'class'=>'validate[required,custom[integer],min[1]]',
475
- ),
476
- 'numberofwhat'=>array(
477
- 'values'=>array(
478
- 'immediate'=>__('immediately.',WYSIJA),
479
- 'hours'=>__('hour(s) after.',WYSIJA),
480
- 'days'=>__('day(s) after.',WYSIJA),
481
- 'weeks'=>__('week(s) after.',WYSIJA)
482
- ),
483
- 'valuesunit'=>array(
484
- 'immediate'=>__('immediately',WYSIJA),
485
- 'hours'=>__('hour(s)',WYSIJA),
486
- 'days'=>__('day(s)',WYSIJA),
487
- 'weeks'=>__('week(s)',WYSIJA)
488
- ),
489
- ),
490
- 'dayevery'=>array(
491
- 'values'=>$numberweeks,
492
- ),
493
- 'dayname'=>array(
494
- 'values'=>$daysvalues,
495
- ),
496
-
497
- 'daynumber'=>array(
498
- 'values'=>$daynumbers,
499
- ),
500
-
501
- 'time'=>array(
502
- 'values'=>$times,
503
- ),
504
- /*'unique_send'=>array(
505
- 'label_before'=>__('Send this email only once.',WYSIJA),
506
- 'type'=>'checkbox'
507
- ),*/
508
- );
509
- $helpersEvent=WYSIJA::get('autonews','helper');
510
- $extraEvents=$helpersEvent->events();
511
-
512
- /*if there are plugin to add autonewsletter event they are adding their customized field over here*/
513
- if($extraEvents){
514
- foreach($extraEvents as $k =>$v){
515
-
516
- $this->data['autonl']['fields']['event']['values'][$k]=$v['title'];
517
- foreach($v['fields'] as $fieldCKEY => $fieldCVAL){
518
- if(isset($this->data['autonl']['fields'][$fieldCKEY])) continue;
519
- }
520
- $this->data['autonl']['fields']['event']['valueshow'][$k]=array_keys($v['fields']);
521
- }
522
- }
523
-
524
- }
525
-
526
-
527
-
528
- function __getLists($enabled=true,$count=false,$notgetalllistid=false){
529
- $modelList=WYSIJA::get('list','model');
530
- //get lists which have users and are enabled */
531
- if($enabled) $enabledstrg=' is_enabled>0 and';
532
- else $enabledstrg='';
533
-
534
- $extrasql='';
535
- if(!$notgetalllistid) $extrasql='WHERE list_id in (SELECT distinct(list_id) from wp_wysija_user_list )';
536
- $query='SELECT * FROM [wysija]list '.$extrasql;
537
- $listres=$modelList->query('get_res',$query);
538
-
539
- if($count){
540
- $mConfig = WYSIJA::get('config','model');
541
- $condit = '>=';
542
- if($mConfig->getValue('confirm_dbleoptin')) $condit='>';
543
- $qry1="SELECT count(distinct A.user_id) as nbsub,A.list_id FROM `[wysija]user_list` as A LEFT JOIN `[wysija]user` as B on A.user_id=B.user_id WHERE B.status $condit 0 and A.sub_date>0 and A.unsub_date=0 GROUP BY list_id";
544
-
545
- $total=$modelList->getResults($qry1);
546
-
547
- foreach($total as $tot){
548
- foreach($listres as $key=>$res){
549
- if($tot['list_id']==$res['list_id']) $listres[$key]['count']=$tot['nbsub'];
550
- }
551
- }
552
- }
553
- foreach($listres as $key =>$res){
554
- if(!isset($res['count'])) $listres[$key]['count']=0;
555
- }
556
- return $listres;
557
- }
558
-
559
- function edit($dataPost=false){
560
- if(!$this->_checkEmailExists($_REQUEST['id'])) return;
561
- $this->add();
562
-
563
- $modelEmail=WYSIJA::get('email','model');
564
-
565
- $this->data['email']=$modelEmail->getOne(false,array('email_id'=>$_REQUEST['id']));
566
-
567
- if($this->data['email']['status']>0){
568
- $this->redirect();
569
- }
570
- $this->title=sprintf(__('Step %1$s',WYSIJA),1).' | '.$this->data['email']['subject'];
571
- $modelCamp=WYSIJA::get('campaign','model');
572
- $this->data['campaign']=$modelCamp->getOne(false,array('campaign_id'=>$this->data['email']['campaign_id']));
573
-
574
- $modelCL=WYSIJA::get('campaign_list','model');
575
- $this->data['campaign_list']=$modelCL->get(false,array('campaign_id'=>$this->data['email']['campaign_id']));
576
- }
577
-
578
-
579
- function editTemplate(){
580
- // make sure the editor content is not cached
581
- header('Cache-Control: no-cache, max-age=0, must-revalidate, no-store'); // HTTP/1.1
582
- header('Expires: Fri, 9 Mar 1984 00:00:00 GMT');
583
-
584
- if(!$this->_checkEmailExists($_REQUEST['id'])) return;
585
- $this->viewShow = 'editTemplate';
586
-
587
- wp_enqueue_style('thickbox');
588
-
589
- $wjEngine = WYSIJA::get('wj_engine', 'helper');
590
- /* WJ editor translations */
591
- $this->jsTrans = array_merge($this->jsTrans, $wjEngine->getTranslations());
592
-
593
- $this->jsTrans['savingnl']=__('Saving newsletter...',WYSIJA);
594
- $this->jsTrans['errorsavingnl']=__('Error Saving newsletter...',WYSIJA);
595
- $this->jsTrans['savednl']=__('Newsletter has been saved.',WYSIJA);
596
- $this->jsTrans['previewemail']=__('Sending preview...',WYSIJA);
597
- $this->jsTrans['spamtestresult']=__('Spam test results',WYSIJA);
598
-
599
- /* WJ editor JS */
600
- $this->js[]='wysija-editor';
601
- $this->js[]='wysija-admin-ajax-proto';
602
- $this->js[]='wysija-admin-ajax';
603
- $this->js[]='wysija-base-script-64';
604
- $this->js[]='media-upload';
605
- $this->js['admin-campaigns-editDetails']='admin-campaigns-editDetails';
606
- $modelEmail=WYSIJA::get('email','model');
607
- $this->data=array();
608
- $this->data['email']=$modelEmail->getOne(false,array('email_id'=>$_REQUEST['id']));
609
-
610
- $this->checkIsEditable();
611
-
612
- $this->viewObj->title=sprintf(__('Second step : "%1$s"',WYSIJA),$this->data['email']['subject']);
613
- $this->title=sprintf(__('Step %1$s',WYSIJA),2)." | ".$this->data['email']['subject'];
614
-
615
- // check if html source is enabled in the config (this will add the "html source" button in tinymce)
616
- $model_config = WYSIJA::get('config', 'model');
617
- $this->jsTrans['html_source_enabled'] = (int)$model_config->getValue('html_source');
618
- }
619
-
620
- function checkIsEditable(){
621
- if(
622
- !($this->data['email']==2 || isset($this->data['email']['params']['schedule']['isscheduled']))
623
- && $this->data['email']['status']>0
624
- ){
625
- $this->redirect();
626
- }
627
- }
628
-
629
- function pause(){
630
- /* pause the campaign entry */
631
- if(isset($_REQUEST['id']) && $_REQUEST['id']){
632
- $modelEmail=WYSIJA::get('email','model');
633
- $myemail=$modelEmail->getOne(false,array('email_id'=>$_REQUEST['id']));
634
- $modelEmail->reset();
635
- $modelEmail->columns['modified_at']['autoup']=1;
636
- $modelEmail->update(array('status'=>-1),array('email_id'=>$_REQUEST['id']));
637
-
638
- if($myemail['type']==2){
639
- return $this->redirect('admin.php?page=wysija_campaigns&id='.$myemail['email_id'].'&action=edit');
640
- }else{
641
- $this->notice(__('Sending is now paused.',WYSIJA));
642
- }
643
- }
644
-
645
- $this->redirect();
646
- }
647
-
648
- function resume(){
649
- /* pause the campaign entry */
650
- if(isset($_REQUEST['id']) && $_REQUEST['id']){
651
- $modelEmail=WYSIJA::get('email','model');
652
- $modelEmail->columns['modified_at']['autoup']=1;
653
- $modelEmail->update(array('status'=>99),array('email_id'=>$_REQUEST['id']));
654
- $this->notice(__('Sending has resumed.',WYSIJA));
655
- }
656
-
657
- $this->redirect();
658
- }
659
-
660
- function duplicate(){
661
-
662
- /* 1 - copy the campaign entry */
663
-
664
- $model=WYSIJA::get('campaign','model');
665
- $query='INSERT INTO `[wysija]campaign` (`name`,`description`)
666
- SELECT concat("'.stripslashes(__('Copy of ',WYSIJA)).'",`name`),`description` FROM [wysija]campaign
667
- WHERE campaign_id='.(int)$_REQUEST['id'];
668
- $campaignid=$model->query($query);
669
-
670
- /* 2 - copy the email entry */
671
- $query='INSERT INTO `[wysija]email` (`campaign_id`,`subject`,`body`,`type`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,`status`,`created_at`,`modified_at`)
672
- SELECT '.$campaignid.', concat("'.stripslashes(__('Copy of ',WYSIJA)).'",`subject`),`body`,`type`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,0,'.time().','.time().' FROM [wysija]email
673
- WHERE email_id='.(int)$_REQUEST['email_id'];
674
- $emailid=$model->query($query);
675
-
676
- //let's reset the count of total childs for auto newsletter
677
- $mEmail=WYSIJA::get('email','model');
678
- $emailData=$mEmail->getOne(false,array('email_id'=>$emailid));
679
-
680
- if($emailData['type']==2){
681
- $paramsReseted=$emailData['params'];
682
- if(isset($paramsReseted['autonl']['total_child'])) $paramsReseted['autonl']['total_child']=0;
683
- if(isset($paramsReseted['autonl']['nextSend'])) $paramsReseted['autonl']['nextSend']=0;
684
- if(isset($paramsReseted['autonl']['firstSend'])) unset($paramsReseted['autonl']['firstSend']);
685
- if(isset($paramsReseted['autonl']['lastSend'])) unset($paramsReseted['autonl']['lastSend']);
686
- if(isset($paramsReseted['autonl']['articles']['ids'])) unset($paramsReseted['autonl']['articles']['ids']);
687
-
688
-
689
- $mEmail->update(array('params'=>$paramsReseted),array('email_id'=>$emailid));
690
- }
691
-
692
- /* 3 - copy the campaign_list entry */
693
- $query="INSERT INTO `[wysija]campaign_list` (`campaign_id`,`list_id`,`filter`)
694
- SELECT $campaignid,`list_id`,`filter` FROM [wysija]campaign_list
695
- WHERE campaign_id=".(int)$_REQUEST['id'];
696
- $model->query($query);
697
-
698
- $this->notice(__('The newsletter has been duplicated.',WYSIJA));
699
-
700
- $this->redirect('admin.php?page=wysija_campaigns&id='.$emailid.'&action=edit');
701
- }
702
- function duplicateEmail(){
703
- if(!$this->_checkEmailExists($_REQUEST['id'])) return;
704
-
705
- $model=WYSIJA::get('campaign','model');
706
- /* 2 - copy the email entry */
707
- $query='INSERT INTO `[wysija]email` (`campaign_id`,`subject`,`body`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,`status`,`created_at`,`modified_at`)
708
- SELECT `campaign_id`, concat("'.stripslashes(__("Copy of ",WYSIJA)).'",`subject`),`body`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,0,'.time().','.time().' FROM [wysija]email
709
- WHERE email_id='.(int)$_REQUEST['id'];
710
- $emailid = $model->query($query);
711
-
712
- $this->notice(__('The newsletter has been duplicated.',WYSIJA));
713
-
714
- $this->redirect('admin.php?page=wysija_campaigns&id='.$emailid.'&action=edit');
715
- }
716
-
717
- function immediateWarning(){
718
- $mConfig=WYSIJA::get('config','model');
719
-
720
- $is_multisite=is_multisite();
721
-
722
- //$is_multisite=true;//PROD comment that line
723
- if($is_multisite && $mConfig->getValue('sending_method')=='network'){
724
- $sending_emails_each=$mConfig->getValue('ms_sending_emails_each');
725
- $number=$mConfig->getValue('ms_sending_emails_number');
726
- }else{
727
- $sending_emails_each=$mConfig->getValue('sending_emails_each');
728
- $number=$mConfig->getValue('sending_emails_number');
729
- }
730
-
731
- $formsHelp=WYSIJA::get('forms','helper');
732
-
733
- $timespan=$formsHelp->eachValuesSec[$sending_emails_each];
734
- $tb=WYSIJA::get('toolbox','helper');
735
-
736
- $this->immediatewarning=str_replace(
737
- array('[link]','[/link]','[settings]'),
738
- array('<a href="#">','</a>',sprintf(__('%1$s emails every %2$s',WYSIJA),$number,trim($tb->duration($timespan,true)))),
739
- __('Your sending settings ([settings]) can\'t send that quickly to [number] subscribers. Expect delivery delays. [link]Read more[/link]',WYSIJA));
740
- $this->viewObj->immediatewarning='<span class="warning-msg" id="immediatewarning">'.$this->immediatewarning.'</span>';
741
-
742
- $this->jsTrans['immediatewarning']=$this->immediatewarning;
743
-
744
- //how many emails can be sent in 12 hours
745
- //if the frequency is less than 12hours
746
- if($timespan < 43200){
747
- $ratio=floor(43200/$timespan);
748
- $this->jsTrans['possibleemails']=$ratio*$number;
749
- }else{
750
- if($timespan == 43200){
751
- $this->jsTrans['possibleemails']=$number;
752
- }else{
753
- $ratio=floor($timespan/43200);
754
- $this->jsTrans['possibleemails']=$number/$ratio;
755
- }
756
-
757
- }
758
- }
759
-
760
- function editDetails(){
761
- if(!$this->_checkEmailExists($_REQUEST['id'])) return;
762
- $this->viewObj->title=__('Final step : last details',WYSIJA);
763
- $this->viewShow='editDetails';
764
- $this->js[]='wysija-validator';
765
- $this->jsTrans['previewemail']=__('Sending preview...',WYSIJA);
766
- $this->jsTrans['pickadate']=__('Pick a date',WYSIJA);
767
- $this->jsTrans['saveclose']=__('Save & close',WYSIJA);
768
- $this->jsTrans['sendlater']=__('Send later',WYSIJA);
769
-
770
- $this->jsTrans['schedule']=__('Schedule',WYSIJA);
771
-
772
-
773
- $this->js[]='jquery-ui-datepicker';
774
-
775
- $model_list=WYSIJA::get('list','model');
776
- $model_list->limitON=false;
777
- $this->data=array();
778
- $this->data['lists']=$this->__getLists(false,true,true);
779
-
780
- $model_email=WYSIJA::get('email','model');
781
- $this->data['email']=$model_email->getOne(false,array('email_id'=>$_REQUEST['id']));
782
-
783
- // The first newsletter, we don't have replyto_email and replyto_name
784
- if(empty($this->data['email']['replyto_email']) || empty($this->data['email']['replyto_name'])){
785
- $current_user = wp_get_current_user();
786
- $this->data['email']['replyto_email'] = $current_user->data->user_email;
787
- $this->data['email']['replyto_name'] = $current_user->data->display_name;
788
- }
789
-
790
-
791
- if((int)$this->data['email']['type']==2){
792
- $this->js['wysija-edit-autonl']='wysija-edit-autonl';
793
- $this->jsTrans['autonl']=true;
794
- $this->immediateWarning();
795
- $this->jsTrans['send']=__('Activate now',WYSIJA);
796
- }else{
797
- $this->jsTrans['autonl']=true;
798
- $this->viewObj->immediatewarning='';
799
- $this->jsTrans['send']= __('Send',WYSIJA);
800
- }
801
-
802
- if((int)$this->data['email']['type']==1){
803
- $this->jsTrans['alertsend']=__('You are about to send this newsletter. Please confirm.',WYSIJA);
804
- }else{
805
- if(isset($this->data['email']['params']['autonl']['event']) && $this->data['email']['params']['autonl']['event']=='subs-2-nl'){
806
- $this->data['autoresponder']=1;
807
- foreach($this->data['lists'] as $list){
808
- if($list['list_id']==$this->data['email']['params']['autonl']['subscribetolist']){
809
- break;
810
- }
811
- }
812
-
813
- $this->jsTrans['ignoreprevious']=sprintf(__('Are you sure you want to ignore the %1$s subscribers of the list %2$s?', WYSIJA),'"'.$list['count'].'"','"'.$list['name'].'"');
814
- }
815
- }
816
-
817
- $this->checkIsEditable();
818
-
819
- $this->title=sprintf(__('Step %1$s',WYSIJA),3)." | ".$this->data['email']['subject'];
820
- $this->dataAutoNl();
821
-
822
- $this->jsLoc['wysija-edit-autonl']['autofields']=$this->data['autonl']['fields'];
823
-
824
- $modelCL=WYSIJA::get('campaign_list','model');
825
- $this->data['campaign_list']=$modelCL->get(false,array('campaign_id'=>$this->data['email']['campaign_id']));
826
- }
827
-
828
- function delete(){
829
- $this->requireSecurity();
830
-
831
- if(isset($_REQUEST['id'])){
832
- $modelCampaign=WYSIJA::get('campaign','model');
833
- $modelCampaign->delete(array('campaign_id'=>$_REQUEST['id']));
834
-
835
- $modelCampaignL=WYSIJA::get('campaign_list','model');
836
- $modelCampaignL->delete(array('campaign_id'=>$_REQUEST['id']));
837
-
838
- $modelEmail=WYSIJA::get('email','model');
839
- $modelEmail->delete(array('campaign_id'=>$_REQUEST['id']));
840
-
841
- $this->notice(__('Newsletter deleted.',WYSIJA));
842
-
843
- }else{
844
-
845
- $this->notice(__("Newsletter can't be deleted.",WYSIJA));
846
- }
847
-
848
- // retrieve saved filter
849
- if(!empty($_REQUEST['action'])) unset($_REQUEST['action']);
850
- if(!empty($_REQUEST['id'])) unset($_REQUEST['id']);
851
- if(!empty($_REQUEST['_wpnonce'])) unset($_REQUEST['_wpnonce']);
852
- $redirect = $this->base_url.'?'.http_build_query($_REQUEST);
853
- $this->redirect($redirect);
854
- }
855
-
856
- function deleteEmail(){
857
- $this->requireSecurity();
858
- if(!$this->_checkEmailExists($_REQUEST['id'])) return;
859
-
860
- if(isset($_REQUEST['id'])){
861
- $modelEmail=WYSIJA::get('email','model');
862
- $modelEmail->delete(array('email_id'=>$_REQUEST['id']));
863
- $this->notice(__('Newsletter deleted.',WYSIJA));
864
- }else{
865
- $this->notice(__('Newsletter can\'t be deleted.',WYSIJA));
866
- }
867
-
868
- $this->redirect();
869
- }
870
-
871
- function savecamp(){
872
- $this->redirectAfterSave=false;
873
- //echo 'hello';
874
- //$this->requireSecurity();
875
- /* update email */
876
- $data=array();
877
-
878
- if(isset($_REQUEST['id'])){
879
-
880
- $modelEmail=WYSIJA::get('email','model');
881
- $modelEmail->fieldValid=false;
882
- $emaildataarr=$modelEmail->getOne(array('email_id'=>$_REQUEST['id']));
883
-
884
- $modelCampaign=WYSIJA::get('campaign','model');
885
- $modelCampaign->update(array('name'=>$_POST['wysija']['email']['subject'],'description'=>''),array('campaign_id'=>$emaildataarr['campaign_id']));
886
- $campaign_id=$emaildataarr['campaign_id'];
887
- $email_id=$emaildataarr['email_id'];
888
- $dataEmail=array(
889
- 'campaign_id'=>$campaign_id,
890
- 'subject'=>$_POST['wysija']['email']['subject'],
891
- 'type'=>$_POST['wysija']['email']['type']);
892
-
893
- if((int)$dataEmail['type'] === 2){
894
-
895
- //$newparams=unserialize(base64_decode($emaildataarr['params']));
896
- $newparams['autonl']=$_POST['wysija']['email']['params']['autonl'];
897
-
898
- $dataEmail['params']=$newparams;
899
- if(!isset($newparams['autonl']['unique_send'])){
900
- unset($dataEmail['params']['autonl']['unique_send']);
901
- }else $dataEmail['params']['autonl']['unique_send']=true;
902
-
903
- }
904
- $modelEmail->columns['modified_at']['autoup']=1;
905
- $modelEmail->debugupdate=true;
906
- $dataEmail['email_id']=$_REQUEST['id'];
907
-
908
- if(isset($_REQUEST['save-reactivate'])){
909
- //if the button save and reactivate has been clicked then we reactivate and redirect to the newsletter page
910
- $dataEmail['status']=99;
911
- $_REQUEST['return']=1;
912
- }
913
-
914
- $data['email']['email_id']=$modelEmail->update($dataEmail,array('email_id'=>$_REQUEST['id']));
915
- } else {
916
- $modelCampaign=WYSIJA::get('campaign','model');
917
- $campaign_id = $modelCampaign->insert(array('name' => $_POST['wysija']['email']['subject'], 'description' => ''));
918
-
919
- $modelEmail=WYSIJA::get('email','model');
920
- $modelEmail->fieldValid=false;
921
- $emaildata=array(
922
- 'campaign_id' => $campaign_id,
923
- 'subject' => $_POST['wysija']['email']['subject'],
924
- 'type' => (int)$_POST['wysija']['email']['type']
925
- );
926
-
927
-
928
- // create autonl parameters if necessary
929
- if((int)$_POST['wysija']['email']['type'] === 2 && isset($_POST['wysija']['email']['params']['autonl'])) {
930
- $emaildata['params'] = array('autonl' => $_POST['wysija']['email']['params']['autonl']);
931
- }
932
-
933
- // create sample data depending on newsletter's type
934
- if((int)$_POST['wysija']['email']['type'] === 2 && $_POST['wysija']['email']['params']['autonl']['event'] === 'new-articles') {
935
-
936
- // if immediate, post_limit is set to 1
937
- if($emaildata['params']['autonl']['when-article'] === 'immediate') {
938
- $autopostParams = array(
939
- array('key' => 'category_ids', 'value' => ''),
940
- array('key' => 'category', 'value' => ''),
941
- array('key' => 'title_tag', 'value' => 'h2'),
942
- array('key' => 'title_alignment', 'value' => 'left'),
943
- array('key' => 'image_alignment', 'value' => 'alternate'),
944
- array('key' => 'post_content', 'value' => 'excerpt'),
945
- array('key' => 'readmore', 'value' => base64_encode(__('Read online.',WYSIJA))),
946
- array('key' => 'show_divider', 'value' => 'yes'),
947
- array('key' => 'cpt', 'value' => 'post'),
948
- array('key' => 'post_limit', 'value' => 1)
949
- );
950
- } else {
951
- $autopostParams = array(
952
- array('key' => 'category_ids', 'value' => ''),
953
- array('key' => 'category', 'value' => ''),
954
- array('key' => 'title_tag', 'value' => 'h2'),
955
- array('key' => 'title_alignment', 'value' => 'left'),
956
- array('key' => 'image_alignment', 'value' => 'alternate'),
957
- array('key' => 'post_content', 'value' => 'excerpt'),
958
- array('key' => 'readmore', 'value' => base64_encode(__('Read online.',WYSIJA))),
959
- array('key' => 'show_divider', 'value' => 'yes'),
960
- array('key' => 'cpt', 'value' => 'post'),
961
- array('key' => 'post_limit', 'value' => 2)
962
- );
963
- }
964
-
965
- // sample data for post notifications
966
- $newwjdata = array(
967
- 'version' => WYSIJA::get_version(),
968
- 'header' => array(
969
- 'text' => NULL,
970
- 'image' => array(
971
- 'src' => WYSIJA_EDITOR_IMG.'transparent.png',
972
- 'width' => 600,
973
- 'height' => 86,
974
- 'alignment' => 'center',
975
- 'static' => true,
976
- ),
977
- 'alignment' => 'center',
978
- 'static' => true,
979
- 'type' => 'header'
980
- ),
981
- 'body' => array(
982
- 'block-1' => array(
983
- 'text' => array(
984
- 'value' => '<h3 class="align-right">'.sprintf(__("The posts below were added with the widget %sAutomatic latest content%s", WYSIJA), '<strong>', '</strong>').'</h3>'
985
- ),
986
- 'image' => array(
987
- 'src' => WYSIJA_EDITOR_IMG.'default-newsletter/autonewsletter/arrow-up.png',
988
- 'width' => 45,
989
- 'height' => 45,
990
- 'alignment' => 'right',
991
- 'static' => false
992
- ),
993
- 'alignment' => 'right',
994
- 'static' => false,
995
- 'position' => '1',
996
- 'type' => 'content'
997
- ),
998
- 'block-2' => array(
999
- 'text' => array(
1000
- 'value' => '<h3>'.sprintf(__('%sTo edit%s, mouse over to show edit button below.', WYSIJA), '<strong>', '</strong>').'</h3>'
1001
- ),
1002
- 'image' => array(
1003
- 'src' => WYSIJA_EDITOR_IMG.'default-newsletter/autonewsletter/arrow-down.png',
1004
- 'width' => 150,
1005
- 'height' => 53,
1006
- 'alignment' => 'left',
1007
- 'static' => false
1008
- ),
1009
- 'alignment' => 'left',
1010
- 'static' => false,
1011
- 'position' => '2',
1012
- 'type' => 'content'
1013
- ),
1014
- 'block-3' => array(
1015
- 'params' => $autopostParams,
1016
- 'position' => '3',
1017
- 'type' => 'auto-post'
1018
- )
1019
- ),
1020
- 'footer' => array(
1021
- 'text' => NULL,
1022
- 'image' => array(
1023
- 'src' => WYSIJA_EDITOR_IMG.'transparent.png',
1024
- 'width' => 600,
1025
- 'height' => 86,
1026
- 'alignment' => 'center',
1027
- 'static' => true,
1028
- ),
1029
- 'alignment' => 'center',
1030
- 'static' => true,
1031
- 'type' => 'footer'
1032
- )
1033
- );
1034
-
1035
- } else {
1036
- if(!isset($emaildata['params'])) $emaildata['params']=array();
1037
- $emaildata['params']['quickselection'] = array(
1038
- 'wp-301' => array(
1039
- 'identifier' => 'wp-301',
1040
- 'width' => 281,
1041
- 'height' => 190,
1042
- 'url' => WYSIJA_EDITOR_IMG.'default-newsletter/newsletter/pigeon.png',
1043
- 'thumb_url' => WYSIJA_EDITOR_IMG.'default-newsletter/newsletter/pigeon-150x150.png'
1044
- )
1045
- );
1046
- // get solid divider
1047
- $hDividers = WYSIJA::get('dividers', 'helper');
1048
- $defaultDivider = $hDividers->getDefault();
1049
-
1050
- // get bookmarks from iconset 2
1051
- $hBookmarks = WYSIJA::get('bookmarks', 'helper');
1052
- $bookmarks = $hBookmarks->getAllByIconset('medium', '02');
1053
-
1054
- // sample data for regular newsletter
1055
- $newwjdata = array(
1056
- 'version' => WYSIJA::get_version(),
1057
- 'header' => array(
1058
- 'text' => null,
1059
- 'image' => array(
1060
- // 'src' => WYSIJA_EDITOR_IMG.'default-newsletter/newsletter/header.png',
1061
- 'src' => WYSIJA_EDITOR_IMG.'transparent.png',
1062
- 'width' => 600,
1063
- 'height' => 86,
1064
- 'alignment' => 'center',
1065
- 'static' => true
1066
- ),
1067
- 'alignment' => 'center',
1068
- 'static' => true,
1069
- 'type' => 'header'
1070
- ),
1071
- 'body' => array(
1072
- 'block-1' => array(
1073
- 'text' => array(
1074
- 'value' => '<h2><strong>'.__('Step 1:', WYSIJA).'</strong> '.__('hey, click on this text!', WYSIJA).'</h2>'.'<p>'.__('To edit, simply click on this block of text.', WYSIJA).'</p>'
1075
- ),
1076
- 'image' => null,
1077
- 'alignment' => 'left',
1078
- 'static' => false,
1079
- 'position' => 1,
1080
- 'type' => 'content'
1081
- ),
1082
- 'block-2' => array_merge(array(
1083
- 'position' => 2,
1084
- 'type' => 'divider'
1085
- ), $defaultDivider
1086
- ),
1087
- 'block-3' => array(
1088
- 'text' => array(
1089
- 'value' => '<h2><strong>'.__('Step 2:', WYSIJA).'</strong> '.__('play with this image', WYSIJA).'</h2>'
1090
- ),
1091
- 'image' => null,
1092
- 'alignment' => 'left',
1093
- 'static' => false,
1094
- 'position' => 3,
1095
- 'type' => 'content'
1096
- ),
1097
- 'block-4' => array(
1098
- 'text' => array(
1099
- 'value' => '<p>'.__('Position your mouse over the image to the left.', WYSIJA).'</p>'
1100
- ),
1101
- 'image' => array(
1102
- 'src' => WYSIJA_EDITOR_IMG.'default-newsletter/newsletter/pigeon.png',
1103
- 'width' => 281,
1104
- 'height' => 190,
1105
- 'alignment' => 'left',
1106
- 'static' => false
1107
- ),
1108
- 'alignment' => 'left',
1109
- 'static' => false,
1110
- 'position' => 4,
1111
- 'type' => 'content'
1112
- ),
1113
- 'block-5' => array_merge(array(
1114
- 'position' => 5,
1115
- 'type' => 'divider'
1116
- ), $defaultDivider
1117
- ),
1118
- 'block-6' => array(
1119
- 'text' => array(
1120
- 'value' => '<h2><strong>'.__('Step 3:', WYSIJA).'</strong> '.__('drop content here', WYSIJA).'</h2>'.
1121
- '<p>'.sprintf(__('Drag and drop %1$stext, posts, dividers.%2$s Look on the right!', WYSIJA), '<strong>', '</strong>').'</p>'.
1122
- '<p>'.sprintf(__('You can even %1$ssocial bookmarks%2$s like these:', WYSIJA), '<strong>', '</strong>').'</p>'
1123
- ),
1124
- 'image' => null,
1125
- 'alignment' => 'left',
1126
- 'static' => false,
1127
- 'position' => 6,
1128
- 'type' => 'content'
1129
- ),
1130
- 'block-7' => array(
1131
- 'width' => 184,
1132
- 'alignment' => 'center',
1133
- 'items' => array(
1134
- array_merge(array(
1135
- 'url' => 'http://www.facebook.com/wysija',
1136
- 'alt' => 'Facebook',
1137
- 'cellWidth' => 61,
1138
- 'cellHeight' => 32
1139
- ), $bookmarks['facebook']),
1140
- array_merge(array(
1141
- 'url' => 'http://www.twitter.com/wysija',
1142
- 'alt' => 'Twitter',
1143
- 'cellWidth' => 61,
1144
- 'cellHeight' => 32
1145
- ), $bookmarks['twitter']),
1146
- array_merge(array(
1147
- 'url' => 'https://plus.google.com/104749849451537343615',
1148
- 'alt' => 'Google',
1149
- 'cellWidth' => 61,
1150
- 'cellHeight' => 32
1151
- ), $bookmarks['google'])
1152
- ),
1153
- 'position' => 7,
1154
- 'type' => 'gallery'
1155
- ),
1156
- 'block-8' => array_merge(array(
1157
- 'position' => 8,
1158
- 'type' => 'divider'
1159
- ), $defaultDivider
1160
- ),
1161
- 'block-9' => array(
1162
- 'text' => array(
1163
- 'value' => '<h2><strong>'.__('Step 4:', WYSIJA).'</strong> '.__('and the footer?', WYSIJA).'</h2>'.
1164
- '<p>'.sprintf(__('Change the footer\'s content in Wysija\'s %1$sSettings%2$s page.', WYSIJA), '<strong>', '</strong>').'</p>'
1165
- ),
1166
- 'image' => null,
1167
- 'alignment' => 'left',
1168
- 'static' => false,
1169
- 'position' => 9,
1170
- 'type' => 'content'
1171
- )
1172
- ),
1173
- 'footer' => array(
1174
- 'text' => NULL,
1175
- 'image' => array(
1176
- // 'src' => WYSIJA_EDITOR_IMG.'default-newsletter/newsletter/footer.png',
1177
- 'src' => WYSIJA_EDITOR_IMG.'transparent.png',
1178
- 'width' => 600,
1179
- 'height' => 86,
1180
- 'alignment' => 'center',
1181
- 'static' => true,
1182
- ),
1183
- 'alignment' => 'center',
1184
- 'static' => true,
1185
- 'type' => 'footer'
1186
- )
1187
- );
1188
- }
1189
-
1190
- // set default styles
1191
- $helper_engine = WYSIJA::get('wj_engine', 'helper');
1192
- $styles = $helper_engine->getDefaultStyles();
1193
-
1194
- $model_config = WYSIJA::get('config', 'model');
1195
- $default_theme = $model_config->getValue('newsletter_default_theme', 'default');
1196
-
1197
- $helper_themes = WYSIJA::get('themes', 'helper');
1198
- $theme_data = $helper_themes->getData($default_theme);
1199
-
1200
- if($theme_data['header'] !== null) {
1201
- $newwjdata['header'] = $theme_data['header'];
1202
- }
1203
- if($theme_data['footer'] !== null) {
1204
- $newwjdata['footer'] = $theme_data['footer'];
1205
- }
1206
- // end - set default styles
1207
-
1208
- $emaildata['wj_data'] = base64_encode(serialize($newwjdata));
1209
- $emaildata['wj_styles'] = base64_encode(serialize($styles));
1210
-
1211
- $email_id=$data['email']['email_id']=$modelEmail->insert($emaildata);
1212
-
1213
- $this->notice(__('Newsletter successfully created.',WYSIJA));
1214
- }
1215
-
1216
- $this->_saveLists($campaign_id,true);
1217
-
1218
- if(isset($_REQUEST['return'])) $this->redirect();
1219
- else {
1220
- $this->redirect('admin.php?page=wysija_campaigns&action=editTemplate&id='.$email_id);
1221
- }
1222
- }
1223
-
1224
- function saveemail(){
1225
- $this->redirectAfterSave=false;
1226
- //$this->requireSecurity();
1227
- $modelEmail=WYSIJA::get("email","model");
1228
- $modelEmail->fieldValid=false;
1229
- $emaildataarr=$modelEmail->getOne(array('email_id'=>$_REQUEST['id']));
1230
-
1231
- if(isset($_REQUEST['save-reactivate'])){
1232
- //if the button save and reactivate has been clicked then we reactivate and redirect to the newsletter page
1233
- $dataEmail['status']=99;
1234
- $_REQUEST['return']=1;
1235
- }
1236
-
1237
- if(isset($_REQUEST['return'])) $this->redirect();
1238
- else {
1239
- $this->redirect('admin.php?page=wysija_campaigns&action=editDetails&id='.$emaildataarr['email_id']);
1240
- }
1241
- }
1242
-
1243
-
1244
- function savelast(){
1245
- $this->redirectAfterSave=false;
1246
- $post_notification=false;
1247
- $this->requireSecurity();
1248
-
1249
- if(!isset($_POST['wysija']['email']['from_name'])|| !isset($_POST['wysija']['email']['from_email']) || !isset($_POST['wysija']['email']['replyto_name']) || !isset($_POST['wysija']['email']['replyto_email'])){
1250
- $this->error(__('Information is missing.',WYSIJA));
1251
- return $this->editDetails();
1252
- }
1253
- if(isset($_REQUEST['wysija']['email']['params']['googletrackingcode']) && $_REQUEST['wysija']['email']['params']['googletrackingcode'] &&
1254
- (!is_string($_REQUEST['wysija']['email']['params']['googletrackingcode'])
1255
- OR
1256
- preg_match('#[^a-z0-9_-\s]#i',$_REQUEST['wysija']['email']['params']['googletrackingcode']) !== 0 )){
1257
- //force to simple text
1258
- $_REQUEST['wysija']['email']['params']['googletrackingcode']=preg_replace('#[^a-z0-9_-\s]#i', '_',$_REQUEST['wysija']['email']['params']['googletrackingcode']);
1259
- $this->error(__('The Google Campaign name needs to be only letters, number, spaces and hyphens. We\'ll improve this in the future!',WYSIJA),1);
1260
- return $this->editDetails();
1261
- }
1262
-
1263
- $update_email=array(
1264
- 'email_id'=>$_POST['wysija']['email']['email_id'],
1265
- 'from_name'=>$_POST['wysija']['email']['from_name'],
1266
- 'from_email'=>$_POST['wysija']['email']['from_email'],
1267
- 'replyto_name'=>$_POST['wysija']['email']['replyto_name'],
1268
- 'replyto_email'=>$_POST['wysija']['email']['replyto_email'],
1269
- 'subject'=>$_POST['wysija']['email']['subject'],
1270
- );
1271
- $model_email=WYSIJA::get('email','model');
1272
- if(isset($_POST['wysija']['email']['params'])) $update_email['params']=$_POST['wysija']['email']['params'];
1273
-
1274
- //insert into campaigns lists
1275
- $this->_saveLists($_POST['wysija']['campaign']['campaign_id']);
1276
- $email_data=$model_email->getOne($_POST['wysija']['email']['email_id']);
1277
-
1278
- // if we just save the draf we don't go through the big sending process setup
1279
- if(isset($_POST['submit-draft']) || isset($_POST['submit-pause']) || (isset($_REQUEST['wj_redir']) && $_REQUEST['wj_redir']=='savelastback')){
1280
- if(isset($_POST['wysija']['email']['params']['schedule']['isscheduled'])) $this->notice(__('Newsletter has been scheduled.',WYSIJA));
1281
- else $this->notice(__('Newsletter has been saved as a draft.',WYSIJA));
1282
- }else{
1283
- // we update the param attribute with what's has been posted
1284
- foreach($update_email as $ki =>$vi) {
1285
- if($ki=='params'){
1286
- foreach($vi as $parake=>$paraval){
1287
- $email_data['params'][$parake]=$paraval;
1288
- }
1289
- $update_email[$ki]=$email_data[$ki];
1290
- }else $email_data[$ki]=$vi;
1291
- }
1292
-
1293
- // if the checkbox to ignore retroactivity is here we just tell the class
1294
- if(isset($_POST['wysija']['email']['ignore_subscribers'])){
1295
- $model_email->retro_active_autoresponders=false;
1296
- }
1297
-
1298
- // activate or send the email depending on the typ
1299
- $model_email->send_activate($email_data);
1300
- }
1301
-
1302
- // update email
1303
- $update_email['type']=$email_data['type'];
1304
-
1305
- if($post_notification){
1306
- $helper_autonews=WYSIJA::get('autonews','helper');
1307
- $update_email['params']['autonl']['nextSend']=$helper_autonews->getNextSend($update_email);
1308
- }
1309
-
1310
- $model_email->reset();
1311
- $model_email->columns['modified_at']['autoup']=1;
1312
-
1313
- // update some fields of the email
1314
- $model_email->update($update_email);
1315
-
1316
- // update the campaign subject which ispretty much useless but good to keep in sync with the email
1317
- $model_campaign=WYSIJA::get('campaign','model');
1318
- $model_campaign->reset();
1319
- $update_campaign=array('campaign_id'=>$_REQUEST['id'],'name'=>$_POST['wysija']['email']['subject']);
1320
- $model_campaign->update($update_campaign);
1321
-
1322
- if(isset($_REQUEST['wj_redir']) && $_REQUEST['wj_redir']=='savelastback'){
1323
- return $this->redirect('admin.php?page=wysija_campaigns&action=editTemplate&id='.$_POST['wysija']['email']['email_id']);
1324
- } else return $this->redirect();
1325
- }
1326
-
1327
-
1328
- function _saveLists($campaignId,$flagup=false){
1329
- //record the list that we have in that campaign
1330
- $modelCampL=WYSIJA::get('campaign_list','model');
1331
- if($flagup || (int)$campaignId>0){
1332
- $modelCampL->delete(array('equal'=>array('campaign_id'=>$campaignId)));
1333
- $modelCampL->reset();
1334
- }
1335
-
1336
- if(isset($_POST['wysija']['campaign_list']['list_id'])){
1337
- //$modelCampL=WYSIJA::get("campaign_list","model");
1338
- foreach($_POST['wysija']['campaign_list']['list_id'] as $listid){
1339
- $modelCampL->insert(array('campaign_id'=>$campaignId,"list_id"=>$listid));
1340
- }
1341
- }
1342
- }
1343
-
1344
-
1345
- function _addLinkFilter($status,$type='status'){
1346
- switch($type){
1347
- case 'status':
1348
- switch($status){
1349
- case 'draft':
1350
- $this->filters['equal']=array('status'=>0);
1351
- break;
1352
- case 'sending':
1353
- $this->filters['equal']=array('status'=>99);
1354
- break;
1355
- case 'sent':
1356
- $this->filters['equal']=array('status'=>2);
1357
- break;
1358
- case 'paused':
1359
- $this->filters['equal']=array('status'=>-1);
1360
- break;
1361
- case 'scheduled':
1362
- $this->filters['equal']=array('status'=>4);
1363
- break;
1364
- }
1365
- break;
1366
- case 'type':
1367
- switch($status){
1368
- case 'regular':
1369
- $this->filters['equal']=array('type'=>1);
1370
- break;
1371
- case 'autonl':
1372
- $this->filters['equal']=array('type'=>2);
1373
- break;
1374
- }
1375
- break;
1376
- }
1377
- }
1378
-
1379
- function defaultDisplay(){
1380
- $this->data['base_url'] = $this->base_url.'?'.http_build_query($_REQUEST); // saved filter
1381
- $this->title=__('Newsletters',WYSIJA);
1382
- $this->viewShow=$this->action='main';
1383
- $this->js[]='wysija-admin-list';
1384
- $this->jsTrans["selecmiss"]=__('Please select a newsletter.',WYSIJA);
1385
- $this->jsTrans['suredelete']=__('Delete this newsletter for ever?',WYSIJA);
1386
- $this->jsTrans['processqueue']=__('Sending batch of emails...',WYSIJA);
1387
- $this->jsTrans['viewnews']=__('View newsletter',WYSIJA);
1388
- $this->jsTrans['confirmpauseedit']=__('The newsletter will be deactivated, you will need to reactivate it once you\'re over editing it. Do you want to proceed?',WYSIJA);
1389
- //make sure that there is no late scheduled or automatic newsletter
1390
- $autoNL=WYSIJA::get('autonews','helper');
1391
- $autoNL->checkPostNotif();
1392
- $autoNL->checkScheduled();
1393
- $config=WYSIJA::get('config','model');
1394
- //get the filters
1395
- if(isset($_REQUEST['search']) && $_REQUEST['search']){
1396
- $this->filters['like']=array();
1397
- foreach($this->searchable as $field)
1398
- $this->filters['like'][$field]=$_REQUEST['search'];
1399
- }
1400
-
1401
- if(isset($_REQUEST['filter-list']) && $_REQUEST['filter-list']){
1402
- $this->filters['equal']=array('C.list_id'=>$_REQUEST['filter-list']);
1403
- }
1404
-
1405
- if(isset($_REQUEST['filter-date']) && $_REQUEST['filter-date']){
1406
- $this->filters['greater_eq']=array('created_at'=>$_REQUEST['filter-date']);
1407
- $this->filters['less_eq']=array('created_at'=>strtotime('+1 month',$_REQUEST['filter-date']));
1408
- }
1409
-
1410
- $this->filters['is'] = array('type'=>'IS NOT NULL');
1411
-
1412
-
1413
- if(isset($_REQUEST['link_filter']) && $_REQUEST['link_filter']){
1414
- $linkfilters=explode('-',$_REQUEST['link_filter']);
1415
-
1416
- if(count($linkfilters)>1){
1417
- $this->_addLinkFilter($linkfilters[1],$linkfilters[0]);
1418
- }else{
1419
- $this->_addLinkFilter($_REQUEST['link_filter']);
1420
- }
1421
- }
1422
-
1423
- $this->modelObj->noCheck=true;
1424
-
1425
- // 0 - counting request
1426
- $queryCmmonStart="SELECT count(distinct A.campaign_id) as campaigns FROM `[wysija]".$this->modelObj->table_name."` as A";
1427
- $queryCmmonStart.=' LEFT JOIN `[wysija]email` as B on A.campaign_id=B.campaign_id';
1428
- $queryCmmonStart.=' LEFT JOIN `[wysija]campaign_list` as C on A.campaign_id=C.campaign_id';
1429
-
1430
- // all the counts query
1431
- $query='SELECT count(email_id) as campaigns, status FROM `[wysija]email` WHERE campaign_id > 0 GROUP BY status';
1432
-
1433
- $countss=$this->modelObj->query('get_res',$query,ARRAY_A);
1434
- $counts=array();
1435
- $total=0;
1436
-
1437
- foreach($countss as $count){
1438
- switch($count['status']){
1439
- case '0':
1440
- $type='draft';
1441
- break;
1442
- case '1':
1443
- case '3':
1444
- case '99':
1445
- $type='sending';
1446
- break;
1447
- case '2':
1448
- $type='sent';
1449
- break;
1450
- case '-1':
1451
- $type='paused';
1452
- break;
1453
- case '4':
1454
- $type='scheduled';
1455
- break;
1456
- }
1457
- $total=$total+$count['campaigns'];
1458
- $counts['status-'.$type]=$count['campaigns'];
1459
- }
1460
-
1461
-
1462
- $query='SELECT count(email_id) as campaigns, type FROM `[wysija]email` WHERE campaign_id > 0 GROUP BY type';
1463
- $countss=$this->modelObj->query('get_res',$query,ARRAY_A);
1464
- foreach($countss as $count){
1465
- switch($count['type']){
1466
- case '1':
1467
- $type='regular';
1468
- break;
1469
- case '2':
1470
- $type='autonl';
1471
- break;
1472
- }
1473
- $counts['type-'.$type]=$count['campaigns'];
1474
- }
1475
-
1476
- $counts['all']=$total;
1477
-
1478
- $this->modelObj->reset();
1479
- if($this->filters) $this->modelObj->setConditions($this->filters);
1480
-
1481
- // 1 - campaign request
1482
- $query='SELECT A.campaign_id, A.name as campaign_name, B.subject as name, A.description, B.params , B.type , B.number_opened,B.number_clicked,B.number_unsub,B.status,B.status,B.created_at,B.modified_at,B.sent_at,B.email_id FROM `[wysija]'.$this->modelObj->table_name.'` as A';
1483
- $query.=' LEFT JOIN `[wysija]email` as B on A.campaign_id=B.campaign_id';
1484
- $query.=' LEFT JOIN `[wysija]campaign_list` as C on A.campaign_id=C.campaign_id';
1485
- $queryFinal=$this->modelObj->makeWhere();
1486
-
1487
-
1488
- //campaign created the longest ago
1489
- $query2='SELECT MIN(B.created_at) as datemin FROM `[wysija]'.$this->modelObj->table_name.'` as A';
1490
- $query2.=' LEFT JOIN `[wysija]email` as B on A.campaign_id=B.campaign_id';
1491
- $query2.=' LEFT JOIN `[wysija]campaign_list` as C on A.campaign_id=C.campaign_id';
1492
- $queryFinal2=$this->modelObj->makeWhere();
1493
-
1494
- //without filter we already have the total number of campaigns
1495
-
1496
- if($this->filters) $this->modelObj->countRows=$this->modelObj->count($queryCmmonStart.$queryFinal,'campaigns');
1497
- else $this->modelObj->countRows=$counts['all'];
1498
-
1499
- $orderby=' ORDER BY ';
1500
-
1501
- if(isset($_REQUEST['orderby'])){
1502
- if(!is_string($_REQUEST['orderby']) OR preg_match('|[^a-z0-9#_.-]|i',$_REQUEST['orderby']) !== 0 ){
1503
- $_REQUEST['orderby']='';
1504
- }
1505
- if(!in_array(strtoupper($_REQUEST['ordert']),array('DESC','ASC'))) $_REQUEST['ordert'] = 'DESC';
1506
- $orderby.=$_REQUEST['orderby'].' '.$_REQUEST['ordert'];
1507
- }else{
1508
- $orderby=' ORDER BY ';
1509
- $orderby.='FIELD(B.status, 99,3,1,0,2), ';
1510
- $orderby.='B.status desc, ';
1511
- $orderby.='B.modified_at desc, ';
1512
- $orderby.='B.sent_at desc, ';
1513
- $orderby.='B.type desc, ';
1514
-
1515
- $orderby.='A.'.$this->modelObj->getPk().' desc';
1516
- }
1517
-
1518
-
1519
- //$this->data['campaigns']=$this->modelObj->getResults($query.$queryFinal." GROUP BY A.campaign_id".$orderby.$this->modelObj->setLimit());
1520
- $this->data['campaigns']=$this->modelObj->getResults($query.$queryFinal.' GROUP BY B.email_id'.$orderby.$this->modelObj->setLimit());
1521
- //dbg($this->data['campaigns']);
1522
- $emailids=array();
1523
- foreach($this->data['campaigns'] as $emailcamp){
1524
- if(in_array($emailcamp['status'], array(1,3,99))) $emailids[]=$emailcamp['email_id'];
1525
- }
1526
- $modelQ=WYSIJA::get('queue','model');
1527
- $modelQ->setConditions(array("email_id"=>$emailids));
1528
- $modelQ->groupBy('email_id');
1529
- $queue=$modelQ->count();
1530
- if($queue){
1531
- $this->viewObj->queuedemails=$queue;
1532
- }
1533
-
1534
- $this->modelObj->reset();
1535
-
1536
- $this->data['datemin']=$this->modelObj->query('get_row',$query2.$queryFinal2);
1537
- $this->modelObj->reset();
1538
-
1539
- //make a loop from the first created to now and increment an array of months
1540
- $now=time();
1541
- $this->data['dates']=array();
1542
-
1543
- if((int)$this->data['datemin']['datemin']>1){
1544
- setlocale(LC_TIME, 'en_US');
1545
- $firstdayof=getdate($this->data['datemin']['datemin']);
1546
-
1547
- $formtlettres="1 ".date("F",$this->data['datemin']['datemin'])." ".date("Y",$this->data['datemin']['datemin']) ;
1548
- $monthstart=strtotime($formtlettres);
1549
-
1550
- if($monthstart>0){
1551
- for($i=$monthstart;$i<$now;$i=strtotime('+1 month',$i)){
1552
- $this->data['dates'][$i]=date_i18n('F Y',$i);//date('F Y',$i);
1553
- }
1554
- }
1555
-
1556
- }
1557
-
1558
- //make the data object for the listing view*/
1559
- $modelList=WYSIJA::get('list','model');
1560
-
1561
- // 2 - list request */
1562
- $query='SELECT A.list_id, A.name,A.is_enabled, count( B.campaign_id ) AS users FROM `[wysija]'.$modelList->table_name.'` as A';
1563
- $query.=' LEFT JOIN `[wysija]campaign_list` as B on A.list_id = B.list_id';
1564
- $query.=' GROUP BY A.list_id';
1565
- $listsDB=$modelList->getResults($query);
1566
-
1567
- $lists=array();
1568
- foreach($listsDB as $listobj){
1569
- $lists[$listobj["list_id"]]=$listobj;
1570
- }
1571
-
1572
- $listsDB=null;
1573
-
1574
- $campaign_ids_sent=$campaign_ids=array();
1575
- foreach($this->data['campaigns'] as &$campaign){
1576
- $campaign_ids[]=$campaign['campaign_id'];
1577
- $modelEmail=WYSIJA::get('email','model');
1578
- $modelEmail->getParams($campaign);
1579
- if(in_array((int)$campaign['status'],array(-1,1,2,3,99))) $campaign_ids_sent[]=$campaign['campaign_id'];
1580
- }
1581
-
1582
- // 3 - campaign_list request & count request for queue */
1583
- if($campaign_ids){
1584
- $modeluList=WYSIJA::get('campaign_list','model');
1585
- $userlists=$modeluList->get(array('list_id','campaign_id'),array('campaign_id'=>$campaign_ids));
1586
-
1587
- if($campaign_ids_sent){
1588
- $modeluList=WYSIJA::get("email_user_stat","model");
1589
- $statstotal=$modeluList->getResults("SELECT COUNT(A.user_id) as count,B.email_id FROM `[wysija]queue` as A
1590
- JOIN `[wysija]email` as B on A.email_id=B.email_id
1591
- WHERE B.campaign_id IN (".implode(",",$campaign_ids_sent).") group by B.email_id");
1592
-
1593
- $senttotalgroupedby=$modeluList->getResults("SELECT COUNT(A.user_id) as count,B.campaign_id,B.email_id,B.type,B.status,A.status as statususer FROM `[wysija]".$modeluList->table_name."` as A
1594
- JOIN `[wysija]email` as B on A.email_id=B.email_id
1595
- WHERE B.campaign_id IN (".implode(",",$campaign_ids_sent).") group by A.status,B.email_id");//,A.status
1596
-
1597
-
1598
- $updateEmail=array();
1599
- $columnnamestatus=array(0=>"number_sent",1=>"number_opened",2=>"number_clicked",3=>"number_unsub",-1=>"number_bounce");
1600
- foreach($senttotalgroupedby as $sentbystatus){
1601
- if($sentbystatus['statususer']!="-2") $updateEmail[$sentbystatus['email_id']][$columnnamestatus[$sentbystatus['statususer']]]=$sentbystatus['count'];
1602
- if(isset($senttotal[$sentbystatus['email_id']])){
1603
- $senttotal[$sentbystatus['email_id']]['count']=(int)$senttotal[$sentbystatus['email_id']]['count']+(int)$sentbystatus['count'];
1604
- }else{
1605
- unset($sentbystatus['statususer']);
1606
- $senttotal[$sentbystatus['email_id']]=$sentbystatus;
1607
- }
1608
- }
1609
-
1610
- $modelEmail=WYSIJA::get('email','model');
1611
-
1612
- foreach($updateEmail as $emailid=>$update){
1613
-
1614
- foreach($columnnamestatus as $v){
1615
- if(!isset($update[$v])) $update[$v]=0;
1616
- }
1617
-
1618
- $modelEmail->update($update,array('email_id'=>$emailid));
1619
- $modelEmail->reset();
1620
- }
1621
-
1622
-
1623
- /**/
1624
- $modelC=WYSIJA::get('config','model');
1625
- $running=false;
1626
-
1627
- $is_multisite=is_multisite();
1628
-
1629
- //$is_multisite=true;//PROD comment that line
1630
- if($is_multisite && $modelC->getValue('sending_method')=='network'){
1631
- $sending_emails_each=$modelC->getValue('ms_sending_emails_each');
1632
- }else{
1633
- $sending_emails_each=$modelC->getValue('sending_emails_each');
1634
- }
1635
-
1636
- if($modelC->getValue('cron_manual')){
1637
- $formsHelp=WYSIJA::get('forms','helper');
1638
- $queue_frequency=$formsHelp->eachValuesSec[$sending_emails_each];
1639
- $queue_scheduled=WYSIJA::get_cron_schedule('queue');
1640
-
1641
- $next_scheduled_queue=$queue_scheduled['next_schedule'];
1642
- $running=$queue_scheduled['running'];
1643
-
1644
- if($running){
1645
- $helperToolbox=WYSIJA::get('toolbox','helper');
1646
- $running=time()-$running;
1647
- $running=$helperToolbox->duration($running,true,4);
1648
-
1649
- }
1650
- }else{
1651
- $schedules=wp_get_schedules();
1652
- $queue_frequency=$schedules[wp_get_schedule('wysija_cron_queue')]['interval'];
1653
- $next_scheduled_queue=wp_next_scheduled('wysija_cron_queue');
1654
- }
1655
-
1656
-
1657
-
1658
- $status_sent_complete=array();
1659
- if(isset($senttotal) && $senttotal){
1660
- foreach($senttotal as $sentot){
1661
- if($sentot){
1662
- $this->data['sent'][$sentot['email_id']]['total']=$sentot['count'];
1663
- $this->data['sent'][$sentot['email_id']]['to']=$sentot['count'];
1664
- }else{
1665
- $this->data['sent'][$sentot['email_id']]['total']=$this->data['sent'][$sentot['email_id']]['to']=0;
1666
- }
1667
- $this->data['sent'][$sentot['email_id']]['status']=$sentot['status'];
1668
- $this->data['sent'][$sentot['email_id']]['type']=$sentot['type'];
1669
- $this->data['sent'][$sentot['email_id']]['left']= (int)$this->data['sent'][$sentot['email_id']]['total'] - (int)$this->data['sent'][$sentot['email_id']]['to'];
1670
- }
1671
- }
1672
-
1673
- foreach($statstotal as $sentot){
1674
- if(!isset($this->data['sent'][$sentot['email_id']])) {
1675
- $this->data['sent'][$sentot['email_id']]['total']=0;
1676
- $this->data['sent'][$sentot['email_id']]['to']=0;
1677
- }
1678
- $this->data['sent'][$sentot['email_id']]['total']=$this->data['sent'][$sentot['email_id']]['total']+$sentot['count'];
1679
- $this->data['sent'][$sentot['email_id']]['left']= (int)$this->data['sent'][$sentot['email_id']]['total'] - (int)$this->data['sent'][$sentot['email_id']]['to'];
1680
- }
1681
-
1682
-
1683
- $is_multisite=is_multisite();
1684
-
1685
- //$is_multisite=true;//PROD comment that line
1686
- if($is_multisite && $modelC->getValue('sending_method')=='network'){
1687
- $sending_emails_number=$modelC->getValue('ms_sending_emails_number');
1688
- }else{
1689
- $sending_emails_number=$modelC->getValue('sending_emails_number');
1690
- }
1691
-
1692
- if(isset($this->data['sent'])){
1693
- foreach($this->data['sent'] as $key => $camp){
1694
- if($this->data['sent'][$key]['left']>0){
1695
- $cronsneeded=ceil($this->data['sent'][$key]['left']/$sending_emails_number);
1696
- $this->data['sent'][$key]['remaining_time']=$cronsneeded *$queue_frequency;
1697
- $this->data['sent'][$key]['running_for']=$running;
1698
- $this->data['sent'][$key]['next_batch']=$next_scheduled_queue-time();
1699
- $this->data['sent'][$key]['remaining_time']=$this->data['sent'][$key]['remaining_time']-($queue_frequency)+$this->data['sent'][$key]['next_batch'];
1700
- }else{
1701
- if( (in_array($this->data['sent'][$key]['status'], array(1,3,99))) && $this->data['sent'][$key]['type']==1) $status_sent_complete[]=$key;
1702
- }
1703
- }
1704
- }
1705
-
1706
-
1707
- /* status update to sent for the one that are sent*/
1708
- if(count($status_sent_complete)>0){
1709
- $modelEmail=WYSIJA::get('email','model');
1710
- $modelEmail->noCheck=true;
1711
- $modelEmail->reset();
1712
- $modelEmail->update(array('status'=>2),array('equal'=>array('email_id'=>$status_sent_complete)));
1713
- }
1714
- }
1715
- }
1716
-
1717
- $this->data['lists']=$lists;
1718
- $this->data['counts']=array_reverse($counts);
1719
-
1720
- /* regrouping all the data in the same array */
1721
- foreach($this->data['campaigns'] as $keysus=>&$campaign){
1722
- /* default key while we don't have the data*/
1723
- //TODO add data for stats about emails opened clicked etc
1724
- $campaign["emails"]=0;
1725
- $campaign["opened"]=0;
1726
- $campaign["clicked"]=0;
1727
-
1728
- if($userlists){
1729
- foreach($userlists as $key=>$userlist){
1730
- if($campaign["campaign_id"]==$userlist["campaign_id"] && isset($lists[$userlist["list_id"]])){
1731
- if(!isset($campaign["lists"]) ) $campaign["lists"]=$lists[$userlist["list_id"]]["name"];
1732
- else $campaign["lists"].=", ".$lists[$userlist["list_id"]]["name"];
1733
- }
1734
- }
1735
- }
1736
- if(isset($campaign["lists"]) && !$campaign["lists"]) unset($campaign["lists"]);
1737
-
1738
- if(((isset($campaign['params']['schedule']['isscheduled'])
1739
- ||
1740
- ($campaign['type']==2 && isset($campaign['params']['autonl']['event']) && in_array($campaign['params']['autonl']['event'],array('new-articles'/*,'subs-2-nl'*/)))
1741
- )
1742
- && $campaign['status']!=2 && !isset($campaign["lists"]))
1743
- || ($campaign['type']==2 && isset($campaign['params']['autonl']['event']) && in_array($campaign['params']['autonl']['event'],array('subs-2-nl')) && $campaign['status']!=2 && (!isset($campaign['params']['autonl']['subscribetolist']) || !isset($lists[$campaign['params']['autonl']['subscribetolist']]) ))
1744
- ){
1745
- $campaign['classRow']=" listmissing ";
1746
- $campaign['msgListEdit']='<strong>'.__('The list has been deleted.',WYSIJA).'</strong>';
1747
- $campaign['msgSendSuspended']='<strong>'.__('Sending suspended.',WYSIJA).'</strong>';
1748
- }
1749
-
1750
-
1751
- }
1752
-
1753
- $this->dataAutoNl();
1754
- if(!$this->data['campaigns']){
1755
- $this->notice(__('There are no newsletters.',WYSIJA));
1756
- }
1757
-
1758
- }
1759
-
1760
-
1761
-
1762
- function setviewStatsfilter(){
1763
- /*get the filters*/
1764
- $this->searchable=array("email", "firstname", "lastname");
1765
- $this->filters=array();
1766
- if(isset($_REQUEST['search']) && $_REQUEST['search']){
1767
- $this->filters["like"]=array();
1768
- foreach($this->searchable as $field)
1769
- $this->filters["like"][$field]=$_REQUEST['search'];
1770
- }
1771
- $this->tableQuery='email_user_stat';
1772
- $this->statusemail='B.status as umstatus';
1773
- if(isset($_REQUEST['link_filter']) && $_REQUEST['link_filter']){
1774
- switch($_REQUEST['link_filter']){
1775
- case 'inqueue':
1776
- $this->tableQuery='queue';
1777
- $this->statusemail='-2 as umstatus';
1778
- break;
1779
- case 'sent':
1780
- $this->filters['equal']=array('B.status'=>0);
1781
- break;
1782
- case 'bounced':
1783
- $this->filters['equal']=array('B.status'=>-1);
1784
- break;
1785
- case 'opened':
1786
- $this->filters['equal']=array('B.status'=>1);
1787
- break;
1788
- case 'clicked':
1789
- $this->filters['equal']=array('B.status'=>2);
1790
- break;
1791
- case 'unsubscribe':
1792
- $this->filters['equal']=array('B.status'=>3);
1793
- break;
1794
- case 'notsent':
1795
- $this->filters['equal']=array('B.status'=>-2);
1796
- break;
1797
- }
1798
- }
1799
- // filter by url id
1800
- if(isset($_REQUEST['url_id']) && (int)$_REQUEST['url_id'] > 0){
1801
- $this->tableQuery='email_user_url';
1802
- $this->filters['equal']=array('B.url_id'=>(int)$_REQUEST['url_id']);
1803
- $this->statusemail = '2 as umstatus'; //by default, when filter by url_id, all subscribers had clicked
1804
- }
1805
- }
1806
-
1807
- function viewstats(){
1808
- $this->js[]='wysija-admin-list';
1809
- $this->js[]='wysija-charts';
1810
- $this->viewShow='viewstats';
1811
-
1812
- $this->modelObj=WYSIJA::get("email","model");
1813
- $this->modelObj->limitON=false;
1814
-
1815
- $emailObj=$this->modelObj->getOne(false,array("email_id"=>$_REQUEST['id']));
1816
- $this->viewObj->model=$this->modelObj;
1817
- $this->viewObj->namecampaign=$emailObj['subject'];
1818
- $this->viewObj->title=sprintf(__('Stats : %1$s',WYSIJA),$emailObj['subject']);
1819
-
1820
- $modelObjCamp=WYSIJA::get("campaign","model");
1821
- $limit_pp=false;
1822
- if(isset($modelObjCamp->limit_pp)) $limit_pp = $modelObjCamp->limit_pp;
1823
- $modelObjCamp->limitON=false;
1824
- $campaign=$modelObjCamp->getOne(false,array("campaign_id"=>$emailObj['campaign_id']));
1825
-
1826
-
1827
- $this->setviewStatsfilter();
1828
-
1829
- $this->modelObj->reset();
1830
- $this->modelObj->noCheck=true;
1831
-
1832
- /* 0 - counting request */
1833
- $queryCmmonStart='SELECT count(distinct B.user_id) as users FROM `[wysija]user` as A';
1834
- $queryCmmonStart.=' LEFT JOIN `[wysija]'.$this->tableQuery.'` as B on A.user_id=B.user_id';
1835
-
1836
- /* all the counts query */
1837
- $query="SELECT count(user_id) as users, status FROM `[wysija]email_user_stat` as A
1838
- WHERE A.email_id=".$emailObj['email_id']." GROUP BY status";
1839
- $countss=$this->modelObj->query("get_res",$query,ARRAY_A);
1840
-
1841
- /*we also count what is in the queue */
1842
- $query="SELECT count(user_id) as users FROM `[wysija]queue` as A
1843
- WHERE A.email_id=".$emailObj['email_id'];
1844
- $countss[-2]['status']=-3;
1845
- $countss[-2]['users']=$this->modelObj->count($query,'users');
1846
-
1847
- $counts=array();
1848
- $truetotal=$total=0;
1849
-
1850
- foreach($countss as $count){
1851
- switch($count['status']){
1852
- case "-3":
1853
- $type='inqueue';
1854
- break;
1855
- case "-2":
1856
- $type='notsent';
1857
- break;
1858
- case "-1":
1859
- $type='bounced';
1860
- break;
1861
- case "0":
1862
- $type='sent';
1863
- break;
1864
- case "1":
1865
- $type='opened';
1866
- break;
1867
- case "2":
1868
- $type='clicked';
1869
- break;
1870
- case "3":
1871
- $type='unsubscribe';
1872
- break;
1873
- }
1874
- if($count['status']!="-2") $total=$total+$count['users'];
1875
- $truetotal=$truetotal+$count['users'];
1876
- $counts[$type]=$count['users'];
1877
- }
1878
-
1879
- $counts['allsent']=$total;
1880
- $counts['all']=$truetotal;
1881
-
1882
- $this->modelObj->reset();
1883
- $this->filters['equal']["B.email_id"]=$emailObj['email_id'];
1884
-
1885
- $this->modelObj->noCheck=true;
1886
- if($this->filters) $this->modelObj->setConditions($this->filters);
1887
-
1888
- //$this->modelObj->setConditions(array("equal"=>array("B.email_id"=>$emailObj['email_id'])));
1889
-
1890
- /* 1 - subscriber request */
1891
- $query='SELECT A.user_id, A.firstname, A.lastname,A.status as ustatus,'.$this->statusemail.' , A.email, B.* FROM `[wysija]user` as A';
1892
- $query.=' LEFT JOIN `[wysija]'.$this->tableQuery.'` as B on A.user_id=B.user_id';
1893
- $queryFinal=$this->modelObj->makeWhere();
1894
-
1895
- /* without filter we already have the total number of subscribers */
1896
- if($this->filters) $this->modelObj->countRows=$this->modelObj->count($queryCmmonStart.$queryFinal,'users');
1897
- else $this->modelObj->countRows=$counts['all'];
1898
-
1899
- $orderby=" ORDER BY ";
1900
- /**
1901
- * Until now, we have
1902
- * - 3 possible values of $this->tableQuery (queue, email_user_url, email_user_stat), set by $this->setviewStatsfilter()
1903
- * - 2 possible values of $_REQUEST['orderby']
1904
- * => 3x2 = 6 cases
1905
- */
1906
- if(isset($_REQUEST['orderby'])){
1907
- switch ($this->tableQuery){
1908
- case 'email_user_url':
1909
- case 'email_user_stat':
1910
- $orderby .= 'B.'.$_REQUEST['orderby']." ".$_REQUEST['ordert'];
1911
- break;
1912
-
1913
- case 'queue':
1914
- default:
1915
- $orderby .= 'A.user_id DESC';
1916
- break;
1917
- }
1918
- }else{
1919
- switch ($this->tableQuery){
1920
- case 'email_user_url':
1921
- $orderby .= 'B.clicked_at DESC, B.number_clicked DESC'; // by default, sort by last clicked and biggest hit
1922
- break;
1923
-
1924
- case 'email_user_stat':
1925
- $orderby .= 'B.opened_at DESC, B.status DESC'; // by default, sort by last open and its staus value
1926
- break;
1927
-
1928
- case 'queue':
1929
- default:
1930
- $orderby .= 'A.user_id DESC';
1931
- break;
1932
- }
1933
- }
1934
- $this->data['tableQuery'] = $this->tableQuery;
1935
- $this->modelObj->limitON=true;
1936
- $this->data['subscribers']=$this->modelObj->getResults($query.$queryFinal." GROUP BY A.user_id".$orderby.$this->modelObj->setLimit(0,$limit_pp));
1937
- $this->modelObj->reset();
1938
-
1939
- /*make the data object for the listing view*/
1940
- $modelList=WYSIJA::get("list","model");
1941
-
1942
- /* 2 - list request */
1943
- $query="SELECT A.list_id, A.name,A.is_enabled, count( B.user_id ) AS users FROM `[wysija]".$modelList->table_name."` as A";
1944
- $query.=" LEFT JOIN `[wysija]user_list` as B on A.list_id = B.list_id";
1945
- $query.=" GROUP BY A.list_id";
1946
- $listsDB=$modelList->getResults($query);
1947
-
1948
- $lists=array();
1949
- foreach($listsDB as $listobj){
1950
- $lists[$listobj["list_id"]]=$listobj;
1951
- }
1952
-
1953
- $listsDB=null;
1954
-
1955
- $user_ids=array();
1956
- foreach($this->data['subscribers'] as $subscriber){
1957
- $user_ids[]=$subscriber['user_id'];
1958
- }
1959
-
1960
- /* 3 - user_list request */
1961
- if($user_ids){
1962
- $modeluList=WYSIJA::get("user_list","model");
1963
- $userlists=$modeluList->get(array("list_id","user_id"),array("user_id"=>$user_ids));
1964
- }
1965
-
1966
-
1967
- $this->data['lists']=$lists;
1968
- $this->data['counts']=array_reverse($counts);
1969
-
1970
- /* regrouping all the data in the same array */
1971
- foreach($this->data['subscribers'] as $keysus=>$subscriber){
1972
- /* default key while we don't have the data*/
1973
- //TODO add data for stats about emails opened clicked etc
1974
- $this->data['subscribers'][$keysus]["emails"]=0;
1975
- $this->data['subscribers'][$keysus]["opened"]=0;
1976
- $this->data['subscribers'][$keysus]["clicked"]=0;
1977
-
1978
- if($userlists){
1979
- foreach($userlists as $key=>$userlist){
1980
- if($subscriber["user_id"]==$userlist["user_id"] && isset($lists[$userlist["list_id"]])){
1981
- if(!isset($this->data['subscribers'][$keysus]["lists"]) ) $this->data['subscribers'][$keysus]["lists"]=$lists[$userlist["list_id"]]["name"];
1982
- else $this->data['subscribers'][$keysus]["lists"].=", ".$lists[$userlist["list_id"]]["name"];
1983
- }
1984
- }
1985
- }
1986
- }
1987
-
1988
-
1989
- /* we prepare the data to be pased to the charts script*/
1990
- //$this->data['charts']['title']=__('Statistics for campaign.',WYSIJA);
1991
- $this->data['charts']['title']=" ";
1992
- $this->data['charts']['stats']=array();
1993
- $keys=array(
1994
- 'opened'=>array('order'=>0),
1995
- 'bounced'=>array('order'=>1),
1996
- 'sent'=>array('order'=>2),
1997
- 'clicked'=>array('order'=>3),
1998
- 'unsubscribe'=>array('order'=>4),
1999
- 'notsent'=>array('order'=>5),
2000
- 'inqueue'=>array('order'=>6)
2001
- );
2002
-
2003
- foreach(array_reverse($counts) as $key=> $count){
2004
- if($key!="all" && $key!="allsent"){
2005
- if(isset($keys[$key]['name'])) $name=$keys[$key]['name'];
2006
- else $name=$this->viewObj->getTransStatusEmail($key);
2007
- if($count>0) $this->data['charts']['stats'][$keys[$key]['order']]=array("name"=>$name,"number"=>$count);
2008
- }
2009
- }
2010
-
2011
- $modelEUU=WYSIJA::get('email_user_url',"model");
2012
- $modelEUU->colCheck=false;
2013
- $modelEUU->setConditions(array("equal"=>array("A.email_id"=>$emailObj['email_id'])));
2014
- $query="SELECT count(A.user_id) as count,A.*,B.*,C.subject as name FROM `[wysija]".$modelEUU->table_name."` as A JOIN `[wysija]url` as B on A.url_id=B.url_id JOIN `[wysija]email` as C on C.email_id=A.email_id ";
2015
- $query.=$modelEUU->makeWhere();
2016
- $query.=" GROUP BY A.url_id ";
2017
- $query.=" ORDER BY count Desc";
2018
- $this->data['clicks']=$modelEUU->query("get_res",$query,ARRAY_A);
2019
-
2020
- foreach($this->data['clicks'] as $k => &$v){
2021
- $this->data['clicks'][$k]['name']="<strong>".sprintf(_n('%1$s click', '%1$s clicks', $v['count'],WYSIJA), $v['count'])."</strong> ";
2022
- $v['url']=urldecode(utf8_encode($v['url']));
2023
- }
2024
-
2025
- $this->data['email']=$emailObj;
2026
- $chartsencoded=base64_encode(json_encode($this->data['charts']));
2027
- wp_enqueue_script('wysija-admin-subscribers-edit-manual', WYSIJA_URL."js/admin-subscribers-edit-manual.php?data=".$chartsencoded, array( 'wysija-charts' ), true);
2028
-
2029
- if(!$this->data['subscribers']){
2030
- $this->notice(__("Your request can't retrieve any subscribers. Change your filters!",WYSIJA));
2031
- }
2032
- }
2033
-
2034
- function getListSubscriberQry($selectcolumns){
2035
- $this->modelObj=WYSIJA::get("email","model");
2036
- $this->emailObj=$this->modelObj->getOne(false,array('email_id' => $_REQUEST['id']));
2037
-
2038
- /* use the filter if there is */
2039
- $this->setviewStatsfilter();
2040
-
2041
- if($selectcolumns=="B.user_id"){
2042
- //unset($this->filters["like"]);
2043
- }
2044
-
2045
- $this->filters['equal']["B.email_id"]=$this->emailObj['email_id'];
2046
- $this->modelObj->noCheck=true;
2047
- if($this->filters) $this->modelObj->setConditions($this->filters);
2048
-
2049
- /* select insert all the subscribers from that campaign into user_list */
2050
- if($selectcolumns=="B.user_id"){
2051
- $query="SELECT $selectcolumns FROM `[wysija]".$this->tableQuery."` as B";
2052
- $query.=$this->modelObj->makeWhere();
2053
- }else{
2054
- $query="SELECT $selectcolumns FROM `[wysija]user` as A";
2055
- $query.=" LEFT JOIN `[wysija]".$this->tableQuery."` as B on A.user_id=B.user_id";
2056
- $query.=$this->modelObj->makeWhere();
2057
- }
2058
-
2059
- return $query;
2060
- }
2061
-
2062
- function createnewlist(){
2063
- /* get the email subject */
2064
- $emailModel = WYSIJA::get('email', 'model');
2065
- $email = $emailModel->getOne(array('subject'), array('email_id' => $_REQUEST['id']));
2066
-
2067
- $this->modelObj->reset();
2068
-
2069
- /* set the name of the new list*/
2070
- $prefix="";
2071
- if(isset($_REQUEST['link_filter'])) $prefix=' ('.$this->viewObj->getTransStatusEmail($_REQUEST['link_filter']).')';
2072
- $listname=sprintf(__('Segment of %1$s',WYSIJA), $email['subject'].$prefix);
2073
-
2074
- /*insert new list*/
2075
- $modelL=WYSIJA::get('list','model');
2076
- $listid=$modelL->insert(array('is_enabled'=>1,'name'=>$listname,'description'=>__('List created based on a newsletter segment.',WYSIJA)));
2077
-
2078
- /* get list of subscribers filtered or not */
2079
- $query=$this->getListSubscriberQry($listid.', A.user_id, '.time().', 0');
2080
-
2081
- $query2='INSERT INTO `[wysija]user_list` (`list_id`,`user_id`,`sub_date`,`unsub_date`) '.$query;
2082
-
2083
- $this->modelObj->query($query2);
2084
-
2085
- $this->notice(sprintf(__('A new list "%1$s" has been created out of this segment.',WYSIJA), $listname));
2086
- $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id='.$_REQUEST['id']);
2087
- }
2088
-
2089
- function unsubscribeall(){
2090
- //delete from user_lists where select from email_user_stat
2091
- $query=$this->getListSubscriberQry('B.user_id');
2092
- $query2="UPDATE `[wysija]user_list` where user_id IN ($query) AND list_id not IN(SELECT list_id from `[wysija]list` WHERE is_enabled<1)";
2093
- $this->modelObj->query($query2);
2094
-
2095
- //unsubscribe from user where select from email_user_stat
2096
- $query2="UPDATE `[wysija]user` set `status`=-1 where user_id IN ($query)";
2097
- $this->modelObj->query($query2);
2098
 
2099
- $this->notice(__('The segment has been unbsubscribed from all the lists.',WYSIJA));
2100
- $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id='.$_REQUEST['id']);
2101
- }
2102
 
 
 
 
 
 
 
2103
 
2104
- function sendconfirmation(){
2105
- //delete from user_lists where select from email_user_stat
2106
- $query=$this->getListSubscriberQry('B.user_id ');
2107
 
2108
- $user_ids=$this->modelObj->query('get_res',$query);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2109
 
2110
- $uids=array();
2111
- foreach($user_ids as $data){
2112
- $uids[]=$data['user_id'];
2113
- }
2114
 
2115
- $helperUser=WYSIJA::get('user','helper');
2116
- $helperUser->sendConfirmationEmail($uids);
2117
- $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id='.$_REQUEST['id']);
2118
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2119
 
 
 
 
2120
 
2121
- function removequeue(){
2122
- /* delete from queue where select from email_user_stat */
2123
- $query=$this->getListSubscriberQry('B.user_id');
2124
- $query2="DELETE FROM `[wysija]queue` where user_id IN ($query) AND email_id=".$this->emailObj['email_id'];
2125
- $this->modelObj->query($query2);
2126
 
2127
- $this->notice(__('The segment has been removed from the queue of this newsletter.',WYSIJA));
2128
- $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id='.$_REQUEST['id']);
2129
- }
 
2130
 
2131
- function export(){
2132
- /* select from email_user_stat left join user */
2133
- $query=$this->getListSubscriberQry('B.user_id');
2134
- $result=$this->modelObj->query('get_res',$query);
2135
- $user_ids=array();
2136
- foreach($result as $user) $user_ids[]=$user['user_id'];
2137
 
2138
- $fileHelp=WYSIJA::get('file','helper');
2139
- $tempfilename=$fileHelp->temp(implode(',',$user_ids),'export_userids','.txt');
 
 
 
2140
 
2141
- //$this->redirect("admin.php?page=wysija_campaigns&action=viewstats&id=".$_REQUEST['id']."&user_ids=".serialize($result));
2142
- $this->redirect('admin.php?page=wysija_subscribers&action=exportcampaign&camp_id='.$_REQUEST['id'].'&file_name='. base64_encode($tempfilename['path']));
2143
- }
2144
 
 
 
 
 
 
 
 
2145
 
 
 
2146
 
2147
- function unsubscribelist($data){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2148
 
2149
- $modelL=WYSIJA::get('list','model');
2150
- $list=$modelL->getOne(false,array('list_id'=>$data['listid']));
2151
- if($list['is_enabled']){
2152
- /* delete from user_lists where select from email_user_stat */
2153
- $query=$this->getListSubscriberQry("B.user_id");
2154
- $query2="DELETE FROM `[wysija]user_list` where user_id IN ($query) and list_id=".$data['listid'];
2155
- $this->modelObj->query($query2);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2156
 
2157
- $this->notice(sprintf(__('The segment has been unbsubscribed from the list "%1$s"',WYSIJA),$list['name']));
2158
- }else{
2159
- $this->notice(sprintf(__('The segment cannot be unbsubscribed from an [IMPORT] list.',WYSIJA),$list['name']));
2160
- }
 
 
 
2161
 
2162
- $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id='.$_REQUEST['id']);
2163
- }
2164
 
 
2165
 
 
 
2166
 
2167
- function articles(){
2168
- $this->iframeTabs=array('articles'=>__("Post Selection",WYSIJA));
2169
- $this->js[]='wysija-admin-ajax';
2170
- $this->js[]='wysija-base-script-64';
2171
 
2172
- $_GET['tab']='articles';
2173
- return $this->popupContent();
2174
- }
 
 
 
2175
 
2176
- function themeupload(){
2177
- $helperNumbers=WYSIJA::get('numbers','helper');
2178
- $bytes=$helperNumbers->get_max_file_upload();
2179
 
2180
- if(isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH']>$bytes['maxbytes']){
2181
- if(isset($_FILES['my-theme']['name']) && $_FILES['my-theme']['name']){
2182
- $filename=$_FILES['my-theme']['name'];
2183
- }else{
2184
- $filename="";
2185
- }
2186
-
2187
- $this->error(sprintf(__('Upload error, file %1$s is too large! (MAX:%2$s)',WYSIJA),$filename,$bytes['maxmegas']),true);
2188
- $this->redirect('admin.php?page=wysija_campaigns&action=themes');
2189
-
2190
- return false;
2191
- }
2192
-
2193
-
2194
- $ZipfileResult=trim(file_get_contents($_FILES['my-theme']['tmp_name']));
2195
-
2196
- $themesHelp=WYSIJA::get('themes','helper');
2197
- $result=$themesHelp->installTheme($_FILES['my-theme']['tmp_name'],true);
2198
- $this->redirect('admin.php?page=wysija_campaigns&action=themes&reload=1');
2199
-
2200
- return true;
2201
-
2202
- }
2203
-
2204
- function themes(){
2205
- $this->iframeTabs = array('themes' => __('Install Themes', WYSIJA));
2206
- $this->js[] = 'wysija-admin-ajax';
2207
- $this->js[] = 'wysija-base-script-64';
2208
- $this->jsTrans['viewinfos'] = __('Details & PSD', WYSIJA);
2209
- $this->jsTrans['viewback'] = __('<< Back', WYSIJA);
2210
- $this->jsTrans['install'] = __('Download', WYSIJA);
2211
- $this->jsTrans['reinstall'] = __('Reinstall', WYSIJA);
2212
- $this->jsTrans['premiumonly'] = __('Premium', WYSIJA);
2213
-
2214
- $model_config=WYSIJA::get('config','model');
2215
- //change the translation of the button when it's premium
2216
- if($model_config->getValue('premium_key'))$this->jsTrans['ispremium']=1;
2217
- else $this->jsTrans['ispremium']=0;
2218
-
2219
- $this->jsTrans['premiumfiles']=__('Photoshop file available as part of [link]Premium features[/link].',WYSIJA);
2220
- $helper_licence=WYSIJA::get('licence','helper');
2221
-
2222
- $this->jsTrans['premiumfiles']=str_replace(array('[link]','[/link]'),array('<a class="premium-tab ispopup" href="javascript:;" >','</a>'),$this->jsTrans['premiumfiles']);
2223
-
2224
- $this->jsTrans['showallthemes']=__('Show all themes',WYSIJA);
2225
- $this->jsTrans['totalvotes']=__('(%1$s votes)',WYSIJA);
2226
- $this->jsTrans['voterecorded']=__("Your vote has been recorded.",WYSIJA);
2227
- $this->jsTrans['votenotrecorded']=__("Your vote could not be recorded.",WYSIJA);
2228
- $this->jsTrans['reinstallwarning']=__('Watch out! If you reinstall this theme all the files which are in the folder:/wp-content/uploads/wysija/themes/%1$s will be overwritten. Are you sure you want to reinstall?',WYSIJA);
2229
- $this->jsTrans['errorconnecting']=__("We were unable to contact the API, the site may be down. Please try again later.",WYSIJA);
2230
-
2231
- $this->jsTrans['viewallthemes']=__('View all themes by %1$s',WYSIJA);
2232
- $this->jsTrans['downloadpsd']=__("Download original Photoshop file",WYSIJA);
2233
- $this->jsTrans['downloadzip']=__("Download as .zip",WYSIJA);
2234
- $this->jsTrans['viewauthorsite']=__("View author's website",WYSIJA);
2235
- $this->jsTrans['stars']=__('Average rating: %1$s',WYSIJA);
2236
- $this->jsTrans['starsyr']=__('My rating: %1$s',WYSIJA);
2237
- $this->jsTrans['downloads']=__('Downloads: %1$s',WYSIJA);
2238
- $this->jsTrans['tags']=__('Tags: %1$s',WYSIJA);
2239
- $this->jsTrans['lastupdated']=__('Last updated: %1$s',WYSIJA);
2240
- $this->jsTrans['includes']=__('Includes: %1$s',WYSIJA);
2241
-
2242
- $helper_themes=WYSIJA::get('themes','helper');
2243
-
2244
- $this->jsTrans['installedthemes']=$helper_themes->getInstalled();
2245
-
2246
- $url=admin_url('admin.php');
2247
- $helper_toolbox=WYSIJA::get("toolbox","helper");
2248
- $domain_name=$helper_toolbox->_make_domain_name($url);
2249
- $this->jsTrans['domainname']=$domain_name;
2250
-
2251
- $_GET['tab']='themes';
2252
-
2253
- return $this->popupContent();
2254
- }
2255
-
2256
- function bookmarks() {
2257
- $this->iframeTabs=array('bookmarks'=>__('Bookmarks Selection',WYSIJA));
2258
- $this->js[]='wysija-admin-ajax';
2259
-
2260
- $_GET['tab']='bookmarks';
2261
-
2262
- $networks = array(
2263
- 'facebook' => array(
2264
- 'label' => 'Facebook',
2265
- 'url' => 'https://www.facebook.com/wysija'
2266
- ),
2267
- 'twitter' => array(
2268
- 'label' => 'Twitter',
2269
- 'url' => 'https://twitter.com/#!/wysija'
2270
- ),
2271
- 'google' => array(
2272
- 'label' => 'Google+',
2273
- 'url' => null
2274
- ),
2275
- 'linkedin' => array(
2276
- 'label' => 'LinkedIn',
2277
- 'url' => null
2278
- )
2279
- );
2280
-
2281
- // get networks' url from config
2282
- $model_config=WYSIJA::get('config', 'model');
2283
- $urls = $model_config->getValue('social_bookmarks');
2284
-
2285
- // set url from config for each network if specified
2286
- foreach($networks as $network => $values) {
2287
- if(isset($urls[$network]) and strlen(trim($urls[$network])) > 0) {
2288
- $networks[$network]['url'] = $urls[$network];
2289
- }
2290
- }
2291
-
2292
- $this->data['networks'] = $networks;
2293
- $this->data['size'] = 'medium';
2294
- $this->data['theme'] = isset($_REQUEST['theme']) ? $_REQUEST['theme'] : 'default';
2295
-
2296
- return $this->popupContent();
2297
- }
2298
-
2299
- function dividers() {
2300
- $this->iframeTabs=array('dividers'=>__("Dividers Selection",WYSIJA));
2301
- $this->js[]='wysija-admin-ajax';
2302
- $this->js[]='wysija-base-script-64';
2303
-
2304
- $_GET['tab']='dividers';
2305
-
2306
- $model_email = WYSIJA::get('email', 'model');
2307
- $this->data['email'] = $email = $model_email->getOne(false, array('email_id' => $_REQUEST['emailId']));
2308
-
2309
- // get dividers
2310
- $helper_dividers = WYSIJA::get('dividers', 'helper');
2311
- $dividers = $helper_dividers->getAll();
2312
-
2313
- // get theme divider if it's not the default theme
2314
- if(isset($email['params']['theme'])) {
2315
- $helper_themes = WYSIJA::get('themes', 'helper');
2316
- $themeDivider = $helper_themes->getDivider($email['params']['theme']);
2317
- if($themeDivider !== NULL) {
2318
- array_unshift($dividers, $themeDivider);
2319
- }
2320
- }
2321
-
2322
- // get selected divider
2323
- if(isset($email['params']['divider'])) {
2324
- $selected_divider = $email['params']['divider'];
2325
- } else {
2326
- $helper_dividers = WYSIJA::get('dividers', 'helper');
2327
- $selected_divider = $helper_dividers->getDefault();
2328
- }
2329
-
2330
- // set selected divider in first position
2331
- array_unshift($dividers, $selected_divider);
2332
-
2333
- // remove selected divider if present in the list
2334
- for($i = 1; $i < count($dividers); $i++) {
2335
- if($dividers[$i]['src'] === $selected_divider['src']) {
2336
- unset($dividers[$i]);
2337
- break;
2338
- }
2339
- }
2340
-
2341
- $this->data['selected'] = $selected_divider;
2342
- $this->data['dividers'] = $dividers;
2343
- return $this->popupContent();
2344
- }
2345
-
2346
- function autopost() {
2347
- $this->iframeTabs=array('autopost'=>__("Add / Edit group of posts", WYSIJA));
2348
- $this->js[]='wysija-admin-ajax';
2349
- $this->js[]='wysija-base64';
2350
- $this->js[]='wysija-colorpicker';
2351
-
2352
- $_GET['tab'] = 'autopost';
2353
-
2354
- // get parameters
2355
- $params = array(
2356
- 'category_ids' => null,
2357
- 'category' => null,
2358
- 'title_tag' => 'h2',
2359
- 'title_alignment' => 'left',
2360
- 'image_alignment' => 'alternate',
2361
- 'post_content' => 'excerpt',
2362
- 'readmore' => __('Read more.', WYSIJA),
2363
- 'show_divider' => 'yes',
2364
- 'post_limit' => 5,
2365
- 'cpt' => 'post',
2366
- 'nopost_message' => __('Latest content already sent.', WYSIJA),
2367
- 'bgcolor1' => null,
2368
- 'bgcolor2' => null
2369
- );
2370
-
2371
- // check if GET parameters are specified
2372
- foreach($params as $key => $value) {
2373
- if(array_key_exists($key, $_GET)) {
2374
- switch($key) {
2375
- case 'autopost_count':
2376
- $params[$key] = (int)$_GET[$key];
2377
- break;
2378
- case 'readmore':
2379
- case 'nopost_message':
2380
- $params[$key] = base64_decode($_GET[$key]);
2381
- break;
2382
- default:
2383
- $params[$key] = $_GET[$key];
2384
- }
2385
- }
2386
- }
2387
-
2388
- // get autopost count
2389
- $this->data['autopost_count'] = (array_key_exists('autopost_count', $_GET)) ? (int)$_GET['autopost_count'] : 0;
2390
-
2391
- // get autopost type (single or multiple)
2392
- $this->data['autopost_type'] = (array_key_exists('autopost_type', $_GET)) ? $_GET['autopost_type'] : 'multiple';
2393
-
2394
- // if only one group of post can be added, change default alignment to left
2395
- if($this->data['autopost_type'] === 'single') {
2396
- if($params['image_alignment'] === 'alternate') $params['image_alignment'] = 'left';
2397
- }
2398
-
2399
- // get post categories (even when there's no post)
2400
- $post_categories = get_categories(array('hide_empty' => 0));
2401
- $categories = array();
2402
- foreach($post_categories as $category) {
2403
- $categories[] = array('id' => $category->cat_ID, 'name' => $category->name);
2404
- }
2405
- $this->data['categories'] = $categories;
2406
-
2407
- // max number of posts
2408
- $this->data['post_limits'] = array(1,2,3,4,5,6,7,8,9,10,20,30,50);
2409
-
2410
- $this->data['params'] = $params;
2411
-
2412
- return $this->popupContent();
2413
- }
2414
-
2415
- function image_data() {
2416
- $this->data['url'] = (isset($_GET['url']) && $_GET['url'] !== '') ? trim(urldecode($_GET['url'])) : null;
2417
- $this->data['alt'] = (isset($_GET['alt'])) ? trim(urldecode($_GET['alt'])) : '';
2418
-
2419
- $this->iframeTabs =array('image_data'=>__("Image Parameters",WYSIJA));
2420
- $_GET['tab']='image_data';
2421
- return $this->popupContent();
2422
- }
2423
-
2424
- function medias(){
2425
- $this->popupContent();
2426
- }
2427
-
2428
- function special_wysija_browse() {
2429
- $this->_wysija_subaction();
2430
- $this->jsTrans['deleteimg']=__('Delete image for all newsletters?',WYSIJA);
2431
- return wp_iframe( array($this->viewObj,'popup_wysija_browse'), array() );
2432
- }
2433
-
2434
- function special_wordp_browse() {
2435
- $this->_wysija_subaction();
2436
- $this->jsTrans['deleteimg']=__('This image might be in an article. Delete anyway?',WYSIJA);
2437
- return wp_iframe( array($this->viewObj,'popup_wp_browse'), array() );
2438
- }
2439
-
2440
-
2441
- function _wysija_subaction() {
2442
-
2443
- if(isset($_REQUEST['subaction'])){
2444
- if($_REQUEST['subaction'] === 'delete') {
2445
- if(isset($_REQUEST['imgid']) && (int)$_REQUEST['imgid'] > 0){
2446
- /* delete the image with id imgid */
2447
- $res = wp_delete_attachment((int)$_REQUEST['imgid'], true);
2448
- if($res) {
2449
- $this->notice(__('Image has been deleted.', WYSIJA));
2450
- }
2451
- }
2452
- }
2453
- }
2454
- return true;
2455
- }
2456
-
2457
- function special_new_wordp_upload() {
2458
-
2459
- //wp_enqueue_script('plupload-all');
2460
- wp_enqueue_script('wysija-plupload-handlers', WYSIJA_URL.'js/jquery/pluploadHandler.js', array('plupload-all', 'jquery'));
2461
- $uploader_l10n = array(
2462
- 'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
2463
- 'file_exceeds_size_limit' => __('%s exceeds the maximum upload size for this site.'),
2464
- 'zero_byte_file' => __('This file is empty. Please try another.'),
2465
- 'invalid_filetype' => __('This file type is not allowed. Please try another.'),
2466
- 'not_an_image' => __('This file is not an image. Please try another.'),
2467
- 'image_memory_exceeded' => __('Memory exceeded. Please try another smaller file.'),
2468
- 'image_dimensions_exceeded' => __('This is larger than the maximum size. Please try another.'),
2469
- 'default_error' => __('An error occurred in the upload. Please try again later.'),
2470
- 'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
2471
- 'upload_limit_exceeded' => __('You may only upload 1 file.'),
2472
- 'http_error' => __('HTTP error.'),
2473
- 'upload_failed' => __('Upload failed.'),
2474
- 'big_upload_failed' => __('Please try uploading this file with the %1$sbrowser uploader%2$s.'),
2475
- 'big_upload_queued' => __('%s exceeds the maximum upload size for the multi-file uploader when used in your browser.'),
2476
- 'io_error' => __('IO error.'),
2477
- 'security_error' => __('Security error.'),
2478
- 'file_cancelled' => __('File canceled.'),
2479
- 'upload_stopped' => __('Upload stopped.'),
2480
- 'dismiss' => __('Dismiss'),
2481
- 'crunching' => __('Crunching&hellip;'),
2482
- 'deleted' => __('moved to the trash.'),
2483
- 'error_uploading' => __('&#8220;%s&#8221; has failed to upload.')
2484
- );
2485
-
2486
- wp_localize_script('wysija-plupload-handlers', 'pluploadL10n', $uploader_l10n);
2487
-
2488
- wp_enqueue_script('image-edit');
2489
- wp_enqueue_script('set-post-thumbnail' );
2490
- wp_enqueue_style('imgareaselect');
2491
- wp_enqueue_script( 'media-gallery' );
2492
-
2493
- /*wp_register_style('myplupload', '/adjust-this-url/myplupload.css');
2494
- wp_enqueue_style('myplupload');*/
2495
-
2496
-
2497
- $errors=array();
2498
- return wp_iframe( array($this->viewObj,'popup_new_wp_upload'), $errors );
2499
- }
2500
-
2501
- function special_wordp_upload() {
2502
-
2503
- wp_enqueue_script('swfupload-all');
2504
- wp_enqueue_script('swfupload-handlers');
2505
- wp_enqueue_script('wysija-upload-handlers',WYSIJA_URL."js/jquery/uploadHandlers.js");
2506
- wp_enqueue_script('image-edit');
2507
- wp_enqueue_script('set-post-thumbnail' );
2508
- wp_enqueue_style('imgareaselect');
2509
-
2510
- $errors = array();
2511
- $id = 0;
2512
- if(isset($_GET['flash']))$_GET['flash']=1;
2513
- if ( isset($_POST['html-upload']) && !empty($_FILES) ) {
2514
- // Upload File button was clicked
2515
- $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
2516
- unset($_FILES);
2517
- if ( is_wp_error($id) ) {
2518
- $errors['upload_error'] = $id;
2519
- $id = false;
2520
  }
 
 
 
 
 
 
 
 
 
2521
  }
2522
 
2523
- if ( !empty($_POST['insertonlybutton']) ) {
2524
- $href = $_POST['insertonly']['href'];
2525
- if ( !empty($href) && !strpos($href, '://') )
2526
- $href = "http://$href";
2527
-
2528
- $title = esc_attr($_POST['insertonly']['title']);
2529
- if ( empty($title) )
2530
- $title = basename($href);
2531
- if ( !empty($title) && !empty($href) )
2532
- $html = "<a href='" . esc_url($href) . "' >$title</a>";
2533
- $html = apply_filters('file_send_to_editor_url', $html, esc_url_raw($href), $title);
2534
- return media_send_to_editor($html);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2535
  }
2536
 
2537
- if ( !empty($_POST) ) {
2538
- $return = media_upload_form_handler();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2539
 
2540
- if ( is_string($return) )
2541
- return $return;
2542
- if ( is_array($return) )
2543
- $errors = $return;
2544
  }
2545
 
2546
- if ( isset($_POST['save']) ) {
2547
- $errors['upload_notice'] = __('Saved.',WYSIJA);
2548
- return media_upload_gallery();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2549
  }
2550
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2551
 
2552
- return wp_iframe( array($this->viewObj,'popup_wp_upload'), $errors );
2553
- }
2554
-
2555
- function _checkEmailExists($emailId){
2556
- $result=false;
2557
- $modelEmail=WYSIJA::get('email','model');
2558
- if($modelEmail->exists(array('email_id'=>$emailId))) $result= true;
2559
-
2560
- if(!$result){
2561
- $this->error(__("The newsletter doesn't exist.",WYSIJA),1);
2562
- $this->redirect('admin.php?page=wysija_campaigns');
2563
- }else return true;
2564
- }
2565
-
2566
- /**
2567
- * action to reinstall the latest package from WordPress repository
2568
- */
2569
- function switch_to_package(){
2570
- $this->requireSecurity();
2571
- if((is_multisite() && !WYSIJA::current_user_can('manage_network')) || (!is_multisite() && !WYSIJA::current_user_can('switch_themes'))) return false;
2572
-
2573
- switch($_REQUEST['plugin']){
2574
- case 'wysija-newsletters':
2575
- $package_to_reinstall='wysija-newsletters/index.php';
2576
- $plugin=$_REQUEST['plugin'];
2577
- break;
2578
- case 'wysija-newsletters-premium':
2579
- $package_to_reinstall='wysija-newsletters-premium/index.php';
2580
- $plugin=$_REQUEST['plugin'];
2581
- break;
2582
- }
2583
-
2584
- $beta_mode=true;
2585
- if(isset($_REQUEST['stable'])){
2586
- $beta_mode=false;
2587
-
2588
- // we only need to emulate a downgrade if we move back to stable
2589
- $helper_package = WYSIJA::get('package','helper');
2590
- $helper_package->emulate_downgrade_plugin($package_to_reinstall);
2591
- }
2592
-
2593
- $model_config = WYSIJA::get('config','model');
2594
- $model_config->save(array('beta_mode'=>$beta_mode));
2595
-
2596
-
2597
-
2598
- // modify the version in the index.php
2599
- set_site_transient( 'update_plugins', '' );
2600
-
2601
- $this->redirect('admin.php?page=wysija_campaigns&action=switch_to_package_step2&plugin='.$plugin);
2602
-
2603
- }
2604
-
2605
- /**
2606
- * we need to do that in two steps
2607
- */
2608
- function switch_to_package_step2(){
2609
- if((is_multisite() && !WYSIJA::current_user_can('manage_network')) || (!is_multisite() && !WYSIJA::current_user_can('switch_themes'))) return false;
2610
- switch($_REQUEST['plugin']){
2611
- case 'wysija-newsletters':
2612
- $package_to_reinstall='wysija-newsletters/index.php';
2613
- break;
2614
- case 'wysija-newsletters-premium':
2615
- $package_to_reinstall='wysija-newsletters-premium/index.php';
2616
- break;
2617
- }
2618
-
2619
- $helper_package = WYSIJA::get('package','helper');
2620
-
2621
- echo '<html><head></head><body style="font-family: sans-serif;font-size: 12px;line-height: 1.4em;">';
2622
- $helper_package->re_install($package_to_reinstall);
2623
- echo '</body></html>';
2624
- exit;
2625
- }
2626
-
2627
- /**
2628
- * install the premium package from wysija's remote server
2629
- */
2630
- function install_wjp(){
2631
- $premiumpluginname='wysija-newsletters-premium/index.php';
2632
- echo '<html><head></head><body style="font-family: sans-serif;font-size: 12px;line-height: 1.4em;">';
2633
- if(WYSIJA::is_plugin_active($premiumpluginname)){
2634
- echo '<p>'.__('Plugin is already installed and activated.',WYSIJA).'</p>';
2635
- exit;
2636
- }
2637
-
2638
- //test if plugin is installed but not activated
2639
- $pluginslist=get_plugins();
2640
-
2641
- if(isset($pluginslist[$premiumpluginname])){
2642
- //try to activate it simply
2643
- error_reporting(E_ALL);
2644
- ini_set('display_errors', '1');
2645
- activate_plugin($premiumpluginname);
2646
- echo '<p>'.__('Your Premium features are now activated. Happy emailing!',WYSIJA).'</p>';
2647
-
2648
- }else{
2649
- $helper_package=WYSIJA::get('package','helper');
2650
- $helper_package->install('wysija-newsletters-premium',true);
2651
- }
2652
- echo '</body></html>';
2653
- exit;
2654
- }
2655
  }
2
 
3
  global $viewMedia;
4
  defined('WYSIJA') or die('Restricted access');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
 
6
+ class WYSIJA_control_back_campaigns extends WYSIJA_control_back {
 
 
7
 
8
+ var $model = 'campaign';
9
+ var $view = 'campaigns';
10
+ var $list_columns = array('campaign_id', 'name', 'description');
11
+ var $searchable = array('name', 'subject');
12
+ var $filters = array();
13
+ var $base_url = 'admin.php';
14
 
15
+ function WYSIJA_control_back_campaigns() {
 
 
16
 
17
+ }
18
+
19
+ function installation(){
20
+
21
+ $start_time = time();
22
+ $check_max_execution_time = get_option( 'mpoet_check_max_execution_time' );
23
+ $ini_max_execution_time = ini_get( 'max_execution_time' );
24
+
25
+ // 1 - we haven't run the max execution time extension test yet, let's do it
26
+ // this test should be run in the background, it may take more than 5 minutes to validate
27
+ if( empty( $check_max_execution_time ) ){
28
+
29
+ // we set the max_execution_time to infinite
30
+ @ini_set( 'max_execution_time' , 0 );
31
+ // we keep running the script even if the user abort his request
32
+ @ignore_user_abort( true );
33
+
34
+ $reset_max_execution_time = ini_get( 'max_execution_time' );
35
+
36
+ // FAILURE some servers the "max execution time" returned is Array we make sure our value is numeric
37
+ if( !is_numeric( $ini_max_execution_time ) ){
38
+ WYSIJA::update_option( 'mpoet_check_max_execution_time' , $ini_max_execution_time-1 );
39
+ return;
40
+ }
41
+
42
+ // FAILURE this server doesn't allow us to set the max_execution_time
43
+ if( $reset_max_execution_time == $ini_max_execution_time ){
44
+ WYSIJA::update_option( 'mpoet_check_max_execution_time' , $ini_max_execution_time-1 );
45
+ return;
46
+ }
47
+
48
+ // we set a FAILURE value to our flag so we know if the process crash while executing
49
+ WYSIJA::update_option( 'mpoet_check_max_execution_time' , $ini_max_execution_time );
50
+
51
+ // the common default timeout value is 300, so if by default the timelimit is 0 (which might have been set by another application)
52
+ // we default it to 300 known as a common default value and we run the extension test
53
+ if( $ini_max_execution_time == 0 ) $ini_max_execution_time = 300;
54
+
55
+ // we run asleep script during the initial max execution time to a larger value
56
+ $total_time_to_run_script = $ini_max_execution_time + 20;
57
+ $sleeping_intervals = 5;
58
+ $duration_so_far = 0;
59
+
60
+ // we sleep until the extended total timeout value is reached or it breaks before but we have the value we need
61
+ while($total_time_to_run_script >0){
62
+ $total_time_to_run_script = $total_time_to_run_script - $sleeping_intervals;
63
+ sleep( $sleeping_intervals );
64
+
65
+ $duration_so_far = time() - $start_time;
66
+ WYSIJA::update_option( 'mpoet_check_max_execution_time' , $duration_so_far );
67
+ }
68
+
69
+ // SUCCESS the scripts didn't die we set our flag in the db so that we know the test is a success
70
+ WYSIJA::update_option( 'mpoet_check_max_execution_time' , $duration_so_far );
71
+
72
+ }else{
73
+ // 2 - the max execution time extension test has been run, this is the results we get
74
+ if( $check_max_execution_time > $ini_max_execution_time ){
75
+ echo 'max_execution_time('.$ini_max_execution_time.') can be extended('.$check_max_execution_time.')';
76
+ }else{
77
+ echo 'max_execution_time('.$ini_max_execution_time.') cannot be extended( max value : '.$check_max_execution_time.')';
78
+ }
79
+ }
80
+ exit;
81
+ }
82
+
83
+ /**
84
+ * Welcome page first time install
85
+ * @return boolean
86
+ */
87
+ function welcome_new() {
88
+ $this->title = $this->viewObj->title = __('Welcome Page!', WYSIJA);
89
+ $this->jsTrans['instalwjp'] = __('Installing MailPoet Newsletter Premium plugin', WYSIJA);
90
+ $helper_readme = WYSIJA::get('readme', 'helper');
91
+ $helper_readme->scan();
92
+ $this->data = array();
93
+ $this->data['abouttext'] = __('A Brand New MailPoet. Let the Fun Begin.', WYSIJA);
94
+
95
+ $model_config = WYSIJA::get('config', 'model');
96
+ $is_multisite = is_multisite();
97
+ $is_network_admin = WYSIJA::current_user_can('manage_network');
98
+ if ($is_multisite && $is_network_admin) {
99
+ $model_config->save(array('ms_wysija_whats_new' => WYSIJA::get_version()));
100
+ } else {
101
+ $model_config->save(array('wysija_whats_new' => WYSIJA::get_version()));
102
+ }
103
+
104
+ //add a new language code with a new video
105
+ $video_language=array();
106
+ //$video_language['en_EN'] = '<iframe width="853" height="480" src="http://www.youtube.com/embed/pYzaHDTg5Jk" frameborder="0" allowfullscreen></iframe>';
107
+ $video_language['en_EN'] = '<iframe src="//player.vimeo.com/video/81479899" width="500" height="281" frameborder="0" webkitallowfullscreen mozallowfullscreen allowfullscreen></iframe>';
108
+ //$video_language['fr_FR'] = '<iframe width="853" height="480" src="http://www.youtube.com/embed/W5EyW5w7aWQ" frameborder="0" allowfullscreen></iframe>';
109
+ // $video_language['sv_SE']='<iframe width="853" height="480" src="http://www.youtube.com/embed/O8_t_dekx74" frameborder="0" allowfullscreen></iframe>';
110
+ //$video_language['ar']='<iframe width="853" height="480" src="http://www.youtube.com/embed/cyDHlX_qgOo" frameborder="0" allowfullscreen></iframe>';
111
+
112
+ $wp_lang = get_locale();
113
+ if (!empty($wp_lang) && isset($video_language[$wp_lang])) {
114
+ $welcome_video_link = $video_language[$wp_lang];
115
+ } else {
116
+ $welcome_video_link = $video_language['en_EN'];
117
+ }
118
+
119
+ $this->data['sections'][] = array(
120
+ 'title' => __('Hey, we\'re curious! How did you find out about us?', WYSIJA) . '<span id="poll_result"></span>',
121
+ 'format' => 'normal',
122
+ 'paragraphs' => array(
123
+ '<ul class="welcome_poll">
124
+ <li>
125
+ <input type="radio" id="how_did_you_find_us_1" value="repository" name="how_did_you_find_us">
126
+ <label value="lab1" for="how_did_you_find_us_1">' . __('WordPress.org plugin repository', WYSIJA) . '</label>
127
+ </li>
128
+ <li>
129
+ <input type="radio" id="how_did_you_find_us_2" value="search_engine" name="how_did_you_find_us">
130
+ <label value="lab2" for="how_did_you_find_us_2">' . __('Google or other search engine', WYSIJA) . '</label>
131
+ </li>
132
+ <li>
133
+ <input type="radio" id="how_did_you_find_us_3" value="friend" name="how_did_you_find_us">
134
+ <label value="lab3" for="how_did_you_find_us_3">' . __('Friend recommendation', WYSIJA) . '</label>
135
+ </li>
136
+ <li>
137
+ <input type="radio" id="how_did_you_find_us_4" value="url" name="how_did_you_find_us">
138
+ <label value="lab4" for="how_did_you_find_us_4">' . __('Blog post, online review, forum:', WYSIJA) . '</label>
139
+ <input type="text" id="how_did_you_find_us_4_url" name="how_did_you_find_us_url" placeholder="' . __('Please enter the address where you\'ve found out about us', WYSIJA) . '">
140
+ </li>
141
+ </ul>'
142
+ )
143
+ );
144
+
145
+ $this->data['sections'][]=array(
146
+ 'title'=>__('First Time? See it in Action',WYSIJA),
147
+ 'format'=>'normal',
148
+ 'paragraphs'=>array(
149
+ __('You can start by watching this video by one of our users.',WYSIJA),
150
+ $welcome_video_link
151
+ )
152
+ );
153
+
154
+ // Check if user is already sharing data, and hide the share link.
155
+ if (!$model_config->getValue('analytics')) {
156
+ $share_section = array(
157
+ 'title' => __('Share your data', WYSIJA),
158
+ 'content' => str_replace(
159
+ array('[link]', '[/link]', '[ajaxlink]', '[/ajaxlink]'), array('<a title="Anonymous Data" target="_blank" href="http://support.mailpoet.com/knowledgebase/share-your-data/?utm_source=wpadmin&utm_campaign=welcome_page">', '</a>', '<a id="share_analytics" href="javascript:;">', '</a>'), __("We know too little about our users. We're looking for [link]anonymous data[/link] to build a better plugin. [ajaxlink]Yes, count me in![/ajaxlink]", WYSIJA))
160
+ );
161
+ } else {
162
+ $share_section = array(
163
+ 'title' => __('Share your data', WYSIJA),
164
+ 'content' => str_replace(
165
+ array('[link]', '[/link]'), array('<a title="Anonymous Data" target="_blank" href="http://support.mailpoet.com/knowledgebase/share-your-data/?utm_source=wpadmin&utm_campaign=welcome_page">', '</a>', '<a id="share_analytics" href="javascript:;">', '</a>'), __("We know too little about our users. We're looking for [link]anonymous data[/link] to build a better plugin. Thanks, you're already sharing!", WYSIJA))
166
+ );
167
+ }
168
+
169
+ $this->data['sections'][] = array(
170
+ 'title' => __('What You Can Do', WYSIJA),
171
+ 'cols' => array(
172
+ array(
173
+ 'title' => __('5 minute newbie guide', WYSIJA),
174
+ 'content' => __('Your MailPoet comes with an example newsletter. You\'ll see it when you close this welcome page. Edit it to start playing with it.', WYSIJA)
175
+ ),
176
+ $share_section,
177
+ array(
178
+ 'title' => __('Help yourself. Or let us help you.', WYSIJA),
179
+ 'content' => str_replace(
180
+ array('[link]', '[/link]'), array('<a href="http://support.mailpoet.com/" target="_blank" title="On our blog!">', '</a>'), __('We got documentation and a ticket system on [link]support.mailpoet.com[/link]. We answer within 24h.', WYSIJA))
181
+ )
182
+ ),
183
+ 'format' => 'three-col',
184
+ );
185
+
186
+ $this->viewObj->skip_header = true;
187
+
188
+ return true;
189
+ }
190
+
191
+ /**
192
+ * Welcome page for updaters
193
+ * @return boolean
194
+ */
195
+ function whats_new() {
196
+
197
+ $this->title = $this->viewObj->title = __('What\'s new?', WYSIJA);
198
+ $this->jsTrans['instalwjp'] = __('Installing MailPoet Newsletter Premium plugin', WYSIJA);
199
+ wp_enqueue_style('wysija-admin-css-premium', WYSIJA_URL.'css/admin-premium.css',array(),WYSIJA::get_version());
200
+
201
+ $this->viewObj->skip_header = true;
202
+ return true;
203
+ }
204
+
205
+
206
+
207
+ /* START prem check hook */
208
+
209
+ // when curl or any php remote function not available mailpoet.com returns lcheck to that function
210
+ function licok() {
211
+ parent::WYSIJA_control_back();
212
+ $dt = get_option('wysijey');
213
+
214
+ if (isset($_REQUEST['xtz']) && $dt === $_REQUEST['xtz']) {
215
+ $dataconf = array('premium_key' => base64_encode(get_option('home') . time()), 'premium_val' => time());
216
+ $this->notice(__('Premium version is valid for your site.', WYSIJA));
217
+ } else {
218
+ $dataconf = array('premium_key' => '', 'premium_val' => '');
219
+
220
+ $helper_licence = WYSIJA::get('licence', 'helper');
221
+ $url_premium = 'http://www.mailpoet.com/checkout/?wysijadomain=' . $dt . '&nc=1&utm_source=wpadmin&utm_campaign=error_licence_activation';
222
+
223
+ $this->error(str_replace(array('[link]', '[/link]'), array('<a href="' . $url_premium . '" target="_blank">', '</a>'), __('Premium licence does not exist for your site. Purchase it [link]here[/link].', WYSIJA)), 1);
224
+ }
225
+ WYSIJA::update_option('wysicheck', false);
226
+ $modelConf = WYSIJA::get('config', 'model');
227
+ $modelConf->save($dataconf);
228
+
229
+ $this->redirect('admin.php?page=wysija_config#tab-premium');
230
+ }
231
+
232
+ /* END prem check hook */
233
+
234
+ function validateLic() {
235
+ $helpLic = WYSIJA::get('licence', 'helper');
236
+ $res = $helpLic->check();
237
+
238
+ $this->redirect();
239
+ }
240
+
241
+ /**
242
+ * this function is triggered when sending manually the emails with the "Don't wait and send right now" button
243
+ * @param type $dataPost
244
+ */
245
+ function manual_send($dataPost = false) {
246
+ $modelQ = WYSIJA::get('queue', 'model');
247
+ $config = WYSIJA::get('config', 'model');
248
+ if ((int) $config->getValue('total_subscribers') < 2000) {
249
+ if ($modelQ->count() > 0) {
250
+ $helperQ = WYSIJA::get('queue', 'helper');
251
+ $emailid = false;
252
+ if ($_REQUEST['emailid']) {
253
+ $emailid = $_REQUEST['emailid'];
254
+ }
255
+ $helperQ->process($emailid);
256
+ } else {
257
+ echo '<strong style="font-family: Arial; font-weight: bold; font-size: 12px;">' . __('Queue is empty!', WYSIJA) . '</strong>';
258
+ }
259
+ exit;
260
+ } else {
261
+ //deprecated
262
+ do_action('wysija_send_test_editor');
263
+
264
+ do_action('wysija_manual_send');
265
+ }
266
+
267
+ exit;
268
+ }
269
+
270
+ /**
271
+ * test the bounce handling maybe this should move somewhere else like config controller
272
+ * @return boolean
273
+ */
274
+ function test_bounce() {
275
+ // bounce handling
276
+ $helper_bounce = WYSIJA::get('bounce', 'helper');
277
+
278
+ // in a multisite case we process first the bounce recording into the bounce table
279
+ if (is_multisite()) {
280
+ $helper_bounce->record_bounce_ms();
281
+
282
+ // then we take actions from what has been returned by the bounce
283
+ $helper_bounce->process_bounce_ms();
284
+ } else {
285
+ $helper_bounce->process_bounce();
286
+ }
287
+ exit;
288
+ }
289
+
290
+ function add($dataPost = false) {
291
+ $this->title = sprintf(__('Step %1$s', WYSIJA), 1);
292
+ $this->js[] = 'wysija-validator';
293
+
294
+ $this->js[] = 'wysija-edit-autonl';
295
+ $this->js['admin-campaigns-edit'] = 'admin-campaigns-edit';
296
+ $this->jsTrans['descauto'] = str_replace(array('[newsletter:number]', '[newsletter:total]', '[newsletter:post_title]'), array('<b>[newsletter:number]</b>', '<b>[newsletter:total]</b>', '<b>[newsletter:post_title]</b>'), __('Insert [newsletter:total] to show number of posts, [newsletter:post_title] to show the latest post\'s title & [newsletter:number] to display the issue number.', WYSIJA));
297
+ $this->jsTrans['descstandard'] = __('The first thing your subscribers see. Be creative and increase your open rate!', WYSIJA);
298
+ $this->immediateWarning();
299
+ $this->viewObj->title = __('First step: main details', WYSIJA);
300
+ $this->viewShow = 'add';
301
+ $this->data = array();
302
+ $this->data['campaign'] = array('name' => '', 'description' => '');
303
+ $modelConfig = WYSIJA::get('config', 'model');
304
+ $this->data['email'] = array('subject' => '', 'from_email' => $modelConfig->getValue('from_email'), 'from_name' => $modelConfig->getValue('from_name'));
305
+ $this->data['lists'] = $this->__getLists(false, true, true);
306
+
307
+ $this->dataAutoNl();
308
+ $this->jsLoc['admin-campaigns-edit']['autofields'] = $this->data['autonl']['fields'];
309
+ }
310
+
311
+ /**
312
+ * get the fields and fields value necessary when dealing with automatic newsletters
313
+ */
314
+ function dataAutoNl() {
315
+ $dataFrequencyNoImmediate = $dataFrequency = array('daily' => __('once a day at...', WYSIJA),
316
+ 'weekly' => __('weekly on...', WYSIJA),
317
+ 'monthly' => __('monthly on the...', WYSIJA),
318
+ 'monthlyevery' => __('monthly every...', WYSIJA),
319
+ 'immediate' => __('immediately.', WYSIJA));
320
+
321
+ unset($dataFrequencyNoImmediate['immediate']);
322
+
323
+ $times = array();
324
+ $time = strtotime('00:00:00');
325
+ $toolboxH = WYSIJA::get('toolbox', 'helper');
326
+ $times['00:00:00'] = $toolboxH->localtime($time);
327
+
328
+ for ($i = 1; $i < 24; $i++) {
329
+ $time = strtotime('+ 1hour', $time);
330
+ $key = date('H:i:s', $time);
331
+ $times[$key] = $toolboxH->localtime($time);
332
+ }
333
+
334
+ $daysvalues = $toolboxH->getday();
335
+
336
+ $numberweeks = $toolboxH->getweeksnumber();
337
+ $daynumbers = $toolboxH->getdaynumber();
338
+
339
+
340
+ $dataLists = array();
341
+
342
+ foreach ($this->data['lists'] as $datal) {
343
+ if ($datal['is_enabled'])
344
+ $dataLists[$datal['list_id']] = $datal['name'];
345
+ }
346
+
347
+ // Get all available roles
348
+ $wptoolsH = WYSIJA::get('wp_tools', 'helper');
349
+ $roles = $wptoolsH->wp_get_all_roles();
350
+ $available_roles = array('any' => __('in any WordPress role', WYSIJA));
351
+ foreach ($roles as $role => $name) {
352
+ $available_roles[$role] = $name;
353
+ }
354
+
355
+ $this->data['autonl']['fields'] = array(
356
+ 'event' => array(
357
+ 'values' => array(
358
+ 'new-articles' => __('When there\'s new content...', WYSIJA),
359
+ 'subs-2-nl' => __('When someone subscribes to the list...', WYSIJA),
360
+ 'new-user' => __('When a new WordPress user is added to your site...', WYSIJA),
361
+ ),
362
+ 'valueshow' => array(
363
+ 'new-articles' => array('when-article'),
364
+ 'subs-2-nl' => array('subscribetolist', 'numberafter', 'numberofwhat', 'unique_send'),
365
+ 'new-user' => array('roles', 'numberafter', 'numberofwhat', 'unique_send'),
366
+ ),
367
+ 'style' => 'width:300px;'
368
+ ),
369
+ 'when-article' => array(
370
+ 'values' => $dataFrequency,
371
+ 'valueshow' => array(
372
+ 'daily' => array('time'),
373
+ 'weekly' => array('dayname', 'time'),
374
+ 'monthly' => array('daynumber', 'time'),
375
+ 'monthlyevery' => array('dayevery', 'dayname', 'time'),
376
+ )
377
+ ),
378
+ 'subscribetolist' => array(
379
+ 'values' => $dataLists,
380
+ 'style' => 'width:300px;'
381
+ ),
382
+ 'roles' => array(
383
+ 'values' => $available_roles
384
+ ),
385
+ 'numberafter' => array(
386
+ 'type' => 'input',
387
+ 'style' => 'width:35px;',
388
+ 'class' => 'validate[required,custom[integer],min[1]]',
389
+ ),
390
+ 'numberofwhat' => array(
391
+ 'values' => array(
392
+ 'immediate' => __('immediately.', WYSIJA),
393
+ 'hours' => __('hour(s) after.', WYSIJA),
394
+ 'days' => __('day(s) after.', WYSIJA),
395
+ 'weeks' => __('week(s) after.', WYSIJA)
396
+ ),
397
+ 'valuesunit' => array(
398
+ 'immediate' => __('immediately', WYSIJA),
399
+ 'hours' => __('hour(s)', WYSIJA),
400
+ 'days' => __('day(s)', WYSIJA),
401
+ 'weeks' => __('week(s)', WYSIJA)
402
+ ),
403
+ ),
404
+ 'dayevery' => array(
405
+ 'values' => $numberweeks,
406
+ ),
407
+ 'dayname' => array(
408
+ 'values' => $daysvalues,
409
+ ),
410
+ 'daynumber' => array(
411
+ 'values' => $daynumbers,
412
+ ),
413
+ 'time' => array(
414
+ 'values' => $times,
415
+ ),
416
+ /* 'unique_send'=>array(
417
+ 'label_before'=>__('Send this email only once.',WYSIJA),
418
+ 'type'=>'checkbox'
419
+ ), */
420
+ );
421
+ $helpersEvent = WYSIJA::get('autonews', 'helper');
422
+ $extraEvents = $helpersEvent->events();
423
+
424
+ /* if there are plugin to add autonewsletter event they are adding their customized field over here */
425
+ if ($extraEvents) {
426
+ foreach ($extraEvents as $k => $v) {
427
+
428
+ $this->data['autonl']['fields']['event']['values'][$k] = $v['title'];
429
+ foreach ($v['fields'] as $fieldCKEY => $fieldCVAL) {
430
+ if (isset($this->data['autonl']['fields'][$fieldCKEY]))
431
+ continue;
432
+ }
433
+ $this->data['autonl']['fields']['event']['valueshow'][$k] = array_keys($v['fields']);
434
+ }
435
+ }
436
+ }
437
+
438
+ function __getLists($enabled = true, $count = false, $notgetalllistid = false) {
439
+ $modelList = WYSIJA::get('list', 'model');
440
+ //get lists which have users and are enabled */
441
+ if ($enabled)
442
+ $enabledstrg = ' is_enabled>0 and';
443
+ else
444
+ $enabledstrg = '';
445
+
446
+ $extrasql = '';
447
+ if (!$notgetalllistid)
448
+ $extrasql = 'WHERE list_id in (SELECT distinct(list_id) from [wysija]user_list )';
449
+ $query = 'SELECT * FROM [wysija]list ' . $extrasql;
450
+ $listres = $modelList->query('get_res', $query);
451
+
452
+ if ($count) {
453
+ $mConfig = WYSIJA::get('config', 'model');
454
+ $condit = '>=';
455
+ if ($mConfig->getValue('confirm_dbleoptin'))
456
+ $condit = '>';
457
+ $qry1 = "SELECT count(distinct A.user_id) as nbsub,A.list_id FROM `[wysija]user_list` as A LEFT JOIN `[wysija]user` as B on A.user_id=B.user_id WHERE B.status $condit 0 and A.sub_date>0 and A.unsub_date=0 GROUP BY list_id";
458
+
459
+ $total = $modelList->getResults($qry1);
460
+
461
+ foreach ($total as $tot) {
462
+ foreach ($listres as $key => $res) {
463
+ if ($tot['list_id'] == $res['list_id'])
464
+ $listres[$key]['count'] = $tot['nbsub'];
465
+ }
466
+ }
467
+ }
468
+ foreach ($listres as $key => $res) {
469
+ if (!isset($res['count']))
470
+ $listres[$key]['count'] = 0;
471
+ }
472
+ return $listres;
473
+ }
474
+
475
+ function edit($dataPost = false) {
476
+ if (!$this->_checkEmailExists($_REQUEST['id']))
477
+ return;
478
+ $this->add();
479
+
480
+ $modelEmail = WYSIJA::get('email', 'model');
481
+
482
+ $this->data['email'] = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
483
+
484
+ if ($this->data['email']['status'] > 0) {
485
+ $this->redirect();
486
+ }
487
+ $this->title = sprintf(__('Step %1$s', WYSIJA), 1) . ' | ' . $this->data['email']['subject'];
488
+ $modelCamp = WYSIJA::get('campaign', 'model');
489
+ $this->data['campaign'] = $modelCamp->getOne(false, array('campaign_id' => $this->data['email']['campaign_id']));
490
+
491
+ $modelCL = WYSIJA::get('campaign_list', 'model');
492
+ $this->data['campaign_list'] = $modelCL->get(false, array('campaign_id' => $this->data['email']['campaign_id']));
493
+ }
494
+
495
+ function editTemplate() {
496
+ // make sure the editor content is not cached
497
+ header('Cache-Control: no-cache, max-age=0, must-revalidate, no-store'); // HTTP/1.1
498
+ header('Expires: Fri, 9 Mar 1984 00:00:00 GMT');
499
+
500
+ if (!$this->_checkEmailExists($_REQUEST['id']))
501
+ return;
502
+ $this->viewShow = 'editTemplate';
503
+
504
+ wp_enqueue_style('thickbox');
505
+
506
+ $wjEngine = WYSIJA::get('wj_engine', 'helper');
507
+ /* WJ editor translations */
508
+ $this->jsTrans = array_merge($this->jsTrans, $wjEngine->getTranslations(), $wjEngine->getApplicationData());
509
+
510
+ $this->jsTrans['savingnl'] = __('Saving newsletter...', WYSIJA);
511
+ $this->jsTrans['errorsavingnl'] = __('Error Saving newsletter...', WYSIJA);
512
+ $this->jsTrans['savednl'] = __('Newsletter has been saved.', WYSIJA);
513
+ $this->jsTrans['previewemail'] = __('Sending preview...', WYSIJA);
514
+ $this->jsTrans['spamtestresult'] = __('Spam test results', WYSIJA);
515
+
516
+ /* WJ editor JS */
517
+ $this->js[] = 'wysija-editor';
518
+ $this->js[] = 'wysija-admin-ajax-proto';
519
+ $this->js[] = 'wysija-admin-ajax';
520
+ $this->js[] = 'wysija-base-script-64';
521
+ $this->js[] = 'media-upload';
522
+ $this->js['admin-campaigns-editDetails'] = 'admin-campaigns-editDetails';
523
+ $modelEmail = WYSIJA::get('email', 'model');
524
+ $this->data = array();
525
+ $this->data['email'] = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
526
+
527
+ $this->checkIsEditable();
528
+
529
+ $this->viewObj->title = sprintf(__('Second step: "%1$s"', WYSIJA), $this->data['email']['subject']);
530
+ $this->title = sprintf(__('Step %1$s', WYSIJA), 2) . " | " . $this->data['email']['subject'];
531
+
532
+ // check if html source is enabled in the config (this will add the "html source" button in tinymce)
533
+ $model_config = WYSIJA::get('config', 'model');
534
+ $this->jsTrans['html_source_enabled'] = (int) $model_config->getValue('html_source');
535
+ }
536
+
537
+ function checkIsEditable() {
538
+ if (
539
+ !($this->data['email'] == 2 || isset($this->data['email']['params']['schedule']['isscheduled'])) && $this->data['email']['status'] > 0
540
+ ) {
541
+ $this->redirect();
542
+ }
543
+ }
544
+
545
+ function pause() {
546
+ /* pause the campaign entry */
547
+ if (isset($_REQUEST['id']) && $_REQUEST['id']) {
548
+ $modelEmail = WYSIJA::get('email', 'model');
549
+ $myemail = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
550
+ $modelEmail->reset();
551
+ $modelEmail->columns['modified_at']['autoup'] = 1;
552
+ $modelEmail->update(array('status' => -1), array('email_id' => $_REQUEST['id']));
553
+
554
+ if ($myemail['type'] == 2) {
555
+ return $this->redirect('admin.php?page=wysija_campaigns&id=' . $myemail['email_id'] . '&action=edit');
556
+ } else {
557
+ $this->notice(__('Sending is now paused.', WYSIJA));
558
+ }
559
+ }
560
+
561
+ $this->redirect();
562
+ }
563
+
564
+ function resume() {
565
+ /* pause the campaign entry */
566
+ if (isset($_REQUEST['id']) && $_REQUEST['id']) {
567
+ $modelEmail = WYSIJA::get('email', 'model');
568
+ $modelEmail->columns['modified_at']['autoup'] = 1;
569
+ $modelEmail->update(array('status' => 99), array('email_id' => $_REQUEST['id']));
570
+ $this->notice(__('Sending has resumed.', WYSIJA));
571
+ }
572
+
573
+ $this->redirect();
574
+ }
575
+
576
+ function duplicate() {
577
+
578
+ /* 1 - copy the campaign entry */
579
+
580
+ $model = WYSIJA::get('campaign', 'model');
581
+ $query = 'INSERT INTO `[wysija]campaign` (`name`,`description`)
582
+ SELECT concat("' . stripslashes(__('Copy of ', WYSIJA)) . '",`name`),`description` FROM [wysija]campaign
583
+ WHERE campaign_id=' . (int) $_REQUEST['id'];
584
+ $campaignid = $model->query($query);
585
+
586
+ /* 2 - copy the email entry */
587
+ $query = 'INSERT INTO `[wysija]email` (`campaign_id`,`subject`,`body`,`type`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,`status`,`created_at`,`modified_at`)
588
+ SELECT ' . $campaignid . ', concat("' . stripslashes(__('Copy of ', WYSIJA)) . '",`subject`),`body`,`type`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,0,' . time() . ',' . time() . ' FROM [wysija]email
589
+ WHERE email_id=' . (int) $_REQUEST['email_id'];
590
+ $emailid = $model->query($query);
591
+
592
+ //let's reset the count of total childs for auto newsletter
593
+ $mEmail = WYSIJA::get('email', 'model');
594
+ $emailData = $mEmail->getOne(false, array('email_id' => $emailid));
595
+
596
+ if ($emailData['type'] == 2) {
597
+ $paramsReseted = $emailData['params'];
598
+ if (isset($paramsReseted['autonl']['total_child']))
599
+ $paramsReseted['autonl']['total_child'] = 0;
600
+ if (isset($paramsReseted['autonl']['nextSend']))
601
+ $paramsReseted['autonl']['nextSend'] = 0;
602
+ if (isset($paramsReseted['autonl']['firstSend']))
603
+ unset($paramsReseted['autonl']['firstSend']);
604
+ if (isset($paramsReseted['autonl']['lastSend']))
605
+ unset($paramsReseted['autonl']['lastSend']);
606
+ if (isset($paramsReseted['autonl']['articles']['ids']))
607
+ unset($paramsReseted['autonl']['articles']['ids']);
608
+
609
+
610
+ $mEmail->update(array('params' => $paramsReseted), array('email_id' => $emailid));
611
+ }
612
+
613
+ /* 3 - copy the campaign_list entry */
614
+ $query = "INSERT INTO `[wysija]campaign_list` (`campaign_id`,`list_id`,`filter`)
615
+ SELECT $campaignid,`list_id`,`filter` FROM [wysija]campaign_list
616
+ WHERE campaign_id=" . (int) $_REQUEST['id'];
617
+ $model->query($query);
618
+
619
+ $this->notice(__('The newsletter has been duplicated.', WYSIJA));
620
+
621
+ $this->redirect('admin.php?page=wysija_campaigns&id=' . $emailid . '&action=edit');
622
+ }
623
+
624
+ function duplicateEmail() {
625
+ if (!$this->_checkEmailExists($_REQUEST['id']))
626
+ return;
627
+
628
+ $model = WYSIJA::get('campaign', 'model');
629
+ /* 2 - copy the email entry */
630
+ $query = 'INSERT INTO `[wysija]email` (`campaign_id`,`subject`,`body`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,`status`,`created_at`,`modified_at`)
631
+ SELECT `campaign_id`, concat("' . stripslashes(__("Copy of ", WYSIJA)) . '",`subject`),`body`,`params`,`wj_data`,`wj_styles`,`from_email`,`from_name`,`replyto_email`,`replyto_name`,`attachments`,0,' . time() . ',' . time() . ' FROM [wysija]email
632
+ WHERE email_id=' . (int) $_REQUEST['id'];
633
+ $emailid = $model->query($query);
634
+
635
+ $this->notice(__('The newsletter has been duplicated.', WYSIJA));
636
+
637
+ $this->redirect('admin.php?page=wysija_campaigns&id=' . $emailid . '&action=edit');
638
+ }
639
+
640
+ function immediateWarning() {
641
+ $model_config = WYSIJA::get('config', 'model');
642
+ $is_multisite = is_multisite();
643
+
644
+ //$is_multisite=true;//PROD comment that line
645
+ if ($is_multisite && $model_config->getValue('sending_method') == 'network') {
646
+ $sending_emails_each = $model_config->getValue('ms_sending_emails_each');
647
+ $number = $model_config->getValue('ms_sending_emails_number');
648
+ } else {
649
+ $sending_emails_each = $model_config->getValue('sending_emails_each');
650
+ $number = $model_config->getValue('sending_emails_number');
651
+ }
652
+
653
+ $formsHelp = WYSIJA::get('forms', 'helper');
654
+
655
+ $timespan = $formsHelp->eachValuesSec[$sending_emails_each];
656
+ $tb = WYSIJA::get('toolbox', 'helper');
657
+
658
+ $this->immediatewarning = str_replace(
659
+ array('[link]', '[/link]', '[settings]'), array('<a href="#">', '</a>', sprintf(__('%1$s emails every %2$s', WYSIJA), $number, trim($tb->duration_string($timespan, true)))), __('Your sending settings ([settings]) can\'t send that quickly to [number] subscribers. Expect delivery delays. [link]Read more[/link]', WYSIJA));
660
+ $this->viewObj->immediatewarning = '<span class="warning-msg" id="immediatewarning">' . $this->immediatewarning . '</span>';
661
+
662
+ $this->jsTrans['immediatewarning'] = $this->immediatewarning;
663
+
664
+ //how many emails can be sent in 12 hours
665
+ //if the frequency is less than 12hours
666
+ if ($timespan < 43200) {
667
+ $ratio = floor(43200 / $timespan);
668
+ $this->jsTrans['possibleemails'] = $ratio * $number;
669
+ } else {
670
+ if ($timespan == 43200) {
671
+ $this->jsTrans['possibleemails'] = $number;
672
+ } else {
673
+ $ratio = floor($timespan / 43200);
674
+ $this->jsTrans['possibleemails'] = $number / $ratio;
675
+ }
676
+ }
677
+ }
678
+
679
+ function editDetails() {
680
+ if (!$this->_checkEmailExists($_REQUEST['id']))
681
+ return;
682
+ $this->viewObj->title = __('Final step: last details', WYSIJA);
683
+ $this->viewShow = 'editDetails';
684
+ $this->js[] = 'wysija-validator';
685
+ $this->jsTrans['previewemail'] = __('Sending preview...', WYSIJA);
686
+ $this->jsTrans['pickadate'] = __('Pick a date', WYSIJA);
687
+ $this->jsTrans['saveclose'] = __('Save & close', WYSIJA);
688
+ $this->jsTrans['sendlater'] = __('Send later', WYSIJA);
689
+
690
+ $this->jsTrans['schedule'] = __('Schedule', WYSIJA);
691
+
692
+ $this->jsTrans['emailCheck'] = WJ_Utils::get_tip_data();
693
+
694
+
695
+ $this->js[] = 'jquery-ui-datepicker';
696
+ $this->js[] = 'wysija-tooltip';
697
+
698
+ $model_list = WYSIJA::get('list', 'model');
699
+ $model_list->limitON = false;
700
+ $this->data = array();
701
+ $this->data['lists'] = $this->__getLists(false, true, true);
702
+
703
+ $model_email = WYSIJA::get('email', 'model');
704
+ $this->data['email'] = $model_email->getOne(false, array('email_id' => $_REQUEST['id']));
705
+
706
+ // The first newsletter, we don't have replyto_email and replyto_name
707
+ if (empty($this->data['email']['replyto_email']) || empty($this->data['email']['replyto_name'])) {
708
+ $current_user = wp_get_current_user();
709
+ $this->data['email']['replyto_email'] = $current_user->data->user_email;
710
+ $this->data['email']['replyto_name'] = $current_user->data->display_name;
711
+ }
712
+
713
+
714
+ if ((int) $this->data['email']['type'] == 2) {
715
+ $this->js['wysija-edit-autonl'] = 'wysija-edit-autonl';
716
+ $this->jsTrans['autonl'] = true;
717
+ $this->immediateWarning();
718
+ $this->jsTrans['send'] = __('Activate now', WYSIJA);
719
+ } else {
720
+ $this->jsTrans['autonl'] = true;
721
+ $this->viewObj->immediatewarning = '';
722
+ $this->jsTrans['send'] = __('Send', WYSIJA);
723
+ }
724
+
725
+ if ((int) $this->data['email']['type'] == 1) {
726
+ $this->jsTrans['alertsend'] = __('You are about to send this newsletter. Please confirm.', WYSIJA);
727
+ } else {
728
+ if (isset($this->data['email']['params']['autonl']['event']) && $this->data['email']['params']['autonl']['event'] == 'subs-2-nl') {
729
+ $this->data['autoresponder'] = 1;
730
+ foreach ($this->data['lists'] as $list) {
731
+ if ($list['list_id'] == $this->data['email']['params']['autonl']['subscribetolist']) {
732
+ break;
733
+ }
734
+ }
735
+
736
+ $this->jsTrans['ignoreprevious'] = sprintf(__('Are you sure you want to ignore the %1$s subscribers of the list %2$s?', WYSIJA), '"' . $list['count'] . '"', '"' . $list['name'] . '"');
737
+ }
738
+ }
739
+
740
+ $this->checkIsEditable();
741
+
742
+ $this->title = sprintf(__('Step %1$s', WYSIJA), 3) . " | " . $this->data['email']['subject'];
743
+ $this->dataAutoNl();
744
+
745
+ $this->jsLoc['wysija-edit-autonl']['autofields'] = $this->data['autonl']['fields'];
746
+
747
+ $modelCL = WYSIJA::get('campaign_list', 'model');
748
+ $this->data['campaign_list'] = $modelCL->get(false, array('campaign_id' => $this->data['email']['campaign_id']));
749
+ }
750
+
751
+ function delete() {
752
+ $this->requireSecurity();
753
+
754
+ $campaign_ids = array();
755
+ if(isset($_REQUEST['id'])) $campaign_ids[] = $_REQUEST['id'];
756
+ if(isset($_REQUEST['campaign']['campaign_id'])) $campaign_ids[] = $_REQUEST['campaign']['campaign_id'];
757
+ if(isset($_REQUEST['wysija']['campaign']['campaign_id'][0])){
758
+ $campaign_ids = array_merge($campaign_ids, $_REQUEST['wysija']['campaign']['campaign_id']);
759
+ }
760
+
761
+ if (!empty($campaign_ids)) {
762
+ foreach($campaign_ids as $campaign_id){
763
+ if($campaign_id > 0){
764
+ $model_campaign = WYSIJA::get('campaign', 'model');
765
+ $model_campaign->delete(array('campaign_id' => $campaign_id));
766
+
767
+ $model_campaign_list = WYSIJA::get('campaign_list', 'model');
768
+ $model_campaign_list->delete(array('campaign_id' => $campaign_id));
769
+
770
+ $modelEmail = WYSIJA::get('email', 'model');
771
+ $modelEmail->delete(array('campaign_id' => $campaign_id));
772
+ }
773
+ }
774
+
775
+ $this->notice(_n(__('Newsletter deleted.', WYSIJA), __('Newsletters deleted.', WYSIJA), count($campaign_ids), WYSIJA));
776
+ } else {
777
+ $this->notice(__('Newsletter can\'t be deleted.', WYSIJA));
778
+ }
779
+
780
+ // retrieve saved filter
781
+ if (!empty($_REQUEST['action']))
782
+ unset($_REQUEST['action']);
783
+ if (!empty($_REQUEST['id']))
784
+ unset($_REQUEST['id']);
785
+ if (!empty($_REQUEST['_wpnonce']))
786
+ unset($_REQUEST['_wpnonce']);
787
+ $redirect = $this->base_url . '?' . http_build_query($_REQUEST);
788
+ $this->redirect($redirect);
789
+ }
790
+
791
+ /**
792
+ *
793
+ * this function is to delete an email that belongs to a campaign
794
+ * when we have a post notification all emails belong to the same campaign
795
+ * we don't want to delete an entire campaign when we delete a single email
796
+ */
797
+ function deleteEmail(){
798
+ $this->requireSecurity();
799
+ if(!$this->_checkEmailExists($_REQUEST['id'])) return;
800
+
801
+ if(isset($_REQUEST['id'])){
802
+ $modelEmail=WYSIJA::get('email','model');
803
+ $modelEmail->delete(array('email_id'=>$_REQUEST['id']));
804
+ $this->notice(__('Newsletter deleted.',WYSIJA));
805
+ }else{
806
+ $this->notice(__('Newsletter can\'t be deleted.',WYSIJA));
807
+ }
808
+
809
+ $this->redirect();
810
+ }
811
+
812
+ function savecamp() {
813
+ $this->redirectAfterSave = false;
814
+
815
+ /* update email */
816
+ $data = array();
817
+
818
+ // in case the newsletter already exists
819
+ if (isset($_REQUEST['id'])) {
820
+ $modelEmail = WYSIJA::get('email', 'model');
821
+ $modelEmail->fieldValid = false;
822
+ $emaildataarr = $modelEmail->getOne(false, array('email_id' => $_REQUEST['id']));
823
+
824
+ $model_campaign = WYSIJA::get('campaign', 'model');
825
+ $model_campaign->update(array('name' => $_POST['wysija']['email']['subject'], 'description' => ''), array('campaign_id' => $emaildataarr['campaign_id']));
826
+
827
+ $campaign_id = $emaildataarr['campaign_id'];
828
+ $email_id = $emaildataarr['email_id'];
829
+ $dataEmail = array(
830
+ 'campaign_id' => $campaign_id,
831
+ 'subject' => $_POST['wysija']['email']['subject'],
832
+ 'type' => $_POST['wysija']['email']['type']);
833
+
834
+ if((int)$dataEmail['type'] === 2) {
835
+ // set autonl params
836
+ $dataEmail['params'] = array('autonl' => $_POST['wysija']['email']['params']['autonl']);
837
+
838
+ // WTF?
839
+ if(!isset($newparams['autonl']['unique_send'])) {
840
+ unset($dataEmail['params']['autonl']['unique_send']);
841
+ } else {
842
+ $dataEmail['params']['autonl']['unique_send'] = true;
843
+ }
844
+ }
845
+
846
+ // check if the newsletter used to be an automatic newsletter (if )
847
+ if((int)$dataEmail['type'] === 1 && (int)$emaildataarr['type'] === 2) {
848
+ // make sure we remove any kind of auto-post block
849
+ $helper_autonews = WYSIJA::get('autonews', 'helper');
850
+ $updated_email_data = $helper_autonews->remove_autopost_blocks($emaildataarr['wj_data']);
851
+ if($updated_email_data !== false) {
852
+ // if the email data has been changed, make sure to update it in the DB
853
+ $dataEmail['wj_data'] = $updated_email_data;
854
+ }
855
+ }
856
+
857
+ $modelEmail->columns['modified_at']['autoup'] = 1;
858
+ $modelEmail->debugupdate = true;
859
+ $dataEmail['email_id'] = $_REQUEST['id'];
860
+
861
+ if(isset($_REQUEST['save-reactivate'])) {
862
+ //if the button save and reactivate has been clicked then we reactivate and redirect to the newsletter page
863
+ $dataEmail['status'] = 99;
864
+ $_REQUEST['return'] = 1;
865
+ }
866
+
867
+ $data['email']['email_id'] = $modelEmail->update($dataEmail, array('email_id' => (int)$_REQUEST['id']));
868
+ } else {
869
+ // get default theme
870
+ $model_config = WYSIJA::get('config', 'model');
871
+ $default_theme = $model_config->getValue('newsletter_default_theme', 'default');
872
+
873
+ $helper_themes = WYSIJA::get('themes', 'helper');
874
+ $theme_data = $helper_themes->getData($default_theme);
875
+
876
+ // get campaign data
877
+ $model_campaign = WYSIJA::get('campaign', 'model');
878
+ $campaign_id = $model_campaign->insert(array('name' => $_POST['wysija']['email']['subject'], 'description' => ''));
879
+
880
+ $modelEmail = WYSIJA::get('email', 'model');
881
+ $modelEmail->fieldValid = false;
882
+ $emaildata = array(
883
+ 'campaign_id' => $campaign_id,
884
+ 'subject' => $_POST['wysija']['email']['subject'],
885
+ 'type' => (int) $_POST['wysija']['email']['type']
886
+ );
887
+
888
+
889
+ // create autonl parameters if necessary
890
+ if ((int) $_POST['wysija']['email']['type'] === 2 && isset($_POST['wysija']['email']['params']['autonl'])) {
891
+ $emaildata['params'] = array('autonl' => $_POST['wysija']['email']['params']['autonl']);
892
+ }
893
+
894
+ // create sample data depending on newsletter's type
895
+ if ((int) $_POST['wysija']['email']['type'] === 2 && $_POST['wysija']['email']['params']['autonl']['event'] === 'new-articles') {
896
+
897
+ // if immediate, post_limit is set to 1
898
+ if ($emaildata['params']['autonl']['when-article'] === 'immediate') {
899
+ $autopostParams = array(
900
+ array('key' => 'category_ids', 'value' => null),
901
+ array('key' => 'title_tag', 'value' => 'h2'),
902
+ array('key' => 'title_alignment', 'value' => 'left'),
903
+ array('key' => 'title_position', 'value' => 'inside'),
904
+ array('key' => 'image_alignment', 'value' => 'alternate'),
905
+ array('key' => 'image_width', 'value' => 325),
906
+ array('key' => 'post_content', 'value' => 'excerpt'),
907
+ array('key' => 'readmore', 'value' => base64_encode(__('Read more.', WYSIJA))),
908
+ array('key' => 'show_divider', 'value' => 'yes'),
909
+ array('key' => 'post_limit', 'value' => 1),
910
+ array('key' => 'post_type', 'value' => 'post'),
911
+ array('key' => 'author_show', 'value' => 'no'),
912
+ array('key' => 'author_label', 'value' => base64_encode(__('Author:', WYSIJA))),
913
+ array('key' => 'category_show', 'value' => 'no'),
914
+ array('key' => 'category_label', 'value' => base64_encode(__('Categories:', WYSIJA))),
915
+ array('key' => 'nopost_message', 'value' => base64_encode(__('Latest content already sent.', WYSIJA))),
916
+ array('key' => 'bgcolor1', 'value' => null),
917
+ array('key' => 'bgcolor2', 'value' => null),
918
+ array('key' => 'sort_by', 'value' => 'newest')
919
+ );
920
+ } else {
921
+ $autopostParams = array(
922
+ array('key' => 'category_ids', 'value' => null),
923
+ array('key' => 'title_tag', 'value' => 'h2'),
924
+ array('key' => 'title_alignment', 'value' => 'left'),
925
+ array('key' => 'title_position', 'value' => 'inside'),
926
+ array('key' => 'image_alignment', 'value' => 'alternate'),
927
+ array('key' => 'image_width', 'value' => 325),
928
+ array('key' => 'post_content', 'value' => 'excerpt'),
929
+ array('key' => 'readmore', 'value' => base64_encode(__('Read more.', WYSIJA))),
930
+ array('key' => 'show_divider', 'value' => 'yes'),
931
+ array('key' => 'post_limit', 'value' => 2),
932
+ array('key' => 'post_type', 'value' => 'post'),
933
+ array('key' => 'author_show', 'value' => 'no'),
934
+ array('key' => 'author_label', 'value' => base64_encode(__('Author:', WYSIJA))),
935
+ array('key' => 'category_show', 'value' => 'no'),
936
+ array('key' => 'category_label', 'value' => base64_encode(__('Categories:', WYSIJA))),
937
+ array('key' => 'nopost_message', 'value' => base64_encode(__('Latest content already sent.', WYSIJA))),
938
+ array('key' => 'bgcolor1', 'value' => null),
939
+ array('key' => 'bgcolor2', 'value' => null),
940
+ array('key' => 'sort_by', 'value' => 'newest')
941
+ );
942
+ }
943
+
944
+ // sample data for post notifications
945
+ $newwjdata = array(
946
+ 'version' => WYSIJA::get_version(),
947
+ 'header' => array(
948
+ 'text' => NULL,
949
+ 'image' => array(
950
+ 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
951
+ 'width' => 600,
952
+ 'height' => 86,
953
+ 'alignment' => 'center',
954
+ 'static' => true,
955
+ ),
956
+ 'alignment' => 'center',
957
+ 'static' => true,
958
+ 'type' => 'header'
959
+ ),
960
+ 'body' => array(
961
+ 'block-1' => array(
962
+ 'text' => array(
963
+ 'value' => '<h3 class="align-right">' . sprintf(__("The posts below were added with the widget %sAutomatic latest content%s", WYSIJA), '<strong>', '</strong>') . '</h3>'
964
+ ),
965
+ 'image' => array(
966
+ 'src' => WYSIJA_EDITOR_IMG . 'default-newsletter/autonewsletter/arrow-up.png',
967
+ 'width' => 45,
968
+ 'height' => 45,
969
+ 'alignment' => 'right',
970
+ 'static' => false
971
+ ),
972
+ 'alignment' => 'right',
973
+ 'static' => false,
974
+ 'position' => '1',
975
+ 'type' => 'content'
976
+ ),
977
+ 'block-2' => array(
978
+ 'text' => array(
979
+ 'value' => '<h3>' . sprintf(__('%sTo edit%s, mouse over to show edit button below.', WYSIJA), '<strong>', '</strong>') . '</h3>'
980
+ ),
981
+ 'image' => array(
982
+ 'src' => WYSIJA_EDITOR_IMG . 'default-newsletter/autonewsletter/arrow-down.png',
983
+ 'width' => 150,
984
+ 'height' => 53,
985
+ 'alignment' => 'left',
986
+ 'static' => false
987
+ ),
988
+ 'alignment' => 'left',
989
+ 'static' => false,
990
+ 'position' => '2',
991
+ 'type' => 'content'
992
+ ),
993
+ 'block-3' => array(
994
+ 'params' => $autopostParams,
995
+ 'position' => '3',
996
+ 'type' => 'auto-post'
997
+ )
998
+ ),
999
+ 'footer' => array(
1000
+ 'text' => NULL,
1001
+ 'image' => array(
1002
+ 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
1003
+ 'width' => 600,
1004
+ 'height' => 86,
1005
+ 'alignment' => 'center',
1006
+ 'static' => true,
1007
+ ),
1008
+ 'alignment' => 'center',
1009
+ 'static' => true,
1010
+ 'type' => 'footer'
1011
+ )
1012
+ );
1013
+ } else {
1014
+ if(!isset($emaildata['params'])) {
1015
+ $emaildata['params'] = array();
1016
+ }
1017
+
1018
+ $emaildata['params']['quickselection'] = array(
1019
+ 'wp-301' => array(
1020
+ 'identifier' => 'wp-301',
1021
+ 'width' => 281,
1022
+ 'height' => 190,
1023
+ 'url' => WYSIJA_EDITOR_IMG . 'default-newsletter/newsletter/pigeon.png',
1024
+ 'thumb_url' => WYSIJA_EDITOR_IMG . 'default-newsletter/newsletter/pigeon-150x150.png'
1025
+ )
1026
+ );
1027
+
1028
+ if($theme_data['divider'] === null) {
1029
+ // default theme does not exist anymore or there is no divider associated to the theme
1030
+ // we need to get the default divider in this case
1031
+ $helper_dividers = WYSIJA::get('dividers', 'helper');
1032
+ $default_divider = $helper_dividers->getDefault();
1033
+ } else {
1034
+ // set default divider
1035
+ $default_divider = $theme_data['divider'];
1036
+ }
1037
+ // set default divider in email parameters
1038
+ $emaildata['params']['divider'] = $default_divider;
1039
+
1040
+ // get bookmarks from iconset 2
1041
+ $helper_bookmarks = WYSIJA::get('bookmarks', 'helper');
1042
+ $bookmarks = $helper_bookmarks->getAllByIconset('medium', '02');
1043
+
1044
+ // sample data for regular newsletter
1045
+ $newwjdata = array(
1046
+ 'version' => WYSIJA::get_version(),
1047
+ 'header' => array(
1048
+ 'text' => null,
1049
+ 'image' => array(
1050
+ // 'src' => WYSIJA_EDITOR_IMG.'default-newsletter/newsletter/header.png',
1051
+ 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
1052
+ 'width' => 600,
1053
+ 'height' => 86,
1054
+ 'alignment' => 'center',
1055
+ 'static' => true
1056
+ ),
1057
+ 'alignment' => 'center',
1058
+ 'static' => true,
1059
+ 'type' => 'header'
1060
+ ),
1061
+ 'body' => array(
1062
+ 'block-1' => array(
1063
+ 'text' => array(
1064
+ 'value' => '<h2><strong>' . __('Step 1:', WYSIJA) . '</strong> ' . __('hey, click on this text!', WYSIJA) . '</h2>' . '<p>' . __('To edit, simply click on this block of text.', WYSIJA) . '</p>'
1065
+ ),
1066
+ 'image' => null,
1067
+ 'alignment' => 'left',
1068
+ 'static' => false,
1069
+ 'position' => 1,
1070
+ 'type' => 'content'
1071
+ ),
1072
+ 'block-2' => array_merge(array(
1073
+ 'position' => 2,
1074
+ 'type' => 'divider'
1075
+ ),
1076
+ $default_divider
1077
+ ),
1078
+ 'block-3' => array(
1079
+ 'text' => array(
1080
+ 'value' => '<h2><strong>' . __('Step 2:', WYSIJA) . '</strong> ' . __('play with this image', WYSIJA) . '</h2>'
1081
+ ),
1082
+ 'image' => null,
1083
+ 'alignment' => 'left',
1084
+ 'static' => false,
1085
+ 'position' => 3,
1086
+ 'type' => 'content'
1087
+ ),
1088
+ 'block-4' => array(
1089
+ 'text' => array(
1090
+ 'value' => '<p>' . __('Position your mouse over the image to the left.', WYSIJA) . '</p>'
1091
+ ),
1092
+ 'image' => array(
1093
+ 'src' => WYSIJA_EDITOR_IMG . 'default-newsletter/newsletter/pigeon.png',
1094
+ 'width' => 281,
1095
+ 'height' => 190,
1096
+ 'alignment' => 'left',
1097
+ 'static' => false
1098
+ ),
1099
+ 'alignment' => 'left',
1100
+ 'static' => false,
1101
+ 'position' => 4,
1102
+ 'type' => 'content'
1103
+ ),
1104
+ 'block-5' => array_merge(array(
1105
+ 'position' => 5,
1106
+ 'type' => 'divider'
1107
+ ), $default_divider
1108
+ ),
1109
+ 'block-6' => array(
1110
+ 'text' => array(
1111
+ 'value' => '<h2><strong>' . __('Step 3:', WYSIJA) . '</strong> ' . __('drop content here', WYSIJA) . '</h2>' .
1112
+ '<p>' . sprintf(__('Drag and drop %1$stext, posts, dividers.%2$s Look on the right!', WYSIJA), '<strong>', '</strong>') . '</p>' .
1113
+ '<p>' . sprintf(__('You can even %1$ssocial bookmarks%2$s like these:', WYSIJA), '<strong>', '</strong>') . '</p>'
1114
+ ),
1115
+ 'image' => null,
1116
+ 'alignment' => 'left',
1117
+ 'static' => false,
1118
+ 'position' => 6,
1119
+ 'type' => 'content'
1120
+ ),
1121
+ 'block-7' => array(
1122
+ 'width' => 184,
1123
+ 'alignment' => 'center',
1124
+ 'items' => array(
1125
+ array_merge(array(
1126
+ 'url' => 'http://www.facebook.com/mailpoetplugin',
1127
+ 'alt' => 'Facebook',
1128
+ 'cellWidth' => 61,
1129
+ 'cellHeight' => 32
1130
+ ), $bookmarks['facebook']),
1131
+ array_merge(array(
1132
+ 'url' => 'http://www.twitter.com/mail_poet',
1133
+ 'alt' => 'Twitter',
1134
+ 'cellWidth' => 61,
1135
+ 'cellHeight' => 32
1136
+ ), $bookmarks['twitter']),
1137
+ array_merge(array(
1138
+ 'url' => 'https://plus.google.com/+Mailpoet',
1139
+ 'alt' => 'Google',
1140
+ 'cellWidth' => 61,
1141
+ 'cellHeight' => 32
1142
+ ), $bookmarks['google'])
1143
+ ),
1144
+ 'position' => 7,
1145
+ 'type' => 'gallery'
1146
+ ),
1147
+ 'block-8' => array_merge(array(
1148
+ 'position' => 8,
1149
+ 'type' => 'divider'
1150
+ ), $default_divider
1151
+ ),
1152
+ 'block-9' => array(
1153
+ 'text' => array(
1154
+ 'value' => '<h2><strong>' . __('Step 4:', WYSIJA) . '</strong> ' . __('and the footer?', WYSIJA) . '</h2>' .
1155
+ '<p>' . sprintf(__('Change the footer\'s content in MailPoet\'s %1$sSettings%2$s page.', WYSIJA), '<strong>', '</strong>') . '</p>'
1156
+ ),
1157
+ 'image' => null,
1158
+ 'alignment' => 'left',
1159
+ 'static' => false,
1160
+ 'position' => 9,
1161
+ 'type' => 'content'
1162
+ )
1163
+ ),
1164
+ 'footer' => array(
1165
+ 'text' => NULL,
1166
+ 'image' => array(
1167
+ // 'src' => WYSIJA_EDITOR_IMG.'default-newsletter/newsletter/footer.png',
1168
+ 'src' => WYSIJA_EDITOR_IMG . 'transparent.png',
1169
+ 'width' => 600,
1170
+ 'height' => 86,
1171
+ 'alignment' => 'center',
1172
+ 'static' => true,
1173
+ ),
1174
+ 'alignment' => 'center',
1175
+ 'static' => true,
1176
+ 'type' => 'footer'
1177
+ )
1178
+ );
1179
+ }
1180
+
1181
+ // set default styles
1182
+ $helper_engine = WYSIJA::get('wj_engine', 'helper');
1183
+ $styles = $helper_engine->getDefaultStyles();
1184
+ // end - set default styles
1185
+
1186
+ // set theme specific data
1187
+ if($theme_data['header'] !== null) {
1188
+ $newwjdata['header'] = $theme_data['header'];
1189
+ }
1190
+ if($theme_data['footer'] !== null) {
1191
+ $newwjdata['footer'] = $theme_data['footer'];
1192
+ }
1193
+ if($theme_data['divider'] !== null) {
1194
+ $newwjdata['widgets'] = array('divider' => $theme_data['divider']);
1195
+ }
1196
+ // end - set theme specific data
1197
+
1198
+ $emaildata['wj_data'] = base64_encode(serialize($newwjdata));
1199
+ $emaildata['wj_styles'] = base64_encode(serialize($styles));
1200
+
1201
+ $email_id = $data['email']['email_id'] = $modelEmail->insert($emaildata);
1202
+
1203
+ $this->notice(__('Newsletter successfully created.', WYSIJA));
1204
+ }
1205
+
1206
+ $this->_saveLists($campaign_id, true);
1207
+
1208
+ if (isset($_REQUEST['return']))
1209
+ $this->redirect();
1210
+ else {
1211
+ $this->redirect('admin.php?page=wysija_campaigns&action=editTemplate&id=' . $email_id);
1212
+ }
1213
+ }
1214
+
1215
+ function saveemail() {
1216
+ $this->redirectAfterSave = false;
1217
+ //$this->requireSecurity();
1218
+ $modelEmail = WYSIJA::get("email", "model");
1219
+ $modelEmail->fieldValid = false;
1220
+ $emaildataarr = $modelEmail->getOne(array('email_id' => $_REQUEST['id']));
1221
+
1222
+ if (isset($_REQUEST['save-reactivate'])) {
1223
+ //if the button save and reactivate has been clicked then we reactivate and redirect to the newsletter page
1224
+ $dataEmail['status'] = 99;
1225
+ $_REQUEST['return'] = 1;
1226
+ }
1227
+
1228
+ if (isset($_REQUEST['return']))
1229
+ $this->redirect();
1230
+ else {
1231
+ $this->redirect('admin.php?page=wysija_campaigns&action=editDetails&id=' . $emaildataarr['email_id']);
1232
+ }
1233
+ }
1234
+
1235
+ function savelast() {
1236
+ $this->redirectAfterSave = false;
1237
+ $post_notification = false;
1238
+ $this->requireSecurity();
1239
+
1240
+ if (!isset($_POST['wysija']['email']['from_name']) || !isset($_POST['wysija']['email']['from_email']) || !isset($_POST['wysija']['email']['replyto_name']) || !isset($_POST['wysija']['email']['replyto_email'])) {
1241
+ $this->error(__('Information is missing.', WYSIJA));
1242
+ return $this->editDetails();
1243
+ }
1244
+ if (isset($_REQUEST['wysija']['email']['params']['googletrackingcode']) && $_REQUEST['wysija']['email']['params']['googletrackingcode'] &&
1245
+ (!is_string($_REQUEST['wysija']['email']['params']['googletrackingcode']) OR
1246
+ preg_match('#[^a-z0-9_\-\s]#i', $_REQUEST['wysija']['email']['params']['googletrackingcode']) !== 0 )) {
1247
+ //force to simple text
1248
+ $_REQUEST['wysija']['email']['params']['googletrackingcode'] = preg_replace('#[^a-z0-9_\-\s]#i', '_', $_REQUEST['wysija']['email']['params']['googletrackingcode']);
1249
+ $this->error(__('Your Google Campaign can only contain latin characters, numbers, spaces and hyphens!', WYSIJA), 1);
1250
+ return $this->editDetails();
1251
+ }
1252
+
1253
+ $update_email = array(
1254
+ 'email_id' => $_POST['wysija']['email']['email_id'],
1255
+ 'from_name' => $_POST['wysija']['email']['from_name'],
1256
+ 'from_email' => $_POST['wysija']['email']['from_email'],
1257
+ 'replyto_name' => $_POST['wysija']['email']['replyto_name'],
1258
+ 'replyto_email' => $_POST['wysija']['email']['replyto_email'],
1259
+ 'subject' => $_POST['wysija']['email']['subject'],
1260
+ );
1261
+ $model_email = WYSIJA::get('email', 'model');
1262
+ if (isset($_POST['wysija']['email']['params']))
1263
+ $update_email['params'] = $_POST['wysija']['email']['params'];
1264
+
1265
+ //insert into campaigns lists
1266
+ $this->_saveLists($_POST['wysija']['campaign']['campaign_id']);
1267
+ $email_data = $model_email->getOne($_POST['wysija']['email']['email_id']);
1268
+
1269
+ // if we just save the draf we don't go through the big sending process setup
1270
+ if (isset($_POST['submit-draft']) || isset($_POST['submit-pause']) || (isset($_REQUEST['wj_redir']) && $_REQUEST['wj_redir'] == 'savelastback')) {
1271
+ if (isset($_POST['wysija']['email']['params']['schedule']['isscheduled']))
1272
+ $this->notice(__('Newsletter has been scheduled.', WYSIJA));
1273
+ else
1274
+ $this->notice(__('Newsletter has been saved as a draft.', WYSIJA));
1275
+ }else {
1276
+ // we update the param attribute with what's has been posted
1277
+ foreach ($update_email as $ki => $vi) {
1278
+ if ($ki == 'params') {
1279
+ foreach ($vi as $parake => $paraval) {
1280
+ $email_data['params'][$parake] = $paraval;
1281
+ }
1282
+ $update_email[$ki] = $email_data[$ki];
1283
+ }
1284
+ else
1285
+ $email_data[$ki] = $vi;
1286
+ }
1287
+
1288
+ // if the checkbox to ignore retroactivity is here we just tell the class
1289
+ if (isset($_POST['wysija']['email']['ignore_subscribers'])) {
1290
+ $model_email->retro_active_autoresponders = false;
1291
+ }
1292
+
1293
+ // activate or send the email depending on the typ
1294
+ $model_email->send_activate($email_data);
1295
+ }
1296
+
1297
+ // update email
1298
+ $update_email['type'] = $email_data['type'];
1299
+
1300
+ if ($post_notification) {
1301
+ $helper_autonews = WYSIJA::get('autonews', 'helper');
1302
+ $update_email['params']['autonl']['nextSend'] = $helper_autonews->getNextSend($update_email);
1303
+ }
1304
+
1305
+ $model_email->reset();
1306
+ $model_email->columns['modified_at']['autoup'] = 1;
1307
+
1308
+ // update some fields of the email
1309
+ $model_email->update($update_email);
1310
+
1311
+ // update the campaign subject which ispretty much useless but good to keep in sync with the email
1312
+ $model_campaign = WYSIJA::get('campaign', 'model');
1313
+ $model_campaign->reset();
1314
+ $update_campaign = array('campaign_id' => $_REQUEST['id'], 'name' => $_POST['wysija']['email']['subject']);
1315
+ $model_campaign->update($update_campaign);
1316
+
1317
+ if (isset($_REQUEST['wj_redir']) && $_REQUEST['wj_redir'] == 'savelastback') {
1318
+ return $this->redirect('admin.php?page=wysija_campaigns&action=editTemplate&id=' . $_POST['wysija']['email']['email_id']);
1319
+ }
1320
+ else
1321
+ return $this->redirect();
1322
+ }
1323
+
1324
+ function _saveLists($campaignId, $flagup = false) {
1325
+ //record the list that we have in that campaign
1326
+ $modelCampL = WYSIJA::get('campaign_list', 'model');
1327
+ if ($flagup || (int) $campaignId > 0) {
1328
+ $modelCampL->delete(array('equal' => array('campaign_id' => $campaignId)));
1329
+ $modelCampL->reset();
1330
+ }
1331
+
1332
+ if (isset($_POST['wysija']['campaign_list']['list_id'])) {
1333
+ //$modelCampL=WYSIJA::get("campaign_list","model");
1334
+ foreach ($_POST['wysija']['campaign_list']['list_id'] as $listid) {
1335
+ $modelCampL->insert(array('campaign_id' => $campaignId, "list_id" => $listid));
1336
+ }
1337
+ }
1338
+ }
1339
+
1340
+ function _addLinkFilter($status, $type = 'status') {
1341
+ switch ($type) {
1342
+ case 'status':
1343
+ switch ($status) {
1344
+ case 'draft':
1345
+ $this->filters['equal'] = array('status' => 0);
1346
+ break;
1347
+ case 'sending':
1348
+ $this->filters['equal'] = array('status' => 99);
1349
+ break;
1350
+ case 'sent':
1351
+ $this->filters['equal'] = array('status' => 2);
1352
+ break;
1353
+ case 'paused':
1354
+ $this->filters['equal'] = array('status' => -1);
1355
+ break;
1356
+ case 'scheduled':
1357
+ $this->filters['equal'] = array('status' => 4);
1358
+ break;
1359
+ }
1360
+ break;
1361
+ case 'type':
1362
+ switch ($status) {
1363
+ case 'regular':
1364
+ $this->filters['equal'] = array('type' => 1);
1365
+ break;
1366
+ case 'autonl':
1367
+ $this->filters['equal'] = array('type' => 2);
1368
+ break;
1369
+ }
1370
+ break;
1371
+ }
1372
+ }
1373
+
1374
+ /**
1375
+ * Get all campaigns, based on the filters
1376
+ */
1377
+ protected function get_campaigns() {
1378
+ $order_by = ' ORDER BY ';
1379
+
1380
+ if (isset($_REQUEST['orderby'])) {
1381
+ if (!is_string($_REQUEST['orderby']) OR preg_match('|[^a-z0-9#_.-]|i', $_REQUEST['orderby']) !== 0) {
1382
+ $_REQUEST['orderby'] = '';
1383
+ }
1384
+ if (!in_array(strtoupper($_REQUEST['ordert']), array('DESC', 'ASC')))
1385
+ $_REQUEST['ordert'] = 'DESC';
1386
+ $order_by.=$_REQUEST['orderby'] . ' ' . $_REQUEST['ordert'];
1387
+ }else {
1388
+ $order_by.='FIELD(B.status, 99,3,1,0,2), ';
1389
+ $order_by.='B.status desc, ';
1390
+ $order_by.='B.modified_at desc, ';
1391
+ $order_by.='B.sent_at desc, ';
1392
+ $order_by.='B.type desc, ';
1393
+ $order_by.='A.' . $this->modelObj->getPk() . ' DESC';
1394
+ }
1395
+
1396
+ $query = '
1397
+ SELECT
1398
+ A.`campaign_id`,
1399
+ A.`name` as `campaign_name`,
1400
+ B.`subject` as `name`,
1401
+ A.`description`,
1402
+ B.`params`,
1403
+ B.`type`,
1404
+ B.`number_sent`,
1405
+ B.`number_opened`,
1406
+ B.`number_clicked`,
1407
+ B.`number_unsub`,
1408
+ (B.`number_sent` +
1409
+ B.`number_opened` +
1410
+ B.`number_clicked` +
1411
+ B.`number_unsub` +
1412
+ B.`number_bounce` +
1413
+ B.`number_forward`
1414
+ ) AS `number_total`,
1415
+ B.`status`,
1416
+ B.`created_at`,
1417
+ B.`modified_at`,
1418
+ B.`sent_at`,
1419
+ B.`email_id`
1420
+ FROM
1421
+ `[wysija]' . $this->modelObj->table_name . '` AS A
1422
+ LEFT JOIN
1423
+ `[wysija]email` AS B on A.`campaign_id` = B.`campaign_id`
1424
+ LEFT JOIN
1425
+ `[wysija]campaign_list` AS C on A.`campaign_id` = C.`campaign_id`';
1426
+ $campaigns = $this->modelObj->getResults($query . $this->modelObj->makeWhere() . ' GROUP BY B.email_id' . $order_by . $this->modelObj->setLimit());
1427
+
1428
+ // calculate percetange of open / click / unsubscribe
1429
+ $helper_numbers = WYSIJA::get('numbers', 'helper');
1430
+ foreach ($campaigns as &$campaign) {
1431
+ // open rate, based on sent number
1432
+ $campaign['rate_opened'] = $helper_numbers->calculate_percetage($campaign['number_opened'], $campaign['number_total'], 1);
1433
+ // click rate, based on opened number
1434
+ $campaign['rate_clicked'] = $helper_numbers->calculate_percetage($campaign['number_clicked'], $campaign['number_total'], 1);
1435
+ // unsubscribe rate, based on opened number
1436
+ $campaign['rate_unsub'] = $helper_numbers->calculate_percetage($campaign['number_unsub'], $campaign['number_total'], 1);
1437
+ }
1438
+ return $campaigns;
1439
+ }
1440
+
1441
+ /**
1442
+ * Get the first campaign in history
1443
+ */
1444
+ protected function get_oldest_compaign() {
1445
+ $query = '
1446
+ SELECT
1447
+ MIN(B.created_at) as datemin
1448
+ FROM `[wysija]' . $this->modelObj->table_name . '` as A
1449
+ LEFT JOIN
1450
+ `[wysija]email` AS B on A.campaign_id = B.campaign_id
1451
+ LEFT JOIN
1452
+ `[wysija]campaign_list` as C on A.campaign_id = C.campaign_id';
1453
+
1454
+ return $this->modelObj->query('get_row', $query . $this->modelObj->makeWhere());
1455
+ }
1456
+
1457
+ /**
1458
+ * Count ALL emails of each email-status
1459
+ * @todo: move to model
1460
+ */
1461
+ protected function count_emails_by_status() {
1462
+ $query = '
1463
+ SELECT
1464
+ COUNT(`email_id`) AS `campaigns`,
1465
+ `status`
1466
+ FROM
1467
+ `[wysija]email`
1468
+ WHERE
1469
+ `campaign_id` > 0
1470
+ GROUP BY `status`';
1471
+
1472
+ $countss = $this->modelObj->query('get_res', $query);
1473
+ $counts = array();
1474
+ $total = 0;
1475
+
1476
+ foreach ($countss as $count) {
1477
+ switch ($count['status']) {
1478
+ case '0':
1479
+ $type = 'draft';
1480
+ break;
1481
+ case '1':
1482
+ case '3':
1483
+ case '99':
1484
+ $type = 'sending';
1485
+ break;
1486
+ case '2':
1487
+ $type = 'sent';
1488
+ break;
1489
+ case '-1':
1490
+ $type = 'paused';
1491
+ break;
1492
+ case '4':
1493
+ $type = 'scheduled';
1494
+ break;
1495
+ }
1496
+ $total = $total + $count['campaigns'];
1497
+ $counts['status-' . $type] = $count['campaigns'];
1498
+ }
1499
+ return $counts;
1500
+ }
1501
+
1502
+ /**
1503
+ * Count emails which matched the filters
1504
+ */
1505
+ protected function count_emails() {
1506
+ $query = '
1507
+ SELECT
1508
+ COUNT(DISTINCT B.`email_id`) AS `campaigns`
1509
+ FROM
1510
+ `[wysija]' . $this->modelObj->table_name . '` AS A
1511
+ LEFT JOIN
1512
+ `[wysija]email` AS B ON A.`campaign_id` = B.`campaign_id`
1513
+ LEFT JOIN
1514
+ `[wysija]campaign_list` AS C ON A.`campaign_id` = C.`campaign_id`';
1515
+ return $this->modelObj->count($query . $this->modelObj->makeWhere(), 'campaigns');
1516
+ }
1517
+
1518
+ /**
1519
+ * Count ALL emails of each type of email
1520
+ */
1521
+ protected function count_emails_by_type() {
1522
+ $query = '
1523
+ SELECT
1524
+ COUNT(`email_id`) AS `campaigns`,
1525
+ `type`
1526
+ FROM
1527
+ `[wysija]email`
1528
+ WHERE
1529
+ `campaign_id` > 0
1530
+ GROUP BY `type`';
1531
+ $countss = $this->modelObj->query('get_res', $query, ARRAY_A);
1532
+ $counts = array();
1533
+ foreach ($countss as $count) {
1534
+ switch ($count['type']) {
1535
+ case '1':
1536
+ $type = 'regular';
1537
+ break;
1538
+ case '2':
1539
+ $type = 'autonl';
1540
+ break;
1541
+ }
1542
+ $counts['type-' . $type] = $count['campaigns'];
1543
+ }
1544
+ return $counts;
1545
+ }
1546
+
1547
+ /**
1548
+ * Get all existing lists
1549
+ */
1550
+ protected function get_lists() {
1551
+ $model_list = WYSIJA::get('list', 'model');
1552
+ $query = '
1553
+ SELECT
1554
+ A.`list_id`,
1555
+ A.`name`,
1556
+ A.`is_enabled`,
1557
+ COUNT( B.`campaign_id` ) AS `users`
1558
+ FROM
1559
+ `[wysija]' . $model_list->table_name . '` as A
1560
+ LEFT JOIN
1561
+ `[wysija]campaign_list` AS B on A.`list_id` = B.`list_id`
1562
+ GROUP BY A.`list_id`';
1563
+ $result = $model_list->getResults($query);
1564
+ $lists = array();
1565
+ foreach ($result as $list_obj) {
1566
+ $lists[$list_obj['list_id']] = $list_obj;
1567
+ }
1568
+ return $lists;
1569
+ }
1570
+
1571
+ function defaultDisplay() {
1572
+ $this->data['base_url'] = $this->base_url . '?' . http_build_query($_REQUEST); // saved filter
1573
+ $this->title = __('Newsletters', WYSIJA);
1574
+ $this->viewShow = $this->action = 'main';
1575
+ $this->js[] = 'wysija-admin-list';
1576
+ $this->jsTrans["selecmiss"] = __('Please select a newsletter.', WYSIJA);
1577
+ $this->jsTrans['suredelete'] = __('Delete this newsletter for ever?', WYSIJA);
1578
+ $this->jsTrans['suredelete_bulk'] = __('Delete these newsletters for ever?', WYSIJA);
1579
+ $this->jsTrans['processqueue'] = __('Sending batch of emails...', WYSIJA);
1580
+ $this->jsTrans['viewnews'] = __('View newsletter', WYSIJA);
1581
+ $this->jsTrans['confirmpauseedit'] = __('The newsletter will be deactivated, you will need to reactivate it once you\'re over editing it. Do you want to proceed?', WYSIJA);
1582
+
1583
+
1584
+ //get the filters
1585
+ if (isset($_REQUEST['search']) && $_REQUEST['search']) {
1586
+ $this->filters['like'] = array();
1587
+ foreach ($this->searchable as $field)
1588
+ $this->filters['like'][$field] = $_REQUEST['search'];
1589
+ }
1590
+
1591
+ if (isset($_REQUEST['filter-list']) && $_REQUEST['filter-list']) {
1592
+ $this->filters['equal'] = array('C.list_id' => $_REQUEST['filter-list']);
1593
+ }
1594
+
1595
+ if (isset($_REQUEST['filter-date']) && $_REQUEST['filter-date']) {
1596
+ $this->filters['greater_eq'] = array('created_at' => $_REQUEST['filter-date']);
1597
+ $this->filters['less_eq'] = array('created_at' => strtotime('+1 month', $_REQUEST['filter-date']));
1598
+ }
1599
+
1600
+ $this->filters['is'] = array('type' => 'IS NOT NULL');
1601
+
1602
+
1603
+ if (isset($_REQUEST['link_filter']) && $_REQUEST['link_filter']) {
1604
+ $linkfilters = explode('-', $_REQUEST['link_filter']);
1605
+
1606
+ if (count($linkfilters) > 1) {
1607
+ $this->_addLinkFilter($linkfilters[1], $linkfilters[0]);
1608
+ } else {
1609
+ $this->_addLinkFilter($_REQUEST['link_filter']);
1610
+ }
1611
+ }
1612
+
1613
+ $this->modelObj->noCheck = true;
1614
+ $this->modelObj->reset();
1615
+ if ($this->filters)
1616
+ $this->modelObj->setConditions($this->filters);
1617
+
1618
+
1619
+ // Count emails by status and type
1620
+ $emails_by_status = $this->count_emails_by_status();
1621
+ $emails_by_type = $this->count_emails_by_type();
1622
+ $counts = array_merge($emails_by_status, $emails_by_type);
1623
+ $counts['all'] = array_sum($emails_by_status);
1624
+
1625
+ // collect data
1626
+ $this->data['campaigns'] = $this->get_campaigns();
1627
+ $this->data['datemin'] = $this->get_oldest_compaign();
1628
+ $lists = $this->get_lists(); // $lists is in use later within this scope
1629
+ $this->data['lists'] = $lists;
1630
+
1631
+ // for paging
1632
+ $this->modelObj->countRows = $this->filters ? $this->count_emails () : $counts['all'];
1633
+
1634
+
1635
+ // count queue
1636
+ $email_ids = array();
1637
+ foreach ($this->data['campaigns'] as $emailcamp) {
1638
+ if (in_array($emailcamp['status'], array(1, 3, 99)))
1639
+ $email_ids[] = $emailcamp['email_id'];
1640
+ }
1641
+ $model_queue = WYSIJA::get('queue', 'model');
1642
+ $model_queue->setConditions(array("email_id" => $email_ids));
1643
+ $model_queue->groupBy('email_id');
1644
+ $queue = $model_queue->count();
1645
+ if ($queue) {
1646
+ $this->viewObj->queuedemails = $queue;
1647
+ }
1648
+
1649
+ $this->modelObj->reset();
1650
+
1651
+ //make a loop from the first created to now and increment an array of months
1652
+ $now = time();
1653
+ $this->data['dates'] = array();
1654
+
1655
+ if ((int) $this->data['datemin']['datemin'] > 1) {
1656
+ setlocale(LC_TIME, 'en_US');
1657
+ $formtlettres = "1 " . date('F', $this->data['datemin']['datemin']) . ' ' . date("Y", $this->data['datemin']['datemin']);
1658
+ $month_start = strtotime($formtlettres);
1659
+
1660
+ if ($month_start > 0) {
1661
+ for ($i = $month_start; $i < $now; $i = strtotime('+1 month', $i)) {
1662
+ $this->data['dates'][$i] = date_i18n('F Y', $i); //date('F Y',$i);
1663
+ }
1664
+ }
1665
+ }
1666
+
1667
+
1668
+
1669
+ $campaign_ids_sent = $campaign_ids = array();
1670
+ foreach ($this->data['campaigns'] as &$campaign) {
1671
+ $campaign_ids[] = $campaign['campaign_id'];
1672
+ $modelEmail = WYSIJA::get('email', 'model');
1673
+ $modelEmail->getParams($campaign);
1674
+ if (in_array((int) $campaign['status'], array(-1, 1, 2, 3, 99)))
1675
+ $campaign_ids_sent[] = $campaign['campaign_id'];
1676
+ }
1677
+
1678
+ // 3 - campaign_list request & count request for queue */
1679
+ if ($campaign_ids) {
1680
+ $modeluList = WYSIJA::get('campaign_list', 'model');
1681
+ $userlists = $modeluList->get(array('list_id', 'campaign_id'), array('campaign_id' => $campaign_ids));
1682
+
1683
+ if ($campaign_ids_sent) {
1684
+ $modeluList = WYSIJA::get("email_user_stat", "model");
1685
+ $statstotal = $modeluList->getResults("SELECT COUNT(A.user_id) as count,B.email_id FROM `[wysija]queue` as A
1686
+ JOIN `[wysija]email` as B on A.email_id=B.email_id
1687
+ WHERE B.campaign_id IN (" . implode(",", $campaign_ids_sent) . ") group by B.email_id");
1688
+
1689
+ $senttotalgroupedby = $modeluList->getResults("SELECT COUNT(A.user_id) as count,B.campaign_id,B.email_id,B.type,B.status,A.status as statususer FROM `[wysija]" . $modeluList->table_name . "` as A
1690
+ JOIN `[wysija]email` as B on A.email_id=B.email_id
1691
+ WHERE B.campaign_id IN (" . implode(",", $campaign_ids_sent) . ") group by A.status,B.email_id"); //,A.status
1692
+
1693
+
1694
+ $updateEmail = array();
1695
+ $columnnamestatus = array(0 => "number_sent", 1 => "number_opened", 2 => "number_clicked", 3 => "number_unsub", -1 => "number_bounce");
1696
+ foreach ($senttotalgroupedby as $sentbystatus) {
1697
+ if ($sentbystatus['statususer'] != "-2")
1698
+ $updateEmail[$sentbystatus['email_id']][$columnnamestatus[$sentbystatus['statususer']]] = $sentbystatus['count'];
1699
+ if (isset($senttotal[$sentbystatus['email_id']])) {
1700
+ $senttotal[$sentbystatus['email_id']]['count'] = (int) $senttotal[$sentbystatus['email_id']]['count'] + (int) $sentbystatus['count'];
1701
+ } else {
1702
+ unset($sentbystatus['statususer']);
1703
+ $senttotal[$sentbystatus['email_id']] = $sentbystatus;
1704
+ }
1705
+ }
1706
+
1707
+ $modelEmail = WYSIJA::get('email', 'model');
1708
+
1709
+ foreach ($updateEmail as $emailid => $update) {
1710
+
1711
+ foreach ($columnnamestatus as $v) {
1712
+ if (!isset($update[$v]))
1713
+ $update[$v] = 0;
1714
+ }
1715
+
1716
+ $modelEmail->update($update, array('email_id' => $emailid));
1717
+ $modelEmail->reset();
1718
+ }
1719
+
1720
+
1721
+ /**/
1722
+ $modelC = WYSIJA::get('config', 'model');
1723
+ $running = false;
1724
+
1725
+ $is_multisite = is_multisite();
1726
+
1727
+ //$is_multisite=true;//PROD comment that line
1728
+ if ($is_multisite && $modelC->getValue('sending_method') == 'network') {
1729
+ $sending_emails_each = $modelC->getValue('ms_sending_emails_each');
1730
+ } else {
1731
+ $sending_emails_each = $modelC->getValue('sending_emails_each');
1732
+ }
1733
+
1734
+ if ($modelC->getValue('cron_manual')) {
1735
+ $formsHelp = WYSIJA::get('forms', 'helper');
1736
+ $queue_frequency = $formsHelp->eachValuesSec[$sending_emails_each];
1737
+ $queue_scheduled = WYSIJA::get_cron_schedule('queue');
1738
+
1739
+ $next_scheduled_queue = $queue_scheduled['next_schedule'];
1740
+ $running = $queue_scheduled['running'];
1741
+
1742
+ if ($running) {
1743
+ $helperToolbox = WYSIJA::get('toolbox', 'helper');
1744
+ $running = time() - $running;
1745
+ $running = $helperToolbox->duration_string($running, true, 4);
1746
+ }
1747
+ } else {
1748
+ $schedules = wp_get_schedules();
1749
+ $queue_frequency = $schedules[wp_get_schedule('wysija_cron_queue')]['interval'];
1750
+ $next_scheduled_queue = wp_next_scheduled('wysija_cron_queue');
1751
+ }
1752
+
1753
+
1754
+
1755
+ $status_sent_complete = array();
1756
+ if (isset($senttotal) && $senttotal) {
1757
+ foreach ($senttotal as $sentot) {
1758
+ if ($sentot) {
1759
+ $this->data['sent'][$sentot['email_id']]['total'] = $sentot['count'];
1760
+ $this->data['sent'][$sentot['email_id']]['to'] = $sentot['count'];
1761
+ } else {
1762
+ $this->data['sent'][$sentot['email_id']]['total'] = $this->data['sent'][$sentot['email_id']]['to'] = 0;
1763
+ }
1764
+ $this->data['sent'][$sentot['email_id']]['status'] = $sentot['status'];
1765
+ $this->data['sent'][$sentot['email_id']]['type'] = $sentot['type'];
1766
+ $this->data['sent'][$sentot['email_id']]['left'] = (int) $this->data['sent'][$sentot['email_id']]['total'] - (int) $this->data['sent'][$sentot['email_id']]['to'];
1767
+ }
1768
+ }
1769
+
1770
+ foreach ($statstotal as $sentot) {
1771
+ if (!isset($this->data['sent'][$sentot['email_id']])) {
1772
+ $this->data['sent'][$sentot['email_id']]['total'] = 0;
1773
+ $this->data['sent'][$sentot['email_id']]['to'] = 0;
1774
+ }
1775
+ $this->data['sent'][$sentot['email_id']]['total'] = $this->data['sent'][$sentot['email_id']]['total'] + $sentot['count'];
1776
+ $this->data['sent'][$sentot['email_id']]['left'] = (int) $this->data['sent'][$sentot['email_id']]['total'] - (int) $this->data['sent'][$sentot['email_id']]['to'];
1777
+ }
1778
+
1779
+ //$is_multisite=true;//PROD comment that line
1780
+ if ($is_multisite && $modelC->getValue('sending_method') == 'network') {
1781
+ $sending_emails_number = $modelC->getValue('ms_sending_emails_number');
1782
+ } else {
1783
+ $sending_emails_number = $modelC->getValue('sending_emails_number');
1784
+ }
1785
+
1786
+ if (isset($this->data['sent'])) {
1787
+ foreach ($this->data['sent'] as $key => &$camp) {
1788
+ if ($this->data['sent'][$key]['left'] > 0) {
1789
+ $cronsneeded = ceil($this->data['sent'][$key]['left'] / $sending_emails_number);
1790
+ $this->data['sent'][$key]['remaining_time'] = $cronsneeded * $queue_frequency;
1791
+ $this->data['sent'][$key]['running_for'] = $running;
1792
+ $this->data['sent'][$key]['next_batch'] = $next_scheduled_queue - time();
1793
+ $this->data['sent'][$key]['remaining_time'] = $this->data['sent'][$key]['remaining_time'] - ($queue_frequency) + $this->data['sent'][$key]['next_batch'];
1794
+ } else {
1795
+ if ((in_array($this->data['sent'][$key]['status'], array(1, 3, 99))) && $this->data['sent'][$key]['type'] == 1)
1796
+ $status_sent_complete[] = $key;
1797
+ }
1798
+ }
1799
+ }
1800
+
1801
+
1802
+ // status update to sent for the one that are sent
1803
+ if (count($status_sent_complete) > 0) {
1804
+ $modelEmail = WYSIJA::get('email', 'model');
1805
+ $modelEmail->noCheck = true;
1806
+ $modelEmail->reset();
1807
+ $modelEmail->update(array('status' => 2), array('equal' => array('email_id' => $status_sent_complete)));
1808
+ }
1809
+ }
1810
+ }
1811
+
1812
+ $this->data['counts'] = array_reverse($counts);
1813
+
1814
+ /* regrouping all the data in the same array */
1815
+ foreach ($this->data['campaigns'] as &$campaign) {
1816
+ /* default key while we don't have the data */
1817
+ //TODO add data for stats about emails opened clicked etc
1818
+ $campaign["emails"] = 0;
1819
+ $campaign["opened"] = 0;
1820
+ $campaign["clicked"] = 0;
1821
+
1822
+ if ($userlists) {
1823
+ foreach ($userlists as $key => $userlist) {
1824
+ if ($campaign["campaign_id"] == $userlist["campaign_id"] && isset($lists[$userlist["list_id"]])) {
1825
+ if (!isset($campaign["lists"]))
1826
+ $campaign["lists"] = $lists[$userlist["list_id"]]["name"];
1827
+ else
1828
+ $campaign["lists"].=", " . $lists[$userlist["list_id"]]["name"];
1829
+ }
1830
+ }
1831
+ }
1832
+ if (isset($campaign["lists"]) && !$campaign["lists"])
1833
+ unset($campaign["lists"]);
1834
+
1835
+ if (((isset($campaign['params']['schedule']['isscheduled']) ||
1836
+ ($campaign['type'] == 2 && isset($campaign['params']['autonl']['event']) && in_array($campaign['params']['autonl']['event'], array('new-articles'/* ,'subs-2-nl' */)))
1837
+ ) && $campaign['status'] != 2 && !isset($campaign["lists"])) || ($campaign['type'] == 2 && isset($campaign['params']['autonl']['event']) && in_array($campaign['params']['autonl']['event'], array('subs-2-nl')) && $campaign['status'] != 2 && (!isset($campaign['params']['autonl']['subscribetolist']) || !isset($lists[$campaign['params']['autonl']['subscribetolist']]) ))
1838
+ ) {
1839
+ $campaign['classRow'] = " listmissing ";
1840
+ $campaign['msgListEdit'] = '<strong>' . __('The list has been deleted.', WYSIJA) . '</strong>';
1841
+ $campaign['msgSendSuspended'] = '<strong>' . __('Sending suspended.', WYSIJA) . '</strong>';
1842
+ }
1843
+ }
1844
+
1845
+ $this->dataAutoNl();
1846
+ if (!$this->data['campaigns']) {
1847
+ $this->notice(__('There are no newsletters.', WYSIJA));
1848
+ }
1849
+ }
1850
+
1851
+ function setviewStatsfilter() {
1852
+ /* get the filters */
1853
+ $this->searchable = array("email", "firstname", "lastname");
1854
+ $this->filters = array();
1855
+ if (isset($_REQUEST['search']) && $_REQUEST['search']) {
1856
+ $this->filters["like"] = array();
1857
+ foreach ($this->searchable as $field)
1858
+ $this->filters["like"][$field] = $_REQUEST['search'];
1859
+ }
1860
+ $this->tableQuery = 'email_user_stat';
1861
+ $this->statusemail = 'B.status as umstatus';
1862
+ if (isset($_REQUEST['link_filter']) && $_REQUEST['link_filter']) {
1863
+ switch ($_REQUEST['link_filter']) {
1864
+ case 'inqueue':
1865
+ $this->tableQuery = 'queue';
1866
+ $this->statusemail = '-2 as umstatus';
1867
+ break;
1868
+ case 'sent':
1869
+ $this->filters['equal'] = array('B.status' => 0);
1870
+ break;
1871
+ case 'bounced':
1872
+ $this->filters['equal'] = array('B.status' => -1);
1873
+ break;
1874
+ case 'opened':
1875
+ $this->filters['equal'] = array('B.status' => 1);
1876
+ break;
1877
+ case 'clicked':
1878
+ $this->filters['equal'] = array('B.status' => 2);
1879
+ break;
1880
+ case 'unsubscribe':
1881
+ $this->filters['equal'] = array('B.status' => 3);
1882
+ break;
1883
+ case 'notsent':
1884
+ $this->filters['equal'] = array('B.status' => -2);
1885
+ break;
1886
+ }
1887
+ }
1888
+ // filter by url id
1889
+ if (isset($_REQUEST['url_id']) && (int) $_REQUEST['url_id'] > 0) {
1890
+ $this->tableQuery = 'email_user_url';
1891
+ $this->filters['equal'] = array('B.url_id' => (int) $_REQUEST['url_id']);
1892
+ $this->statusemail = '2 as umstatus'; //by default, when filter by url_id, all subscribers had clicked
1893
+ }
1894
+ }
1895
+
1896
+ function viewstats() {
1897
+ $this->js[] = 'wysija-admin-list';
1898
+ $this->js[] = 'wysija-charts';
1899
+ $this->viewShow = 'viewstats';
1900
+
1901
+ $this->modelObj = WYSIJA::get("email", "model");
1902
+ $this->modelObj->limitON = false;
1903
+
1904
+ $email_object = $this->modelObj->getOne(false, array("email_id" => $_REQUEST['id']));
1905
+ $this->viewObj->model = $this->modelObj;
1906
+ $this->viewObj->namecampaign = $email_object['subject'];
1907
+ $this->viewObj->title = sprintf(__('Stats : %1$s', WYSIJA), $email_object['subject']);
1908
+
1909
+ $modelObjCamp = WYSIJA::get("campaign", "model");
1910
+ $limit_pp = false;
1911
+ if (isset($modelObjCamp->limit_pp))
1912
+ $limit_pp = $modelObjCamp->limit_pp;
1913
+ $modelObjCamp->limitON = false;
1914
+ $campaign = $modelObjCamp->getOne(false, array("campaign_id" => $email_object['campaign_id']));
1915
+
1916
+
1917
+ $this->setviewStatsfilter();
1918
+
1919
+ $this->modelObj->reset();
1920
+ $this->modelObj->noCheck = true;
1921
+
1922
+ /* 0 - counting request */
1923
+ $queryCmmonStart = 'SELECT count(distinct B.user_id) as users FROM `[wysija]user` as A';
1924
+ $queryCmmonStart.=' LEFT JOIN `[wysija]' . $this->tableQuery . '` as B on A.user_id=B.user_id';
1925
+
1926
+ /* all the counts query */
1927
+ $query = "SELECT count(user_id) as users, status FROM `[wysija]email_user_stat` as A
1928
+ WHERE A.email_id=" . $email_object['email_id'] . " GROUP BY status";
1929
+ $countss = $this->modelObj->query("get_res", $query, ARRAY_A);
1930
+
1931
+ /* we also count what is in the queue */
1932
+ $query = "SELECT count(user_id) as users FROM `[wysija]queue` as A
1933
+ WHERE A.email_id=" . $email_object['email_id'];
1934
+ $countss[-2]['status'] = -3;
1935
+ $countss[-2]['users'] = $this->modelObj->count($query, 'users');
1936
+
1937
+ $counts = array();
1938
+ $truetotal = $total = 0;
1939
+
1940
+ foreach ($countss as $count) {
1941
+ switch ($count['status']) {
1942
+ case "-3":
1943
+ $type = 'inqueue';
1944
+ break;
1945
+ case "-2":
1946
+ $type = 'notsent';
1947
+ break;
1948
+ case "-1":
1949
+ $type = 'bounced';
1950
+ break;
1951
+ case "0":
1952
+ $type = 'sent';
1953
+ break;
1954
+ case "1":
1955
+ $type = 'opened';
1956
+ break;
1957
+ case "2":
1958
+ $type = 'clicked';
1959
+ break;
1960
+ case "3":
1961
+ $type = 'unsubscribe';
1962
+ break;
1963
+ }
1964
+ if ($count['status'] != "-2")
1965
+ $total = $total + $count['users'];
1966
+ $truetotal = $truetotal + $count['users'];
1967
+ $counts[$type] = $count['users'];
1968
+ }
1969
+
1970
+ $counts['allsent'] = $total;
1971
+ $counts['all'] = $truetotal;
1972
+
1973
+ $this->modelObj->reset();
1974
+ $this->filters['equal']["B.email_id"] = $email_object['email_id'];
1975
+
1976
+ $this->modelObj->noCheck = true;
1977
+ if ($this->filters)
1978
+ $this->modelObj->setConditions($this->filters);
1979
+
1980
+ //$this->modelObj->setConditions(array("equal"=>array("B.email_id"=>$emailObj['email_id'])));
1981
+
1982
+ /* 1 - subscriber request */
1983
+ $query = 'SELECT A.user_id, A.firstname, A.lastname,A.status as ustatus,' . $this->statusemail . ' , A.email, B.* FROM `[wysija]user` as A';
1984
+ $query.=' LEFT JOIN `[wysija]' . $this->tableQuery . '` as B on A.user_id=B.user_id';
1985
+ $queryFinal = $this->modelObj->makeWhere();
1986
+
1987
+ /* without filter we already have the total number of subscribers */
1988
+ if ($this->filters)
1989
+ $this->modelObj->countRows = $this->modelObj->count($queryCmmonStart . $queryFinal, 'users');
1990
+ else
1991
+ $this->modelObj->countRows = $counts['all'];
1992
+
1993
+ $orderby = " ORDER BY ";
1994
+ /**
1995
+ * Until now, we have
1996
+ * - 3 possible values of $this->tableQuery (queue, email_user_url, email_user_stat), set by $this->setviewStatsfilter()
1997
+ * - 2 possible values of $_REQUEST['orderby']
1998
+ * => 3x2 = 6 cases
1999
+ */
2000
+ if (isset($_REQUEST['orderby'])) {
2001
+ switch ($this->tableQuery) {
2002
+ case 'email_user_url':
2003
+ case 'email_user_stat':
2004
+ $orderby .= 'B.' . $_REQUEST['orderby'] . " " . $_REQUEST['ordert'];
2005
+ break;
2006
+
2007
+ case 'queue':
2008
+ default:
2009
+ $orderby .= 'A.user_id DESC';
2010
+ break;
2011
+ }
2012
+ } else {
2013
+ switch ($this->tableQuery) {
2014
+ case 'email_user_url':
2015
+ $orderby .= 'B.clicked_at DESC, B.number_clicked DESC'; // by default, sort by last clicked and biggest hit
2016
+ break;
2017
+
2018
+ case 'email_user_stat':
2019
+ $orderby .= 'B.opened_at DESC, B.status DESC'; // by default, sort by last open and its staus value
2020
+ break;
2021
+
2022
+ case 'queue':
2023
+ default:
2024
+ $orderby .= 'A.user_id DESC';
2025
+ break;
2026
+ }
2027
+ }
2028
+ $this->data['tableQuery'] = $this->tableQuery;
2029
+ $this->modelObj->limitON = true;
2030
+
2031
+ $subscribers = array();
2032
+ $hook_params = array(
2033
+ 'email_id' => $email_object['email_id'],
2034
+ 'url_id' => isset($_REQUEST['url_id']) && $_REQUEST['url_id'] ? $_REQUEST['url_id'] : false,
2035
+ 'subscribers' => &$subscribers
2036
+ );
2037
+ $this->data['subscribers'] = $this->modelObj->getResults($query . $queryFinal . " GROUP BY A.user_id" . $orderby . $this->modelObj->setLimit(0, (int)$limit_pp));
2038
+ $this->modelObj->reset();
2039
+
2040
+ /* make the data object for the listing view */
2041
+ $modelList = WYSIJA::get("list", "model");
2042
+
2043
+ /* 2 - list request */
2044
+ $query = "SELECT A.list_id, A.name,A.is_enabled, count( B.user_id ) AS users FROM `[wysija]" . $modelList->table_name . "` as A";
2045
+ $query.=" LEFT JOIN `[wysija]user_list` as B on A.list_id = B.list_id";
2046
+ $query.=" GROUP BY A.list_id";
2047
+ $listsDB = $modelList->getResults($query);
2048
+
2049
+ $lists = array();
2050
+ foreach ($listsDB as $listobj) {
2051
+ $lists[$listobj["list_id"]] = $listobj;
2052
+ }
2053
+
2054
+ $listsDB = null;
2055
+
2056
+ $user_ids = array();
2057
+ foreach ($this->data['subscribers'] as $subscriber) {
2058
+ $user_ids[] = $subscriber['user_id'];
2059
+ }
2060
+
2061
+ /* 3 - user_list request */
2062
+ if ($user_ids) {
2063
+ $modeluList = WYSIJA::get("user_list", "model");
2064
+ $userlists = $modeluList->get(array("list_id", "user_id"), array("user_id" => $user_ids));
2065
+ }
2066
+
2067
+
2068
+ $this->data['lists'] = $lists;
2069
+ $this->data['counts'] = array_reverse($counts);
2070
+
2071
+ /* regrouping all the data in the same array */
2072
+ foreach ($this->data['subscribers'] as $keysus => $subscriber) {
2073
+ /* default key while we don't have the data */
2074
+ //TODO add data for stats about emails opened clicked etc
2075
+ $this->data['subscribers'][$keysus]["emails"] = 0;
2076
+ $this->data['subscribers'][$keysus]["opened"] = 0;
2077
+ $this->data['subscribers'][$keysus]["clicked"] = 0;
2078
+
2079
+ if ($userlists) {
2080
+ foreach ($userlists as $key => $userlist) {
2081
+ if ($subscriber["user_id"] == $userlist["user_id"] && isset($lists[$userlist["list_id"]])) {
2082
+ if (!isset($this->data['subscribers'][$keysus]["lists"]))
2083
+ $this->data['subscribers'][$keysus]["lists"] = $lists[$userlist["list_id"]]["name"];
2084
+ else
2085
+ $this->data['subscribers'][$keysus]["lists"].=", " . $lists[$userlist["list_id"]]["name"];
2086
+ }
2087
+ }
2088
+ }
2089
+ }
2090
+
2091
+ $this->data['email'] = $email_object;
2092
+
2093
+ if (!$this->data['subscribers']) {
2094
+ $this->notice(__("Your request can't retrieve any subscribers. Change your filters!", WYSIJA));
2095
+ }
2096
+
2097
+ // execute hooks
2098
+ $hook_params = array(
2099
+ 'email_id' => $_REQUEST['id'],
2100
+ 'email_object' => $email_object,
2101
+ 'url_id' => !empty($_REQUEST['url_id']) ? (int)$_REQUEST['url_id'] : null
2102
+ );
2103
+
2104
+ $this->data['hooks']['hook_newsletter_top'] = apply_filters('hook_newsletter_top', WYSIJA_module::execute_hook('hook_newsletter_top', $hook_params), $hook_params);
2105
+ $this->data['hooks']['hook_newsletter_bottom'] = apply_filters('hook_newsletter_bottom', WYSIJA_module::execute_hook('hook_newsletter_bottom', $hook_params), $hook_params);
2106
+ }
2107
+
2108
+ function getListSubscriberQry($selectcolumns) {
2109
+ $this->modelObj = WYSIJA::get("email", "model");
2110
+ $this->emailObj = $this->modelObj->getOne(false, array('email_id' => $_REQUEST['id']));
2111
+
2112
+ /* use the filter if there is */
2113
+ $this->setviewStatsfilter();
2114
+
2115
+ if ($selectcolumns == "B.user_id") {
2116
+ //unset($this->filters["like"]);
2117
+ }
2118
+
2119
+ $this->filters['equal']["B.email_id"] = $this->emailObj['email_id'];
2120
+ $this->modelObj->noCheck = true;
2121
+ if ($this->filters)
2122
+ $this->modelObj->setConditions($this->filters);
2123
+
2124
+ /* select insert all the subscribers from that campaign into user_list */
2125
+ if ($selectcolumns == "B.user_id") {
2126
+ $query = "SELECT $selectcolumns FROM `[wysija]" . $this->tableQuery . "` as B";
2127
+ $query.=$this->modelObj->makeWhere();
2128
+ } else {
2129
+ $query = "SELECT $selectcolumns FROM `[wysija]user` as A";
2130
+ $query.=" LEFT JOIN `[wysija]" . $this->tableQuery . "` as B on A.user_id=B.user_id";
2131
+ $query.=$this->modelObj->makeWhere();
2132
+ }
2133
+
2134
+ return $query;
2135
+ }
2136
+
2137
+ function createnewlist() {
2138
+ /* get the email subject */
2139
+ $emailModel = WYSIJA::get('email', 'model');
2140
+ $email = $emailModel->getOne(array('subject'), array('email_id' => $_REQUEST['id']));
2141
+
2142
+ $this->modelObj->reset();
2143
+
2144
+ /* set the name of the new list */
2145
+ $prefix = "";
2146
+ if (isset($_REQUEST['link_filter']))
2147
+ $prefix = ' (' . $this->viewObj->getTransStatusEmail($_REQUEST['link_filter']) . ')';
2148
+ $listname = sprintf(__('Segment of %1$s', WYSIJA), $email['subject'] . $prefix);
2149
+
2150
+ /* insert new list */
2151
+ $modelL = WYSIJA::get('list', 'model');
2152
+ $listid = $modelL->insert(array('is_enabled' => 1, 'name' => $listname, 'description' => __('List created based on a newsletter segment.', WYSIJA)));
2153
+
2154
+ /* get list of subscribers filtered or not */
2155
+ $query = $this->getListSubscriberQry($listid . ', A.user_id, ' . time() . ', 0');
2156
+
2157
+ $query2 = 'INSERT INTO `[wysija]user_list` (`list_id`,`user_id`,`sub_date`,`unsub_date`) ' . $query;
2158
 
2159
+ $this->modelObj->query($query2);
 
 
 
2160
 
2161
+ $this->notice(sprintf(__('A new list "%1$s" has been created out of this segment.', WYSIJA), $listname));
2162
+ $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2163
+ }
2164
+
2165
+ function unsubscribeall() {
2166
+ // Update user_list, set unsubdate and sub_date
2167
+ $query = $this->getListSubscriberQry('B.user_id');
2168
+ $query1 = "
2169
+ UPDATE `[wysija]user_list`
2170
+ SET
2171
+ `unsub_date` = ".time().",
2172
+ `sub_date` = 0
2173
+ WHERE
2174
+ `user_id` IN ($query)
2175
+ AND `list_id` NOT IN (SELECT `list_id` FROM `[wysija]list` WHERE `is_enabled` < 1)
2176
+ ";
2177
+ $this->modelObj->query($query1);
2178
+
2179
+ // unsubscribe from user where select from email_user_stat
2180
+ $query2 = "UPDATE `[wysija]user` SET `status`=-1 WHERE `user_id` IN ($query)";
2181
+ $this->modelObj->query($query2);
2182
+
2183
+ $this->notice(__('The segment has been unsubscribed from all the lists.', WYSIJA));
2184
+ $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2185
+ }
2186
 
2187
+ function sendconfirmation() {
2188
+ //delete from user_lists where select from email_user_stat
2189
+ $query = $this->getListSubscriberQry('B.user_id ');
2190
 
2191
+ $user_ids = $this->modelObj->query('get_res', $query);
 
 
 
 
2192
 
2193
+ $uids = array();
2194
+ foreach ($user_ids as $data) {
2195
+ $uids[] = $data['user_id'];
2196
+ }
2197
 
2198
+ $helperUser = WYSIJA::get('user', 'helper');
2199
+ $helperUser->sendConfirmationEmail($uids);
2200
+ $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2201
+ }
 
 
2202
 
2203
+ function removequeue() {
2204
+ /* delete from queue where select from email_user_stat */
2205
+ $query = $this->getListSubscriberQry('B.user_id');
2206
+ $query2 = "DELETE FROM `[wysija]queue` where user_id IN ($query) AND email_id=" . $this->emailObj['email_id'];
2207
+ $this->modelObj->query($query2);
2208
 
2209
+ $this->notice(__('The segment has been removed from the queue of this newsletter.', WYSIJA));
2210
+ $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2211
+ }
2212
 
2213
+ function export() {
2214
+ /* select from email_user_stat left join user */
2215
+ $query = $this->getListSubscriberQry('B.user_id');
2216
+ $result = $this->modelObj->query('get_res', $query);
2217
+ $user_ids = array();
2218
+ foreach ($result as $user)
2219
+ $user_ids[] = $user['user_id'];
2220
 
2221
+ $fileHelp = WYSIJA::get('file', 'helper');
2222
+ $tempfilename = $fileHelp->temp(implode(',', $user_ids), 'export_userids', '.txt');
2223
 
2224
+ //$this->redirect("admin.php?page=wysija_campaigns&action=viewstats&id=".$_REQUEST['id']."&user_ids=".serialize($result));
2225
+ $this->redirect('admin.php?page=wysija_subscribers&action=exportcampaign&camp_id=' . $_REQUEST['id'] . '&file_name=' . base64_encode($tempfilename['path']));
2226
+ }
2227
+
2228
+ function unsubscribelist($data) {
2229
+
2230
+ $modelL = WYSIJA::get('list', 'model');
2231
+ $list = $modelL->getOne(false, array('list_id' => $data['listid']));
2232
+ if ($list['is_enabled']) {
2233
+ /* delete from user_lists where select from email_user_stat */
2234
+ $query = $this->getListSubscriberQry("B.user_id");
2235
+ $query2 = "DELETE FROM `[wysija]user_list` where user_id IN ($query) and list_id=" . $data['listid'];
2236
+ $this->modelObj->query($query2);
2237
+
2238
+ $this->notice(sprintf(__('The segment has been unsubscribed from the list "%1$s".', WYSIJA), $list['name']));
2239
+ } else {
2240
+ $this->notice(sprintf(__('The segment cannot be unsubscribed from an [IMPORT] list.', WYSIJA), $list['name']));
2241
+ }
2242
 
2243
+ $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id=' . $_REQUEST['id']);
2244
+ }
2245
+
2246
+ function articles() {
2247
+ $this->iframeTabs = array('articles' => __("Post Selection", WYSIJA));
2248
+
2249
+ // required js files
2250
+ $this->js[] = 'wysija-admin-ajax';
2251
+ $this->js[] = 'wysija-base-script-64';
2252
+ $this->js[] = 'wysija-scriptaculous';
2253
+ $this->js[] = 'wysija-colorpicker';
2254
+
2255
+ // translations
2256
+ $this->jsTrans['show_advanced'] = __('Display and insert options', WYSIJA);
2257
+ $this->jsTrans['hide_advanced'] = __('Back to selection', WYSIJA);
2258
+ $this->jsTrans['loading_results'] = __('Loading results...', WYSIJA);
2259
+ $this->jsTrans['inserting_selection'] = __('Inserting selected articles...', WYSIJA);
2260
+ $this->jsTrans['post_selected'] = __('selected', WYSIJA);
2261
+
2262
+ // default tab in popup (this needs to be removed at some point)
2263
+ $_GET['tab'] = 'articles';
2264
+
2265
+ // get parameters
2266
+ $params = array(
2267
+ 'category_ids' => null,
2268
+ 'category' => null,
2269
+ 'title_tag' => 'h2',
2270
+ 'title_alignment' => 'left',
2271
+ 'title_position' => 'inside',
2272
+ 'image_alignment' => 'alternate',
2273
+ 'image_width' => 325,
2274
+ 'post_content' => 'excerpt',
2275
+ 'readmore' => __('Read more.', WYSIJA),
2276
+ 'show_divider' => 'yes',
2277
+ 'post_limit' => 5,
2278
+ 'post_type' => 'post',
2279
+ 'author_show' => 'no',
2280
+ 'author_label' => __('Author:', WYSIJA),
2281
+ 'category_show' => 'no',
2282
+ 'category_label' => __('Categories:', WYSIJA),
2283
+ 'nopost_message' => __('Latest content already sent.', WYSIJA),
2284
+ 'bgcolor1' => null,
2285
+ 'bgcolor2' => null,
2286
+ 'sort_by' => 'newest'
2287
+ );
2288
+
2289
+ // check if GET parameters are specified
2290
+ foreach($params as $key => $value) {
2291
+ if(array_key_exists($key, $_GET)) {
2292
+ switch($key) {
2293
+ case 'autopost_count':
2294
+ $params[$key] = (int)$_GET[$key];
2295
+ break;
2296
+ case 'readmore':
2297
+ case 'nopost_message':
2298
+ $params[$key] = base64_decode($_GET[$key]);
2299
+ break;
2300
+ default:
2301
+ $params[$key] = $_GET[$key];
2302
+ }
2303
+ }
2304
+ }
2305
+
2306
+ $model_config = WYSIJA::get('config', 'model');
2307
+ $insert_post_parameters = $model_config->getValue('insert_post_parameters');
2308
+ $helper_wj_engine = WYSIJA::get('wj_engine', 'helper');
2309
+
2310
+ if($insert_post_parameters !== false) {
2311
+ // there are user params
2312
+ $params = $helper_wj_engine->decodeParameters(array_merge($params, $insert_post_parameters));
2313
+ }
2314
+
2315
+ // get autopost count
2316
+ $this->data['autopost_count'] = (array_key_exists('autopost_count', $_GET)) ? (int) $_GET['autopost_count'] : 0;
2317
+
2318
+ // get autopost type (single or multiple)
2319
+ $this->data['autopost_type'] = (array_key_exists('autopost_type', $_GET)) ? $_GET['autopost_type'] : 'multiple';
2320
+
2321
+ // if only one group of post can be added, change default alignment to left
2322
+ if($this->data['autopost_type'] === 'single' && $params['image_alignment'] === 'alternate') {
2323
+ $params['image_alignment'] = 'left';
2324
+ }
2325
 
2326
+ // get post categories (even when there's no post)
2327
+ $post_categories = get_categories(array('hide_empty' => 0));
2328
+ $categories = array();
2329
+ foreach ($post_categories as $category) {
2330
+ $categories[] = array('id' => $category->cat_ID, 'name' => $category->name);
2331
+ }
2332
+ $this->data['categories'] = $categories;
2333
 
2334
+ // max number of posts
2335
+ $this->data['post_limits'] = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 50);
2336
 
2337
+ $this->data['params'] = $params;
2338
 
2339
+ return $this->popupContent();
2340
+ }
2341
 
2342
+ function themeupload() {
2343
+ $helperNumbers = WYSIJA::get('numbers', 'helper');
2344
+ $bytes = $helperNumbers->get_max_file_upload();
 
2345
 
2346
+ if (isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH'] > $bytes['maxbytes']) {
2347
+ if (isset($_FILES['my-theme']['name']) && $_FILES['my-theme']['name']) {
2348
+ $filename = $_FILES['my-theme']['name'];
2349
+ } else {
2350
+ $filename = "";
2351
+ }
2352
 
2353
+ $this->error(sprintf(__('Upload error, file %1$s is too large! (MAX:%2$s)', WYSIJA), $filename, $bytes['maxmegas']), true);
2354
+ $this->redirect('admin.php?page=wysija_campaigns&action=themes');
 
2355
 
2356
+ return false;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2357
  }
2358
+
2359
+
2360
+ $ZipfileResult = trim(file_get_contents($_FILES['my-theme']['tmp_name']));
2361
+
2362
+ $themesHelp = WYSIJA::get('themes', 'helper');
2363
+ $result = $themesHelp->installTheme($_FILES['my-theme']['tmp_name'], true);
2364
+ $this->redirect('admin.php?page=wysija_campaigns&action=themes&reload=1');
2365
+
2366
+ return true;
2367
  }
2368
 
2369
+ function themes() {
2370
+ $this->iframeTabs = array('themes' => __('Install Themes', WYSIJA));
2371
+ $this->js[] = 'wysija-admin-ajax';
2372
+ $this->js[] = 'wysija-base-script-64';
2373
+ $this->jsTrans['viewinfos'] = __('Details & PSD', WYSIJA);
2374
+ $this->jsTrans['viewback'] = __('<< Back', WYSIJA);
2375
+ $this->jsTrans['install'] = __('Download', WYSIJA);
2376
+ $this->jsTrans['reinstall'] = __('Reinstall', WYSIJA);
2377
+ $this->jsTrans['premiumonly'] = __('Premium', WYSIJA);
2378
+
2379
+ $model_config = WYSIJA::get('config', 'model');
2380
+ //change the translation of the button when it's premium
2381
+ if ($model_config->getValue('premium_key'))
2382
+ $this->jsTrans['ispremium'] = 1;
2383
+ else
2384
+ $this->jsTrans['ispremium'] = 0;
2385
+
2386
+ $this->jsTrans['premiumfiles'] = __('Photoshop file available as part of [link]Premium features[/link].', WYSIJA);
2387
+
2388
+ $helper_licence = WYSIJA::get('licence', 'helper');
2389
+ $url_checkout = $helper_licence->get_url_checkout('themes');
2390
+ $this->jsTrans['premiumfiles'] = str_replace(array('[link]', '[/link]'), array('<a href="' . $url_checkout . '" target="_blank" >', '</a>'), $this->jsTrans['premiumfiles']);
2391
+
2392
+ $this->jsTrans['showallthemes'] = __('Show all themes', WYSIJA);
2393
+ $this->jsTrans['totalvotes'] = __('(%1$s votes)', WYSIJA);
2394
+ $this->jsTrans['voterecorded'] = __("Your vote has been recorded.", WYSIJA);
2395
+ $this->jsTrans['votenotrecorded'] = __("Your vote could not be recorded.", WYSIJA);
2396
+ $this->jsTrans['reinstallwarning'] = __('Watch out! If you reinstall this theme all the files which are in the folder:/wp-content/uploads/wysija/themes/%1$s will be overwritten. Are you sure you want to reinstall?', WYSIJA);
2397
+ $this->jsTrans['errorconnecting'] = __("We were unable to contact the API, the site may be down. Please try again later.", WYSIJA);
2398
+
2399
+ $this->jsTrans['viewallthemes'] = __('View all themes by %1$s', WYSIJA);
2400
+ $this->jsTrans['downloadpsd'] = __("Download original Photoshop file", WYSIJA);
2401
+ $this->jsTrans['downloadzip'] = __("Download as .zip", WYSIJA);
2402
+ $this->jsTrans['viewauthorsite'] = __("View author's website", WYSIJA);
2403
+ $this->jsTrans['stars'] = __('Average rating: %1$s', WYSIJA);
2404
+ $this->jsTrans['starsyr'] = __('My rating: %1$s', WYSIJA);
2405
+ $this->jsTrans['downloads'] = __('Downloads: %1$s', WYSIJA);
2406
+ $this->jsTrans['tags'] = __('Tags: %1$s', WYSIJA);
2407
+ $this->jsTrans['lastupdated'] = __('Last updated: %1$s', WYSIJA);
2408
+ $this->jsTrans['includes'] = __('Includes: %1$s', WYSIJA);
2409
+
2410
+ $helper_themes = WYSIJA::get('themes', 'helper');
2411
+
2412
+ $this->jsTrans['installedthemes'] = $helper_themes->getInstalled();
2413
+
2414
+ $url = admin_url('admin.php');
2415
+ $helper_toolbox = WYSIJA::get("toolbox", "helper");
2416
+ $domain_name = $helper_toolbox->_make_domain_name($url);
2417
+ $this->jsTrans['domainname'] = $domain_name;
2418
+
2419
+ $_GET['tab'] = 'themes';
2420
+
2421
+ return $this->popupContent();
2422
  }
2423
 
2424
+ function bookmarks() {
2425
+ $this->iframeTabs = array('bookmarks' => __('Bookmarks Selection', WYSIJA));
2426
+ $this->js[] = 'wysija-admin-ajax';
2427
+
2428
+ $_GET['tab'] = 'bookmarks';
2429
+
2430
+ $networks = array(
2431
+ 'facebook' => array(
2432
+ 'label' => 'Facebook',
2433
+ 'url' => null,
2434
+ 'placeholder' => 'https://www.facebook.com/mailpoetplugin'
2435
+ ),
2436
+ 'twitter' => array(
2437
+ 'label' => 'Twitter',
2438
+ 'url' => null,
2439
+ 'placeholder' => 'http://www.twitter.com/mail_poet'
2440
+ ),
2441
+ 'google' => array(
2442
+ 'label' => 'Google+',
2443
+ 'url' => null,
2444
+ 'placeholder' => null
2445
+ ),
2446
+ 'linkedin' => array(
2447
+ 'label' => 'LinkedIn',
2448
+ 'url' => null,
2449
+ 'placeholder' => null
2450
+ )
2451
+ );
2452
+
2453
+ // get networks' url from config
2454
+ $model_config = WYSIJA::get('config', 'model');
2455
+ $urls = $model_config->getValue('social_bookmarks');
2456
+
2457
+ // set url from config for each network if specified
2458
+ foreach ($networks as $network => $values) {
2459
+ if (isset($urls[$network]) and strlen(trim($urls[$network])) > 0) {
2460
+ $networks[$network]['url'] = $urls[$network];
2461
+ }
2462
+ }
2463
+
2464
+ $this->data['networks'] = $networks;
2465
+ $this->data['size'] = 'medium';
2466
+ $this->data['theme'] = isset($_REQUEST['theme']) ? $_REQUEST['theme'] : 'default';
2467
 
2468
+ return $this->popupContent();
 
 
 
2469
  }
2470
 
2471
+ function dividers() {
2472
+ $this->iframeTabs = array('dividers' => __("Dividers Selection", WYSIJA));
2473
+ $this->js[] = 'wysija-admin-ajax';
2474
+ $this->js[] = 'wysija-base-script-64';
2475
+
2476
+ $_GET['tab'] = 'dividers';
2477
+
2478
+ $model_email = WYSIJA::get('email', 'model');
2479
+ $this->data['email'] = $email = $model_email->getOne(false, array('email_id' => $_REQUEST['emailId']));
2480
+
2481
+ // get dividers
2482
+ $helper_dividers = WYSIJA::get('dividers', 'helper');
2483
+ $dividers = $helper_dividers->getAll();
2484
+
2485
+ // get theme divider if it's not the default theme
2486
+ if (isset($email['params']['theme'])) {
2487
+ $helper_themes = WYSIJA::get('themes', 'helper');
2488
+ $themeDivider = $helper_themes->getDivider($email['params']['theme']);
2489
+ if ($themeDivider !== NULL) {
2490
+ array_unshift($dividers, $themeDivider);
2491
+ }
2492
+ }
2493
+
2494
+ // get selected divider
2495
+ if (isset($email['params']['divider'])) {
2496
+ $selected_divider = $email['params']['divider'];
2497
+ } else {
2498
+ $helper_dividers = WYSIJA::get('dividers', 'helper');
2499
+ $selected_divider = $helper_dividers->getDefault();
2500
+ }
2501
+
2502
+ // set selected divider in first position
2503
+ array_unshift($dividers, $selected_divider);
2504
+
2505
+ // remove selected divider if present in the list
2506
+ for ($i = 1; $i < count($dividers); $i++) {
2507
+ if ($dividers[$i]['src'] === $selected_divider['src']) {
2508
+ unset($dividers[$i]);
2509
+ break;
2510
+ }
2511
+ }
2512
+
2513
+ $this->data['selected'] = $selected_divider;
2514
+ $this->data['dividers'] = $dividers;
2515
+ return $this->popupContent();
2516
  }
2517
 
2518
+ function autopost() {
2519
+ $this->iframeTabs = array('autopost' => __("Add / Edit group of posts", WYSIJA));
2520
+ $this->js[] = 'wysija-admin-ajax';
2521
+ $this->js[] = 'wysija-base64';
2522
+ $this->js[] = 'wysija-scriptaculous';
2523
+ $this->js[] = 'wysija-colorpicker';
2524
+ $this->js[] = 'mailpoet-select2';
2525
+
2526
+ // translations
2527
+ $this->jsTrans['show_advanced'] = __('Show display options', WYSIJA);
2528
+ $this->jsTrans['hide_advanced'] = __('Hide display options', WYSIJA);
2529
+
2530
+ $_GET['tab'] = 'autopost';
2531
+
2532
+ // get parameters
2533
+ $params = array(
2534
+ 'category_ids' => null,
2535
+ 'category_condition' => 'include',
2536
+ 'title_tag' => 'h2',
2537
+ 'title_alignment' => 'left',
2538
+ 'title_position' => 'inside',
2539
+ 'image_alignment' => 'alternate',
2540
+ 'image_width' => 325,
2541
+ 'post_content' => 'excerpt',
2542
+ 'readmore' => __('Read more.', WYSIJA),
2543
+ 'show_divider' => 'yes',
2544
+ 'post_limit' => 5,
2545
+ 'post_type' => 'post',
2546
+ 'author_show' => 'no',
2547
+ 'author_label' => __('Author:', WYSIJA),
2548
+ 'category_show' => 'no',
2549
+ 'category_label' => __('Categories:', WYSIJA),
2550
+ 'nopost_message' => __('Latest content already sent.', WYSIJA),
2551
+ 'bgcolor1' => null,
2552
+ 'bgcolor2' => null,
2553
+ 'sort_by' => 'newest'
2554
+ );
2555
+
2556
+ // backwards compatibility since we replaced the 'cpt' parameter by 'post_type' in 2.6
2557
+ if(isset($_GET['cpt']) && strlen(trim($_GET['cpt'])) > 0) {
2558
+ $params['post_type'] = trim($_GET['cpt']);
2559
+ }
2560
+
2561
+ // check if GET parameters are specified
2562
+ foreach ($params as $key => $value) {
2563
+ if (array_key_exists($key, $_GET)) {
2564
+ switch ($key) {
2565
+ case 'autopost_count':
2566
+ $params[$key] = (int)$_GET[$key];
2567
+ break;
2568
+ case 'author_label':
2569
+ case 'category_label':
2570
+ case 'readmore':
2571
+ case 'nopost_message':
2572
+ $params[$key] = base64_decode($_GET[$key]);
2573
+ break;
2574
+ default:
2575
+ $params[$key] = trim($_GET[$key]);
2576
+ }
2577
+ }
2578
+ }
2579
+
2580
+ // get autopost count
2581
+ $this->data['autopost_count'] = (array_key_exists('autopost_count', $_GET)) ? (int) $_GET['autopost_count'] : 0;
2582
+
2583
+ // get autopost type (single or multiple)
2584
+ $this->data['autopost_type'] = (array_key_exists('autopost_type', $_GET)) ? $_GET['autopost_type'] : 'multiple';
2585
+
2586
+ // if only one group of post can be added, change default alignment to left
2587
+ if ($this->data['autopost_type'] === 'single') {
2588
+ if ($params['image_alignment'] === 'alternate')
2589
+ $params['image_alignment'] = 'left';
2590
+ }
2591
+
2592
+ // we use that now, because categories from a post are different than categories from a CPT
2593
+ // $helper_wp_tools = WYSIJA::get('wp_tools','helper');
2594
+ // $this->data['categories'] = $helper_wp_tools->get_categories();
2595
+
2596
+ // max number of posts
2597
+ $this->data['post_limits'] = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 20, 30, 50);
2598
+
2599
+ $this->data['params'] = $params;
2600
+
2601
+ return $this->popupContent();
2602
+ }
2603
+
2604
+ function image_data() {
2605
+ $this->data['url'] = (isset($_GET['url']) && $_GET['url'] !== '') ? trim(urldecode($_GET['url'])) : null;
2606
+ $this->data['alt'] = (isset($_GET['alt'])) ? trim(urldecode($_GET['alt'])) : '';
2607
+
2608
+ $this->iframeTabs = array('image_data' => __("Image Parameters", WYSIJA));
2609
+ $_GET['tab'] = 'image_data';
2610
+ return $this->popupContent();
2611
+ }
2612
+
2613
+ function medias() {
2614
+ $this->popupContent();
2615
+ }
2616
+
2617
+ function special_wysija_browse() {
2618
+ $this->_wysija_subaction();
2619
+ $this->jsTrans['deleteimg'] = __('Delete image for all newsletters?', WYSIJA);
2620
+ return wp_iframe(array($this->viewObj, 'popup_wysija_browse'), array());
2621
+ }
2622
+
2623
+ function special_wordp_browse() {
2624
+ $this->_wysija_subaction();
2625
+ $this->jsTrans['deleteimg'] = __('This image might be in an article. Delete anyway?', WYSIJA);
2626
+ return wp_iframe(array($this->viewObj, 'popup_wp_browse'), array());
2627
+ }
2628
+
2629
+ function _wysija_subaction() {
2630
+
2631
+ if (isset($_REQUEST['subaction'])) {
2632
+ if ($_REQUEST['subaction'] === 'delete') {
2633
+ if (isset($_REQUEST['imgid']) && (int) $_REQUEST['imgid'] > 0) {
2634
+ /* delete the image with id imgid */
2635
+ $res = wp_delete_attachment((int) $_REQUEST['imgid'], true);
2636
+ if ($res) {
2637
+ $this->notice(__('Image has been deleted.', WYSIJA));
2638
+ }
2639
+ }
2640
+ }
2641
+ }
2642
+ return true;
2643
+ }
2644
+
2645
+ function special_new_wordp_upload() {
2646
+
2647
+ //wp_enqueue_script('plupload-all');
2648
+ wp_enqueue_script('wysija-plupload-handlers', WYSIJA_URL . 'js/jquery/pluploadHandler.js', array('plupload-all', 'jquery'));
2649
+ $uploader_l10n = array(
2650
+ 'queue_limit_exceeded' => __('You have attempted to queue too many files.'),
2651
+ 'file_exceeds_size_limit' => __('%s exceeds the maximum upload size for this site.'),
2652
+ 'zero_byte_file' => __('This file is empty. Please try another.'),
2653
+ 'invalid_filetype' => __('This file type is not allowed. Please try another.'),
2654
+ 'not_an_image' => __('This file is not an image. Please try another.'),
2655
+ 'image_memory_exceeded' => __('Memory exceeded. Please try another smaller file.'),
2656
+ 'image_dimensions_exceeded' => __('This is larger than the maximum size. Please try another.'),
2657
+ 'default_error' => __('An error occurred in the upload. Please try again later.'),
2658
+ 'missing_upload_url' => __('There was a configuration error. Please contact the server administrator.'),
2659
+ 'upload_limit_exceeded' => __('You may only upload 1 file.'),
2660
+ 'http_error' => __('HTTP error.'),
2661
+ 'upload_failed' => __('Upload failed.'),
2662
+ 'big_upload_failed' => __('Please try uploading this file with the %1$sbrowser uploader%2$s.'),
2663
+ 'big_upload_queued' => __('%s exceeds the maximum upload size for the multi-file uploader when used in your browser.'),
2664
+ 'io_error' => __('IO error.'),
2665
+ 'security_error' => __('Security error.'),
2666
+ 'file_cancelled' => __('File canceled.'),
2667
+ 'upload_stopped' => __('Upload stopped.'),
2668
+ 'dismiss' => __('Dismiss'),
2669
+ 'crunching' => __('Crunching&hellip;'),
2670
+ 'deleted' => __('moved to the trash.'),
2671
+ 'error_uploading' => __('&#8220;%s&#8221; has failed to upload.')
2672
+ );
2673
+
2674
+ wp_localize_script('wysija-plupload-handlers', 'pluploadL10n', $uploader_l10n);
2675
+
2676
+ wp_enqueue_script('image-edit');
2677
+ wp_enqueue_script('set-post-thumbnail');
2678
+ wp_enqueue_style('imgareaselect');
2679
+ wp_enqueue_script('media-gallery');
2680
+
2681
+ /* wp_register_style('myplupload', '/adjust-this-url/myplupload.css');
2682
+ wp_enqueue_style('myplupload'); */
2683
+
2684
+
2685
+ $errors = array();
2686
+ return wp_iframe(array($this->viewObj, 'popup_new_wp_upload'), $errors);
2687
+ }
2688
+
2689
+ function special_wordp_upload() {
2690
+
2691
+ wp_enqueue_script('swfupload-all');
2692
+ wp_enqueue_script('swfupload-handlers');
2693
+ wp_enqueue_script('wysija-upload-handlers', WYSIJA_URL . "js/jquery/uploadHandlers.js");
2694
+ wp_enqueue_script('image-edit');
2695
+ wp_enqueue_script('set-post-thumbnail');
2696
+ wp_enqueue_style('imgareaselect');
2697
+
2698
+ $errors = array();
2699
+ $id = 0;
2700
+ if (isset($_GET['flash']))
2701
+ $_GET['flash'] = 1;
2702
+ if (isset($_POST['html-upload']) && !empty($_FILES)) {
2703
+ // Upload File button was clicked
2704
+ $id = media_handle_upload('async-upload', $_REQUEST['post_id']);
2705
+ unset($_FILES);
2706
+ if (is_wp_error($id)) {
2707
+ $errors['upload_error'] = $id;
2708
+ $id = false;
2709
+ }
2710
+ }
2711
+
2712
+ if (!empty($_POST['insertonlybutton'])) {
2713
+ $href = $_POST['insertonly']['href'];
2714
+ if (!empty($href) && !strpos($href, '://'))
2715
+ $href = "http://$href";
2716
+
2717
+ $title = esc_attr($_POST['insertonly']['title']);
2718
+ if (empty($title))
2719
+ $title = basename($href);
2720
+ if (!empty($title) && !empty($href))
2721
+ $html = "<a href='" . esc_url($href) . "' >$title</a>";
2722
+ $html = apply_filters('file_send_to_editor_url', $html, esc_url_raw($href), $title);
2723
+ return media_send_to_editor($html);
2724
+ }
2725
+
2726
+ if (!empty($_POST)) {
2727
+ $return = media_upload_form_handler();
2728
+
2729
+ if (is_string($return))
2730
+ return $return;
2731
+ if (is_array($return))
2732
+ $errors = $return;
2733
+ }
2734
+
2735
+ if (isset($_POST['save'])) {
2736
+ $errors['upload_notice'] = __('Saved.', WYSIJA);
2737
+ return media_upload_gallery();
2738
+ }
2739
+
2740
+
2741
+ return wp_iframe(array($this->viewObj, 'popup_wp_upload'), $errors);
2742
+ }
2743
+
2744
+ function _checkEmailExists($emailId) {
2745
+ $result = false;
2746
+ $modelEmail = WYSIJA::get('email', 'model');
2747
+
2748
+ if ($modelEmail->exists(array('email_id' => $emailId)))
2749
+ $result = true;
2750
+
2751
+ if (!$result) {
2752
+ $this->error(__("The newsletter doesn't exist.", WYSIJA), 1);
2753
+ $this->redirect('admin.php?page=wysija_campaigns');
2754
+ }
2755
+ else
2756
+ return true;
2757
+ }
2758
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2759
  }
controllers/back/config.php CHANGED
@@ -1,379 +1,383 @@
1
- <?php
2
- defined('WYSIJA') or die('Restricted access');
3
- class WYSIJA_control_back_config extends WYSIJA_control_back{
4
- var $view='config';
5
- var $model='config';
6
-
7
- function WYSIJA_control_back_config(){
8
-
9
- }
10
-
11
- function main() {
12
- parent::WYSIJA_control_back();
13
- wp_enqueue_style('thickbox');
14
-
15
- if(!isset($_REQUEST['action'])) $this->action='main';
16
- else $this->action=$_REQUEST['action'];
17
-
18
- $this->jsTrans['testemail'] = __('Sending a test email', WYSIJA);
19
- $this->jsTrans['bounceconnect'] = __('Bounce handling connection test', WYSIJA);
20
- $this->jsTrans['processbounceT'] = __('Bounce handling processing', WYSIJA);
21
- $this->jsTrans['doubleoptinon'] = __('Subscribers will now need to activate their subscription by email in order to receive your newsletters. This is recommended.', WYSIJA);
22
- $this->jsTrans['doubleoptinoff'] = __('Unconfirmed subscribers will receive your newslettters from now on without the need to activate their subscriptions.', WYSIJA);
23
- $this->jsTrans['processbounce'] = __('Process bounce handling now!', WYSIJA);
24
- $this->jsTrans['errorbounceforward'] = __('When setting up the bounce system, you need to have a different address for the bounce email and the forward to address', WYSIJA);
25
-
26
- // form list
27
- $this->jsTrans['suredelete'] = __('Are you sure you want to delete this form?', WYSIJA);
28
-
29
- switch($this->action) {
30
- case 'log':
31
- case 'save':
32
- case 'clearlog':
33
- wp_enqueue_script('wysija-config-settings', WYSIJA_URL.'js/admin-config-settings.js', array('wysija-admin-js-global'), WYSIJA::get_version());
34
- case 'form_add':
35
- case 'form_edit':
36
- case 'form_duplicate':
37
- case 'form_delete':
38
- case 'form_widget_settings':
39
- return $this->{$this->action}();
40
- break;
41
- case 'reinstall':
42
- $this->reinstall();
43
- return;
44
- break;
45
- case 'dkimcheck':
46
- $this->dkimcheck();
47
- if(defined('WYSIJA_REDIRECT')) $this->redirectProcess();
48
- return;
49
- break;
50
- case 'doreinstall':
51
- $this->doreinstall();
52
- if(defined('WYSIJA_REDIRECT')){
53
- global $wysi_location;
54
- $wysi_location='admin.php?page=wysija_campaigns';
55
- $this->redirectProcess();
56
- }
57
- return;
58
- break;
59
- default:
60
- wp_enqueue_script('wysija-config-settings', WYSIJA_URL.'js/admin-config-settings.js', array('wysija-admin-js-global'), WYSIJA::get_version());
61
- wp_enqueue_script('jquery-cookie', WYSIJA_URL.'js/jquery/jquery.cookie.js', array('jquery'), WYSIJA::get_version());
62
- }
63
-
64
- if(WYSIJA_DBG > 1) {
65
- $this->viewObj->arrayMenus = array('log' => 'View log');
66
- }
67
-
68
- $this->data=array();
69
- $this->action='main';
70
-
71
- if(isset($_REQUEST['validate'])){
72
- $this->notice(str_replace(array('[link]','[/link]'),
73
- array('<a title="'.__('Get Premium now',WYSIJA).'" class="premium-tab" href="javascript:;">','</a>'),
74
- __('You\'re almost there. Click this [link]link[/link] to activate the licence you have just purchased.',WYSIJA)));
75
-
76
- }
77
-
78
- }
79
-
80
- function dkimcheck(){
81
-
82
- if(isset($_POST['xtz'])){
83
-
84
- $dataconf=json_decode(base64_decode($_POST['xtz']));
85
- if(isset($dataconf->dkim_pubk->key) && isset($dataconf->dkim_privk)){
86
- $modelConf=WYSIJA::get('config','model');
87
- $dataconfsave=array('dkim_pubk'=>$dataconf->dkim_pubk->key, 'dkim_privk'=>$dataconf->dkim_privk,'dkim_1024'=>1);
88
-
89
- $modelConf->save($dataconfsave);
90
- WYSIJA::update_option('dkim_autosetup',false);
91
- }
92
- }
93
-
94
- $this->redirect('admin.php?page=wysija_config');
95
- return true;
96
- }
97
-
98
- function save(){
99
- $_REQUEST = stripslashes_deep($_REQUEST);
100
- $_POST = stripslashes_deep($_POST);
101
- $this->requireSecurity();
102
- $this->modelObj->save($_REQUEST['wysija']['config'],true);
103
-
104
- //wp_redirect('admin.php?page=wysija_config'.$_REQUEST['redirecttab']);
105
-
106
- }
107
-
108
- function reinstall(){
109
- $this->viewObj->title=__('Reinstall Wysija?',WYSIJA);
110
- return true;
111
- }
112
-
113
- function changeMode(){
114
- $helperFile=WYSIJA::get('file','helper');
115
- $helperFile->chmodr(WYSIJA_UPLOADS_DIR, 0666, 0777);
116
- $this->redirect('admin.php?page=wysija_config');
117
- return true;
118
- }
119
-
120
- function doreinstall(){
121
-
122
- if(isset($_REQUEST['postedfrom']) && $_REQUEST['postedfrom'] === 'reinstall') {
123
- $uninstaller=WYSIJA::get('uninstall','helper');
124
- $uninstaller->reinstall();
125
- }
126
- $this->redirect('admin.php?page=wysija_config');
127
- return true;
128
- }
129
-
130
- function render(){
131
- $this->checkTotalSubscribers();
132
- $this->viewObj->render($this->action,$this->data);
133
- }
134
-
135
- function log(){
136
- $this->viewObj->arrayMenus=array('clearlog'=>'Clear log');
137
- $this->viewObj->title='Wysija\'s log';
138
- return true;
139
- }
140
-
141
- function clearlog(){
142
- update_option('wysija_log', array());
143
- $this->redirect('admin.php?page=wysija_config&action=log');
144
- return true;
145
- }
146
-
147
- // WYSIJA Form Editor
148
- function form_add() {
149
- $helper_form_engine = WYSIJA::get('form_engine', 'helper');
150
- // set default form data
151
- $helper_form_engine->set_data();
152
-
153
- // create form in database with default data
154
- $form = array(
155
- 'name' => __('New Form', WYSIJA),
156
- 'data' => $helper_form_engine->get_encoded('data')
157
- );
158
-
159
- // insert into form table
160
- $model_forms = WYSIJA::get('forms', 'model');
161
- $form_id = $model_forms->insert($form);
162
-
163
- if($form_id !== null && (int)$form_id > 0) {
164
- // redirect to form editor, passing along the newly created form id
165
- //$this->redirect('admin.php?page=wysija_config&action=form_edit&id='.$form_id);
166
- WYSIJA::redirect('admin.php?page=wysija_config&action=form_edit&id='.$form_id);
167
- } else {
168
- WYSIJA::redirect('admin.php?page=wysija_config#tab-forms');
169
- }
170
- return true;
171
- }
172
-
173
- function form_duplicate() {
174
-
175
- if(isset($_GET['id']) && (int)$_GET['id'] > 0) {
176
- $form_id = (int)$_GET['id'];
177
-
178
- $model_forms = WYSIJA::get('forms', 'model');
179
-
180
- // get form data
181
- $form = $model_forms->getOne(array('name', 'data', 'styles'), array('form_id' => $form_id));
182
-
183
- if(empty($form)) {
184
- $this->error(__('This form does not exist', WYSIJA), true);
185
- } else {
186
- // reset model forms
187
- $model_forms->reset();
188
-
189
- // add "copy" to the name
190
- $form['name'] = $form['name'].' - '.__('Copy', WYSIJA);
191
-
192
- // insert form (duplicated)
193
- $model_forms->insert($form);
194
-
195
- // display notice
196
- $this->notice(sprintf(__('The form named "%1$s" has been created.', WYSIJA), $form['name']));
197
- }
198
- }
199
-
200
- WYSIJA::redirect('admin.php?page=wysija_config#tab-forms');
201
- }
202
-
203
- function form_delete() {
204
-
205
- $this->requireSecurity();
206
-
207
- if(isset($_GET['id']) && (int)$_GET['id'] > 0) {
208
- $form_id = (int)$_GET['id'];
209
-
210
- $model_forms = WYSIJA::get('forms', 'model');
211
-
212
- // get form data
213
- $form = $model_forms->getOne(array('name'), array('form_id' => $form_id));
214
-
215
- if(empty($form)) {
216
- $this->error(__('This form has already been deleted.', WYSIJA), true);
217
- } else {
218
- // delete the form in the database
219
- $model_forms->reset();
220
- $model_forms->delete(array('form_id' => $form_id));
221
-
222
- // display notice
223
- $this->notice(sprintf(__('The form named "%1$s" has been deleted.', WYSIJA), $form['name']));
224
- }
225
- }
226
-
227
- WYSIJA::redirect('admin.php?page=wysija_config#tab-forms');
228
- }
229
-
230
- function form_edit() {
231
- // wysija form editor javascript files
232
- $this->js[]='wysija-form-editor';
233
- $this->js[]='wysija-admin-ajax-proto';
234
- $this->js[]='wysija-admin-ajax';
235
- $this->js[]='wysija-base-script-64';
236
-
237
- // make sure the editor content is not cached
238
- //header('Cache-Control: no-cache, max-age=0, must-revalidate, no-store'); // HTTP/1.1
239
- //header('Expires: Fri, 9 Mar 1984 00:00:00 GMT');
240
-
241
- // get form id
242
- $form_id = (isset($_REQUEST['id']) && (int)$_REQUEST['id'] > 0) ? (int)$_REQUEST['id'] : null;
243
- $form = array('name' => __('New form', WYSIJA));
244
-
245
- // if no form id was specified, then it's a new form
246
- if($form_id !== null) {
247
- // try to get form data based on form id
248
- $model_forms = WYSIJA::get('forms', 'model');
249
- $form = $model_forms->getOne($form_id);
250
-
251
- // if the form does not exist
252
- if(empty($form)) {
253
- // redirect to forms list
254
- $this->error(__('This form does not exist.', WYSIJA), true);
255
- WYSIJA::redirect('admin.php?page=wysija_config#tab-forms');
256
- } else {
257
- // pass form id to the view
258
- $this->data['form_id'] = (int)$form['form_id'];
259
- }
260
- }
261
- // pass form to the view
262
- $this->data['form'] = $form;
263
-
264
- $helper_form_engine = WYSIJA::get('form_engine', 'helper');
265
- $lists = $helper_form_engine->get_lists();
266
-
267
- // select default list
268
- $default_list = array();
269
- if(!empty($lists)) {
270
- $default_list[] = array(
271
- 'list_id' => $lists[0]['list_id'],
272
- 'is_checked' => 0
273
- );
274
- }
275
-
276
- $this->data['lists'] = $lists;
277
-
278
- // get available custom fields
279
- $model_user_field = WYSIJA::get('user_field', 'model');
280
- $model_user_field->orderBy('field_id');
281
- $custom_fields = $model_user_field->getRows(false);
282
-
283
- // extra widgets that can be added more than once
284
- $extra_fields = array(
285
- array(
286
- 'name' => __('List selection', WYSIJA),
287
- 'column_name' => 'list',
288
- 'column_type' => 'list',
289
- 'params' => array(
290
- 'label' => __('Select list(s):', WYSIJA),
291
- 'values' => $default_list
292
- )
293
- ),
294
- array(
295
- 'name' => __('Random text or HTML', WYSIJA),
296
- 'column_name' => 'html',
297
- 'column_type' => 'html',
298
- 'params' => array(
299
- 'text' => __('Random text or HTML', WYSIJA)
300
- )
301
- ),
302
- array(
303
- 'name' => __('Divider', WYSIJA),
304
- 'column_name' => 'divider',
305
- 'column_type' => 'divider'
306
- )
307
- // array(
308
- // 'name' => __('HTML code', WYSIJA),
309
- // 'column_name' => 'html',
310
- // 'column_type' => 'html',
311
- // 'params' => array(
312
- // 'text' => __('HTML code', WYSIJA)
313
- // )
314
- );
315
-
316
- // set data to be passed to the view
317
- $this->data['custom_fields'] = array_merge($custom_fields, $extra_fields);
318
-
319
- // translations
320
- $this->jsTrans = array_merge($this->jsTrans, $helper_form_engine->get_translations());
321
-
322
- // This should be the title of the page but I don't know how to make it happen...
323
- // __('Edit', WYSIJA).' '.$this->data['form']['name'];
324
- }
325
-
326
- /*
327
- * Handles the settings popup of wysija form widgets
328
- */
329
- function form_widget_settings() {
330
- $this->iframeTabs = array('form_widget_settings' => __('Widget Settings', WYSIJA));
331
- $this->js[] = 'wysija-admin-ajax';
332
- $this->js[] = 'wysija-base-script-64';
333
- $this->js[] = 'wysija-form-widget-settings';
334
-
335
- $_GET['tab'] = 'form_widget_settings';
336
-
337
- // extract parameters from url
338
- $params = array();
339
- foreach(explode('|', $_REQUEST['params']) as $pair) {
340
- // extract both key and value
341
- list($key, $value) = explode(':', $pair);
342
-
343
- // decode value
344
- $value = base64_decode($value);
345
- // unserialize if necessary (using is_serialized from WordPress)
346
- if(is_serialized($value) === true) {
347
- $value = unserialize($value);
348
- }
349
- $params[$key] = $value;
350
- }
351
-
352
- // common widget data
353
- $this->data['name'] = $_REQUEST['name'];
354
- $this->data['type'] = $_REQUEST['type'];
355
- $this->data['field'] = $_REQUEST['field'];
356
-
357
- // widget params
358
- $this->data['params'] = $params;
359
-
360
- // extra data that needs to be fetched for some widget
361
- $extra = array();
362
-
363
- switch($this->data['type']) {
364
- // in case of the list widget, we need to pass an array of all available lists
365
- case 'list':
366
- $model_list = WYSIJA::get('list', 'model');
367
-
368
- // get lists users can subscribe to (aka "enabled list")
369
- $extra['lists'] = $model_list->get(array('name', 'list_id', 'is_public'), array('is_enabled' => 1));
370
- break;
371
- }
372
-
373
- $this->data['extra'] = $extra;
374
-
375
- return $this->popupContent();
376
- exit;
377
- }
378
- // End: WYSIJA Form Editor
379
- }
 
 
 
 
1
+ <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
+ class WYSIJA_control_back_config extends WYSIJA_control_back{
4
+ var $view='config';
5
+ var $model='config';
6
+
7
+ function WYSIJA_control_back_config(){
8
+
9
+ }
10
+
11
+ function main() {
12
+ parent::WYSIJA_control_back();
13
+ wp_enqueue_style('thickbox');
14
+
15
+ if(!isset($_REQUEST['action'])) $this->action='main';
16
+ else $this->action=$_REQUEST['action'];
17
+ $this->jsTrans['testemail'] = __('Sending a test email', WYSIJA);
18
+ $this->jsTrans['bounceconnect'] = __('Bounce handling connection test', WYSIJA);
19
+ $this->jsTrans['processbounceT'] = __('Bounce handling processing', WYSIJA);
20
+ $this->jsTrans['doubleoptinon'] = __('Subscribers will now need to activate their subscription by email in order to receive your newsletters. This is recommended.', WYSIJA);
21
+ $this->jsTrans['doubleoptinoff'] = __('Unconfirmed subscribers will receive your newsletters from now on without the need to activate their subscriptions.', WYSIJA);
22
+ $this->jsTrans['processbounce'] = __('Process bounce handling now!', WYSIJA);
23
+ $this->jsTrans['errorbounceforward'] = __('When setting up the bounce system, you need to have a different address for the bounce email and the forward to address', WYSIJA);
24
+
25
+ // form list
26
+ $this->jsTrans['suredelete'] = __('Are you sure you want to delete this form?', WYSIJA);
27
+
28
+ switch($this->action) {
29
+ case 'log':
30
+ case 'save':
31
+ case 'clearlog':
32
+ wp_enqueue_script('wysija-config-settings', WYSIJA_URL.'js/admin-config-settings.js', array('wysija-admin-js-global'), WYSIJA::get_version());
33
+ wp_localize_script('wysija-config-settings', 'mpEmailCheck', WJ_Utils::get_tip_data());
34
+ wp_enqueue_script('jquery-cookie', WYSIJA_URL.'js/jquery/jquery.cookie.js', array('jquery'), WYSIJA::get_version());
35
+ case 'form_add':
36
+ case 'form_edit':
37
+ case 'form_duplicate':
38
+ case 'form_delete':
39
+ case 'form_widget_settings':
40
+ case 'form_add_field':
41
+ return $this->{$this->action}();
42
+ break;
43
+ case 'reinstall':
44
+ $this->reinstall();
45
+ return;
46
+ break;
47
+ case 'dkimcheck':
48
+ $this->dkimcheck();
49
+ if(defined('WYSIJA_REDIRECT')) $this->redirectProcess();
50
+ return;
51
+ break;
52
+ case 'doreinstall':
53
+ $this->doreinstall();
54
+ if(defined('WYSIJA_REDIRECT')){
55
+ global $wysi_location;
56
+ $wysi_location='admin.php?page=wysija_campaigns';
57
+ $this->redirectProcess();
58
+ }
59
+ return;
60
+ break;
61
+ default:
62
+ wp_enqueue_script( 'mailpoet.tooltip', WYSIJA_URL . 'js/vendor/bootstrap.tooltip.js', array( 'jquery' ), WYSIJA::get_version(), true );
63
+ wp_enqueue_style( 'mailpoet.tooltip', WYSIJA_URL . 'css/vendor/bootstrap.tooltip.css', array(), WYSIJA::get_version(), 'screen' );
64
+ wp_enqueue_script('wysija-config-settings', WYSIJA_URL.'js/admin-config-settings.js', array('wysija-admin-js-global'), WYSIJA::get_version(), true);
65
+ wp_localize_script('wysija-config-settings', 'mpEmailCheck', WJ_Utils::get_tip_data());
66
+ wp_enqueue_script('jquery-cookie', WYSIJA_URL.'js/jquery/jquery.cookie.js', array('jquery'), WYSIJA::get_version());
67
+ }
68
+
69
+ if(WYSIJA_DBG > 1) {
70
+ $this->viewObj->arrayMenus = array('log' => 'View log');
71
+ }
72
+
73
+ $this->data = array();
74
+ $hook_settings_super_advanced_params = array();
75
+ $this->data['hooks']['hook_settings_super_advanced'] = apply_filters('hook_settings_super_advanced',WYSIJA_module::execute_hook('hook_settings_super_advanced', $hook_settings_super_advanced_params), $hook_settings_super_advanced_params);
76
+ $this->action='main';
77
+
78
+ if(isset($_REQUEST['validate'])){
79
+ $this->notice(str_replace(array('[link]','[/link]'),
80
+ array('<a title="'.__('Get Premium now',WYSIJA).'" class="premium-activate" href="javascript:;">','</a>'),
81
+ __('You\'re almost there. Click this [link]link[/link] to activate the licence you have just purchased.',WYSIJA)));
82
+
83
+ }
84
+
85
+ }
86
+
87
+ function dkimcheck(){
88
+
89
+ if(isset($_POST['xtz'])){
90
+
91
+ $dataconf=json_decode(base64_decode($_POST['xtz']));
92
+ if(isset($dataconf->dkim_pubk->key) && isset($dataconf->dkim_privk)){
93
+ $modelConf=WYSIJA::get('config','model');
94
+ $dataconfsave=array('dkim_pubk'=>$dataconf->dkim_pubk->key, 'dkim_privk'=>$dataconf->dkim_privk,'dkim_1024'=>1);
95
+
96
+ $modelConf->save($dataconfsave);
97
+ WYSIJA::update_option('dkim_autosetup',false);
98
+ }
99
+ }
100
+
101
+ $this->redirect('admin.php?page=wysija_config');
102
+ return true;
103
+ }
104
+
105
+ function save(){
106
+ $_REQUEST = stripslashes_deep($_REQUEST);
107
+ $_POST = stripslashes_deep($_POST);
108
+ $this->requireSecurity();
109
+
110
+ $hook_settings_before_save = array(
111
+ 'REQUEST' =>& $_REQUEST
112
+ );
113
+ apply_filters('hook_settings_before_save',WYSIJA_module::execute_hook('hook_settings_before_save', $hook_settings_before_save),$hook_settings_before_save);
114
+
115
+ $this->modelObj->save($_REQUEST['wysija']['config'],true);
116
+
117
+ $hook_settings_super_advanced_params = array();
118
+ $this->data['hooks']['hook_settings_super_advanced'] = apply_filters('hook_settings_super_advanced',WYSIJA_module::execute_hook('hook_settings_super_advanced', $hook_settings_super_advanced_params),$hook_settings_super_advanced_params);
119
+ // redirect so that javascript values get updated
120
+ wp_redirect('admin.php?page=wysija_config'.$_REQUEST['redirecttab']);
121
+ }
122
+
123
+ function reinstall(){
124
+ $this->viewObj->title=__('Reinstall MailPoet?',WYSIJA);
125
+ return true;
126
+ }
127
+
128
+ function changeMode(){
129
+ $helperFile=WYSIJA::get('file','helper');
130
+ $helperFile->chmodr(WYSIJA_UPLOADS_DIR, 0666, 0777);
131
+ $this->redirect('admin.php?page=wysija_config');
132
+ return true;
133
+ }
134
+
135
+ function doreinstall(){
136
+
137
+ if(isset($_REQUEST['postedfrom']) && $_REQUEST['postedfrom'] === 'reinstall') {
138
+ $uninstaller=WYSIJA::get('uninstall','helper');
139
+ $uninstaller->reinstall();
140
+ }
141
+ $this->redirect('admin.php?page=wysija_config');
142
+ return true;
143
+ }
144
+
145
+ function render(){
146
+ $this->checkTotalSubscribers();
147
+ $this->viewObj->render($this->action,$this->data);
148
+ }
149
+
150
+ function log(){
151
+ $this->viewObj->arrayMenus=array('clearlog'=>'Clear log');
152
+ $this->viewObj->title='MailPoet\'s log';
153
+ return true;
154
+ }
155
+
156
+ function clearlog(){
157
+ update_option('wysija_log', array());
158
+ $this->redirect('admin.php?page=wysija_config&action=log');
159
+ return true;
160
+ }
161
+
162
+ // WYSIJA Form Editor
163
+ function form_add() {
164
+ $helper_form_engine = WYSIJA::get('form_engine', 'helper');
165
+ // set default form data
166
+ $helper_form_engine->set_data();
167
+
168
+ // create form in database with default data
169
+ $form = array('name' => __('New Form', WYSIJA));
170
+
171
+ // insert into form table
172
+ $model_forms = WYSIJA::get('forms', 'model');
173
+ $form_id = $model_forms->insert($form);
174
+
175
+ if($form_id !== null && (int)$form_id > 0) {
176
+ // merge form_id into form data for later use
177
+ $data = array_merge(array('form_id' => $form_id), $helper_form_engine->get_data());
178
+ // update form data in form engine
179
+ $helper_form_engine->set_data($data);
180
+ // update form data in database
181
+ $model_forms->update(array('data' => $helper_form_engine->get_encoded('data')), array('form_id' => (int)$form_id));
182
+
183
+ // redirect to form editor, passing along the newly created form id
184
+ WYSIJA::redirect('admin.php?page=wysija_config&action=form_edit&id='.$form_id);
185
+ } else {
186
+ WYSIJA::redirect('admin.php?page=wysija_config#tab-forms');
187
+ }
188
+ return true;
189
+ }
190
+
191
+ function form_duplicate() {
192
+
193
+ if(isset($_GET['id']) && (int)$_GET['id'] > 0) {
194
+ $form_id = (int)$_GET['id'];
195
+
196
+ $model_forms = WYSIJA::get('forms', 'model');
197
+
198
+ // get form data
199
+ $form = $model_forms->getOne(array('name', 'data', 'styles'), array('form_id' => $form_id));
200
+
201
+ if(empty($form)) {
202
+ $this->error(__('This form does not exist', WYSIJA), true);
203
+ } else {
204
+ // reset model forms
205
+ $model_forms->reset();
206
+
207
+ // add "copy" to the name
208
+ $form['name'] = $form['name'].' - '.__('Copy', WYSIJA);
209
+
210
+ // insert form (duplicated)
211
+ $model_forms->insert($form);
212
+
213
+ // display notice
214
+ $this->notice(sprintf(__('The form named "%1$s" has been created.', WYSIJA), $form['name']));
215
+ }
216
+ }
217
+
218
+ WYSIJA::redirect('admin.php?page=wysija_config#tab-forms');
219
+ }
220
+
221
+ function form_delete() {
222
+
223
+ $this->requireSecurity();
224
+
225
+ if(isset($_GET['id']) && (int)$_GET['id'] > 0) {
226
+ $form_id = (int)$_GET['id'];
227
+
228
+ $model_forms = WYSIJA::get('forms', 'model');
229
+
230
+ // get form data
231
+ $form = $model_forms->getOne(array('name'), array('form_id' => $form_id));
232
+
233
+ if(empty($form)) {
234
+ $this->error(__('This form has already been deleted.', WYSIJA), true);
235
+ } else {
236
+ // delete the form in the database
237
+ $model_forms->reset();
238
+ $model_forms->delete(array('form_id' => $form_id));
239
+
240
+ // display notice
241
+ $this->notice(sprintf(__('The form named "%1$s" has been deleted.', WYSIJA), $form['name']));
242
+ }
243
+ }
244
+
245
+ WYSIJA::redirect('admin.php?page=wysija_config#tab-forms');
246
+ }
247
+
248
+ function form_edit() {
249
+ // define whether the form can be edited
250
+ $this->data['can_edit'] = true;
251
+
252
+ // wysija form editor javascript files
253
+ $this->js[]='wysija-form-editor';
254
+ $this->js[]='wysija-admin-ajax-proto';
255
+ // $this->js[]='wysija-admin-ajax';
256
+ $this->js[]='wysija-base-script-64';
257
+ $this->js[] = 'mailpoet-select2';
258
+
259
+ // make sure the editor content is not cached
260
+ //header('Cache-Control: no-cache, max-age=0, must-revalidate, no-store'); // HTTP/1.1
261
+ //header('Expires: Fri, 9 Mar 1984 00:00:00 GMT');
262
+
263
+ // get form id
264
+ $form_id = (isset($_REQUEST['id']) && (int)$_REQUEST['id'] > 0) ? (int)$_REQUEST['id'] : null;
265
+ $form = array('name' => __('New form', WYSIJA));
266
+
267
+ // if no form id was specified, then it's a new form
268
+ if($form_id !== null) {
269
+ // try to get form data based on form id
270
+ $model_forms = WYSIJA::get('forms', 'model');
271
+ $form = $model_forms->getOne($form_id);
272
+
273
+ // if the form does not exist
274
+ if(empty($form)) {
275
+ // redirect to forms list
276
+ $this->error(__('This form does not exist.', WYSIJA), true);
277
+ WYSIJA::redirect('admin.php?page=wysija_config#tab-forms');
278
+ } else {
279
+ // pass form id to the view
280
+ $this->data['form_id'] = (int)$form['form_id'];
281
+ }
282
+ }
283
+ // pass form to the view
284
+ $this->data['form'] = $form;
285
+
286
+ $helper_form_engine = WYSIJA::get('form_engine', 'helper');
287
+ $lists = $helper_form_engine->get_lists();
288
+ $this->data['lists'] = $lists;
289
+
290
+ // disable editing capability when there is no list
291
+ if(empty($lists)) {
292
+ $this->data['can_edit'] = false;
293
+ }
294
+
295
+ // get custom fields
296
+ $this->data['custom_fields'] = $helper_form_engine->get_custom_fields();
297
+
298
+ // translations
299
+ $this->jsTrans = array_merge($this->jsTrans, $helper_form_engine->get_translations());
300
+ }
301
+
302
+ /*
303
+ * Handles the settings popup of wysija form widgets
304
+ */
305
+ function form_widget_settings() {
306
+ $this->iframeTabs = array('form_widget_settings' => __('Widget Settings', WYSIJA));
307
+ $this->js[] = 'wysija-admin-ajax';
308
+ $this->js[] = 'wysija-base-script-64';
309
+ $this->js[] = 'wysija-scriptaculous';
310
+
311
+ $_GET['tab'] = 'form_widget_settings';
312
+
313
+ // if there is a field id, let's get all that from this field
314
+ if(isset($_REQUEST['field_id'])) {
315
+ $field_id = ((int)$_REQUEST['field_id'] > 0) ? (int)$_REQUEST['field_id'] : 0;
316
+
317
+ // if the id is positive then try to fetch field data
318
+ $custom_field = WJ_Field::get($field_id);
319
+
320
+ // if field has been found
321
+ if($custom_field !== NULL) {
322
+ $this->data['name'] = (isset($_REQUEST['name'])) ? $_REQUEST['name'] : $custom_field->name;
323
+ $this->data['type'] = (isset($_REQUEST['type'])) ? $_REQUEST['type'] : $custom_field->type;
324
+ $this->data['field'] = $custom_field->user_column_name();
325
+ $this->data['params'] = $custom_field->settings;
326
+ } else {
327
+ $this->data['name'] = (isset($_REQUEST['name'])) ? $_REQUEST['name'] : null;
328
+ $this->data['type'] = (isset($_REQUEST['type'])) ? $_REQUEST['type'] : null;
329
+ $this->data['field'] = null;
330
+ $this->data['params'] = null;
331
+ }
332
+
333
+ $this->data['field_id'] = $field_id;
334
+ } else {
335
+ // extract parameters from url
336
+ $params = array();
337
+ if(isset($_REQUEST['params']) && trim(strlen($_REQUEST['params'])) > 0) {
338
+ $pairs = explode('|', $_REQUEST['params']);
339
+ if(count($pairs) > 0) {
340
+ foreach($pairs as $pair) {
341
+ // extract both key and value
342
+ list($key, $value) = explode(':', $pair);
343
+
344
+ // decode value
345
+ $value = base64_decode($value);
346
+ // unserialize if necessary (using is_serialized from WordPress)
347
+ if(is_serialized($value) === true) {
348
+ $value = unserialize($value);
349
+ }
350
+ $params[$key] = $value;
351
+ }
352
+ }
353
+ }
354
+
355
+ // common widget data
356
+ $this->data['name'] = (isset($_REQUEST['name'])) ? $_REQUEST['name'] : null;
357
+ $this->data['type'] = (isset($_REQUEST['type'])) ? $_REQUEST['type'] : null;
358
+ $this->data['field'] = (isset($_REQUEST['field'])) ? $_REQUEST['field'] : null;
359
+
360
+ // widget params
361
+ $this->data['params'] = $params;
362
+
363
+ // extra data that needs to be fetched for some widget
364
+ $extra = array();
365
+
366
+ switch($this->data['type']) {
367
+ // in case of the list widget, we need to pass an array of all available lists
368
+ case 'list':
369
+ $model_list = WYSIJA::get('list', 'model');
370
+
371
+ // get lists users can subscribe to (aka "enabled list")
372
+ $extra['lists'] = $model_list->get(array('name', 'list_id', 'is_public'), array('is_enabled' => 1));
373
+ break;
374
+ }
375
+
376
+ $this->data['extra'] = $extra;
377
+ }
378
+
379
+ return $this->popupContent();
380
+ exit;
381
+ }
382
+ // End: WYSIJA Form Editor
383
+ }
controllers/back/premium.php ADDED
@@ -0,0 +1,34 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ defined('WYSIJA') or die('Restricted access');
4
+
5
+ class WYSIJA_control_back_premium extends WYSIJA_control_back {
6
+
7
+ /**
8
+ * Main view of this controller
9
+ * @var string
10
+ */
11
+ public $view = 'premium';
12
+ public $model = 'config';
13
+
14
+
15
+ /**
16
+ * Constructor
17
+ */
18
+ function WYSIJA_control_back_premium() {
19
+ }
20
+ function defaultDisplay() {
21
+ $this->jsTrans['premium_activate'] = __('Already paid? Click here to activate', WYSIJA);
22
+ $this->jsTrans['premium_activating'] = __('Checking license', WYSIJA);
23
+ }
24
+
25
+ function premium_ben() {
26
+ $this->jsTrans['premium_activate'] = __('Already paid? Click here to activate', WYSIJA);
27
+ $this->jsTrans['premium_activating'] = __('Checking license', WYSIJA);
28
+ }
29
+
30
+ function premium_kim() {
31
+ $this->jsTrans['premium_activate'] = __('Already paid? Click here to activate', WYSIJA);
32
+ $this->jsTrans['premium_activating'] = __('Checking license', WYSIJA);
33
+ }
34
+ }
controllers/back/statistics.php ADDED
@@ -0,0 +1,200 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
+ require_once(WYSIJA_CORE.'module'.DS.'statistics.php'); // @todo
4
+
5
+ class WYSIJA_control_back_statistics extends WYSIJA_control_back
6
+ {
7
+
8
+ /**
9
+ * Main model of this controller
10
+ * @var string
11
+ */
12
+ public $model = 'statistics';
13
+
14
+ /**
15
+ * Main view of this controller
16
+ * @var string
17
+ */
18
+ public $view = 'statistics';
19
+
20
+ /**
21
+ * Base URL of all requests
22
+ * @var string
23
+ */
24
+ public $base_url = 'admin.php';
25
+
26
+ /**
27
+ * Load blocks at a same time (FALSE) or one by one (TRUE)
28
+ * @var TRUE
29
+ */
30
+ protected $lazy_load = true;
31
+
32
+ /**
33
+ * list of pre-defined dates
34
+ * @var Array
35
+ */
36
+ protected $pre_defined_dates = array( );
37
+
38
+ protected $date_format = 'Y/m/d';
39
+
40
+ protected $js_date_format = 'yy/mm/dd';
41
+
42
+ /**
43
+ * Constructor
44
+ */
45
+ function WYSIJA_control_back_statistics()
46
+ {
47
+
48
+ }
49
+
50
+ public function defaultDisplay()
51
+ {
52
+ $this->pre_defined_dates = $this->get_pre_defined_dates();
53
+ // Define view
54
+ $this->viewShow = $this->action = 'main';
55
+ $this->js['jquery.core'] = 'jquery/ui/jquery.ui.core';
56
+ $this->js['jquery.datepicker'] = 'jquery/ui/jquery.ui.datepicker';
57
+ $this->js['wysijalazyload'] = 'wysija-lazyload';
58
+ $this->js['admin-statistics-filter'] = 'admin-statistics-filter';
59
+ wp_enqueue_style('jquery.core', WYSIJA_URL.'css/jquery/ui/themes/base/jquery.ui.core.min.css', array( ), WYSIJA::get_version());
60
+ wp_enqueue_style('jquery.core', WYSIJA_URL.'css/jquery/ui/themes/base/jquery.ui.theme.min.css', array( ), WYSIJA::get_version());
61
+
62
+ // date filter
63
+ $default_duration = $this->get_default_duration();
64
+ if (function_exists('date_diff'))
65
+ {
66
+ $this->data['date_interval'] = date_diff(date_create($default_duration['from']), date_create($default_duration['to']));
67
+ }
68
+ else
69
+ {
70
+ $duration = strtotime($default_duration['to']) - strtotime($default_duration['from']);
71
+ $helper_toolbox = WYSIJA::get('toolbox', 'helper');
72
+ $this->data['date_interval'] = (object)$helper_toolbox->convert_seconds_to_array($duration, false);
73
+ }
74
+
75
+ $this->data['custom_dates'] = $this->pre_defined_dates;
76
+ $this->data['default_duration'] = $default_duration;
77
+ $this->data['js_date_format'] = $this->js_date_format;
78
+
79
+ // Process and push data into view
80
+ $this->data['lazy_load'] = $this->lazy_load;
81
+ $hook_name = 'hook_stats';
82
+ $hook_params = array( );
83
+ $hook_params['top'] = WYSIJA_module_statistics::DEFAULT_TOP_RECORDS;
84
+ $hook_params['from'] = !empty($_REQUEST['filter']['from']) ? $_REQUEST['filter']['from'] : $default_duration['from'];
85
+ $hook_params['to'] = !empty($_REQUEST['filter']['to']) ? $_REQUEST['filter']['to'] : $default_duration['to'];
86
+ $hook_params['group_by'] = ($this->data['date_interval']->days == 0 || $this->data['date_interval']->days > WYSIJA_module_statistics::SWITCHING_DATE_TO_MONTH_THRESHOLD) ?
87
+ WYSIJA_module_statistics::GROUP_BY_MONTH :
88
+ WYSIJA_module_statistics::GROUP_BY_DATE; // $this->data['date_interval']->days == 0, means, no begin date, no end date
89
+ // Hack!
90
+ $_REQUEST['limit_pp'] = $hook_params['top']; // Pagination, mark current selected value
91
+
92
+
93
+ // Modify TO date to make sure we always count 23:59:59 of that day
94
+ $to = new DateTime($hook_params['to']);
95
+ $to->modify('+1 day');
96
+ $hook_params['to'] = $to->format($this->date_format);
97
+
98
+ $modules = WYSIJA_module::get_modules_from_hook($hook_name);
99
+ $this->data['modules'] = $modules;
100
+ $this->data['lazy_load_modules'] = array( );
101
+ $this->data['first_module'] = '';
102
+
103
+ if (!$this->lazy_load)
104
+ {
105
+ $this->data['hooks'][$hook_name] = apply_filters('hook_stats', '', $hook_params);
106
+ }
107
+ else
108
+ {
109
+ if (!empty($modules))
110
+ {
111
+ $first_module = array_shift($modules);
112
+ // List of lazy loaded modules
113
+ $this->data['lazy_load_modules'] = $modules;
114
+
115
+ // Evenly we are lazy loading, we always load the first module by default
116
+ $this->data['first_module'] = apply_filters('custom_module_hook', '', $first_module, $hook_name, $hook_params);
117
+ }
118
+ }
119
+ }
120
+
121
+ /**
122
+ * get pre defined dates (duration)
123
+ * @return type
124
+ */
125
+ protected function get_pre_defined_dates()
126
+ {
127
+ return array(
128
+ array(
129
+ 'value' => 7,
130
+ 'label' => __('Last 7 days', WYSIJA),
131
+ 'selected' => false,
132
+ 'from' => date($this->date_format, strtotime('-7 days')),
133
+ 'to' => date($this->date_format, strtotime('today'))
134
+ ),
135
+ array(
136
+ 'value' => 'last_month',
137
+ 'label' => __('Last month', WYSIJA),
138
+ 'selected' => false,
139
+ 'from' => date($this->date_format, mktime(0, 0, 0, date('m') - 1, 1, date('Y'))),
140
+ 'to' => date($this->date_format, mktime(0, 0, 0, date('m'), 0, date('Y')))
141
+ ),
142
+ array(
143
+ 'value' => 30,
144
+ 'label' => __('Last 30 days', WYSIJA),
145
+ 'selected' => false,
146
+ 'from' => date($this->date_format, strtotime('-30 days')),
147
+ 'to' => date($this->date_format, strtotime('today'))
148
+ ),
149
+ array(
150
+ 'value' => 90,
151
+ 'label' => __('Last 90 days', WYSIJA),
152
+ 'selected' => true,
153
+ 'from' => date($this->date_format, strtotime('-90 days')),
154
+ 'to' => date($this->date_format, strtotime('today'))
155
+ ),
156
+ array(
157
+ 'value' => 180,
158
+ 'label' => __('Last 180 days', WYSIJA),
159
+ 'selected' => false,
160
+ 'from' => date($this->date_format, strtotime('-180 days')),
161
+ 'to' => date($this->date_format, strtotime('today'))
162
+ ),
163
+ array(
164
+ 'value' => 365,
165
+ 'label' => __('Last 365 days', WYSIJA),
166
+ 'selected' => false,
167
+ 'from' => date($this->date_format, strtotime('-365 days')),
168
+ 'to' => date($this->date_format, strtotime('today'))
169
+ ),
170
+ array(
171
+ 'value' => 0,
172
+ 'label' => __('Custom dates', WYSIJA),
173
+ 'selected' => false,
174
+ 'from' => '',
175
+ 'to' => ''
176
+ ),
177
+ );
178
+ }
179
+
180
+ /**
181
+ * Get default duration of stats
182
+ * @return int
183
+ */
184
+ protected function get_default_duration()
185
+ {
186
+ foreach ($this->pre_defined_dates as $duration)
187
+ if (isset($duration['selected']) && $duration['selected'])
188
+ return $duration;
189
+ return end($this->pre_defined_dates);
190
+ }
191
+
192
+ function date_diff($time_start, $time_end)
193
+ {
194
+ $result = null;
195
+ $duration = $time_end - $time_start;
196
+ $result->days = floor($duration / (60 * 60 * 24));
197
+ return $result;
198
+ }
199
+
200
+ }
controllers/back/subscribers.php CHANGED
@@ -1,16 +1,34 @@
1
  <?php
2
  defined('WYSIJA') or die('Restricted access');
3
  class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
4
- var $model="user";
5
- var $view="subscribers";
6
- var $list_columns=array("user_id","firstname", "lastname","email","created_at");
7
  var $searchable=array('email','firstname', 'lastname');
8
- var $_export_batch = 2000; //set batch of records, useful when retrieving the list of user Ids to export
9
  var $_separators = array(',', ';'); // csv separator; comma is for standard csv, semi-colon is good for Excel
10
  var $_default_separator = ';';
11
 
12
- function WYSIJA_control_back_subscribers(){
 
 
 
 
 
 
 
13
 
 
 
 
 
 
 
 
 
 
 
 
 
14
  }
15
 
16
  function save(){
@@ -90,13 +108,24 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
90
  $notEqual=array_merge($core_listids, $arrayLists);
91
 
92
  //unsubscribe from lists which exist in the old list but does not exist in the new list
93
- $unsubsribe_list = array_diff(array_keys($oldlistids),$_POST['wysija']['user_list']['list_id']);
94
  if(!empty($unsubsribe_list))
95
  {
96
  $modelUL->reset();
97
  $modelUL->update(array('unsub_date'=>time()),array('user_id'=>$id,'list_id'=>$unsubsribe_list));
98
  }
99
  $modelUL->reset();
 
 
 
 
 
 
 
 
 
 
 
100
  }else{
101
  //instead of going through a classic save we should save through the helper
102
  $data=$_REQUEST['wysija'];
@@ -115,186 +144,103 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
115
  return true;
116
  }
117
 
118
- function defaultDisplay(){
119
- $this->viewShow=$this->action='main';
120
- $this->js[]='wysija-admin-list';
121
- $this->viewObj->msgPerPage=__('Subscribers per page:',WYSIJA);
122
-
123
- $this->jsTrans['selecmiss']=__('Select at least 1 subscriber!',WYSIJA);
124
- $orphaned=$filterJoin=false;
125
- //get the filters
126
- if(isset($_REQUEST['search']) && $_REQUEST['search']){
127
- $this->filters['like']=array();
128
- $_REQUEST['search']=trim($_REQUEST['search']);
129
- foreach($this->searchable as $field)
130
- $this->filters['like'][$field]=trim($_REQUEST['search']);
131
- }
132
 
133
- // Lists filters
134
- // - override wysija[filter][filter-list] if this is empty
135
- if(
136
- !empty($_REQUEST['redirect'])
137
- && (!empty($_REQUEST['filter_list']) || !empty($_REQUEST['filter-list']))
138
- && empty($_REQUEST['wysija']['filter']['filter_list'])
139
- )
140
- $_REQUEST['wysija']['filter']['filter_list'] = !empty ($_REQUEST['filter_list']) ? $_REQUEST['filter_list'] : $_REQUEST['filter-list'];
141
-
142
- if(isset($_REQUEST['wysija']['filter']['filter_list']) && $_REQUEST['wysija']['filter']['filter_list']){
143
- if ($_REQUEST['wysija']['filter']['filter_list'] == 'orphaned') {
144
- $this->filters['equal']['list_id'] = null;
145
- $orphaned = true;
146
- } else {
147
- //we only get subscribed or unconfirmed users
148
- $this->filters['equal']['list_id'] = $_REQUEST['wysija']['filter']['filter_list'];
149
- $filterJoin=true;
150
- }
151
- }
152
-
153
- $config=WYSIJA::get('config','model');
154
- if(isset($_REQUEST['link_filter']) && $_REQUEST['link_filter']){
155
- switch($_REQUEST['link_filter']){
156
- case 'unconfirmed':
157
- $this->filters['equal']['status'] = 0;
158
- break;
159
- case 'unsubscribed':
160
- $this->filters['equal']['status'] = -1;
161
- break;
162
- case 'subscribed':
163
- if($config->getValue('confirm_dbleoptin')) $this->filters['equal']['status'] = 1;
164
- else $this->filters['greater_eq']=array('status'=>0);
165
- break;
166
- }
167
- }
168
-
169
- $this->modelObj->noCheck=true;
170
-
171
-
172
- //0 - counting request */
173
- if($filterJoin){
174
- $queryCmmonStart='SELECT count(distinct A.user_id) as users, max(A.created_at) as max_create_at FROM `[wysija]user_list` as B';
175
- $queryCmmonStart.=' JOIN `[wysija]'.$this->modelObj->table_name.'` as A on A.user_id=B.user_id';
176
- } elseif($orphaned) {
177
- $queryCmmonStart='SELECT count(distinct A.user_id) as users, max(A.created_at) as max_create_at FROM `[wysija]user` as A';
178
- $queryCmmonStart.=' LEFT JOIN `[wysija]user_list` as B on A.user_id=B.user_id';
179
- } else {
180
- $queryCmmonStart='SELECT count(distinct A.user_id) as users, max(A.created_at) as max_create_at FROM `[wysija]'.$this->modelObj->table_name.'` as A';
181
- }
182
-
183
-
184
- //all the counts query */
185
- $query='SELECT count(user_id) as users, status, max(created_at) as max_create_at FROM `[wysija]'.$this->modelObj->table_name.'` GROUP BY status';
186
- $countss=$this->modelObj->query('get_res',$query,ARRAY_A);
187
- $counts=array();
188
- $total=0;
189
-
190
- $arr_max_create_at = array();
191
- foreach($countss as $count){
192
- switch($count['status']){
193
- case '0':
194
- $type='unconfirmed';
195
- break;
196
- case '-1':
197
- $type='unsubscribed';
198
- break;
199
- case '1':
200
- $type='subscribed';
201
- break;
202
- }
203
- $arr_max_create_at[] = $count['max_create_at'];
204
- $total=$total+$count['users'];
205
- $counts[$type]=$count['users'];
206
- }
207
- //if(!isset($counts["unconfirmed"])) $counts["unconfirmed"]=0;
208
- if(!$config->getValue('confirm_dbleoptin')) {
209
- if(isset($counts['subscribed'])) {
210
- if(isset($counts['unconfirmed'])) $counts['subscribed']=$counts['subscribed']+$counts['unconfirmed'];
211
- else $counts['subscribed']=$counts['subscribed'];
212
-
213
- }else{
214
- $counts['subscribed']=$counts['unconfirmed'];
215
  }
216
- unset($counts['unconfirmed']);
217
  }
 
 
218
 
219
- $counts['all']=$total;
220
-
221
- $this->modelObj->reset();
222
-
223
- if($this->filters) $this->modelObj->setConditions($this->filters);
224
-
225
-
226
- //1 - user request
227
-
228
- if($filterJoin){
229
-
230
- $query="SELECT distinct(A.user_id), A.firstname, A.lastname,A.status , A.email, A.created_at FROM `[wysija]user_list` as B";
231
- $query.=" JOIN `[wysija]".$this->modelObj->table_name."` as A on A.user_id=B.user_id";
232
-
233
- }elseif($orphaned) {
234
-
235
- $query="SELECT distinct(A.user_id), A.firstname, A.lastname,A.status , A.email, A.created_at FROM `[wysija]user` as A";
236
- $query.=" LEFT JOIN `[wysija]user_list` as B on B.user_id=A.user_id";
237
-
238
- } else {
239
- $query="SELECT distinct(A.user_id), A.firstname, A.lastname,A.status , A.email, A.created_at FROM `[wysija]".$this->modelObj->table_name."` as A";
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
240
  }
241
 
242
- $queryFinal=$this->modelObj->makeWhere();
 
 
 
 
 
 
 
 
 
243
 
244
- /* without filter we already have the total number of subscribers */
245
- $max_create_at = null; //max value of create_at field of current list of users
246
 
247
- if($this->filters){
248
- $count_rows = $this->modelObj->getResults($queryCmmonStart.$queryFinal);
249
- $count_rows = $count_rows[0];
250
- $this->modelObj->countRows = $count_rows['users'];
251
- $max_create_at = $count_rows['max_create_at'];
252
- }
253
- else{
254
- $max_create_at = !empty($arr_max_create_at) ? max($arr_max_create_at) : 0;
255
- $this->modelObj->countRows=$counts['all'];
256
- }
257
-
258
- $orderby=' ORDER BY ';
259
- if(isset($_REQUEST['orderby'])){
260
- $orderby.=$_REQUEST['orderby'].' '.$_REQUEST['ordert'];
261
- }else{
262
- $orderby.=$this->modelObj->pk.' desc';
263
- }
264
- $this->data['max_create_at'] = $max_create_at;
265
- $this->data['subscribers']=$this->modelObj->getResults($query.$queryFinal." ".$orderby.$this->modelObj->setLimit());
266
  $this->data['current_counts'] = $this->modelObj->countRows;
267
  $this->data['show_batch_select'] = ($this->modelObj->limit >= $this->modelObj->countRows) ? false : true;
 
268
  $this->modelObj->reset();
269
 
270
- /*make the data object for the listing view*/
271
- $modelList=WYSIJA::get('list','model');
272
- $modelList->reset();
273
- $listsAll=$modelList->getRows(false);
274
- /* 2 - list request */
275
 
276
- /*$query="SELECT A.list_id, A.name, count( B.user_id ) AS users FROM `".$modelList->getPrefix().$modelList->table_name."` as A";
277
- $query.=" JOIN `".$modelList->getPrefix()."user_list` as B on A.list_id = B.list_id";
278
- $query.=" GROUP BY A.list_id";
279
 
280
-
281
- $listsDB=$modelList->getResults($query); */
282
- $listsDB=$modelList->getLists();
283
  $lists=array();
284
- foreach($listsAll as $listobje){
285
- $lists[$listobje['list_id']]=$listobje;
286
- }
287
- foreach($listsDB as $listobj){
288
- if($listobj['subscribers']) $lists[$listobj['list_id']]['users']=$listobj['subscribers'];
289
  }
290
- $listsDB=null;
291
 
292
  $user_ids=array();
293
  foreach($this->data['subscribers'] as $subscriber){
294
  $user_ids[]=$subscriber['user_id'];
295
  }
296
 
297
- /* 3 - user_list request */
298
  if($user_ids){
299
  $modeluList=WYSIJA::get('user_list','model');
300
  $userlists=$modeluList->get(array('list_id','user_id','unsub_date'),array('user_id'=>$user_ids));
@@ -303,11 +249,9 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
303
  $this->data['lists']=$lists;
304
  $this->data['counts']=array_reverse($counts);
305
 
306
-
307
-
308
- /* regrouping all the data in the same array */
309
  foreach($this->data['subscribers'] as $keysus=>$subscriber){
310
- /* default key while we don't have the data*/
311
  //TODO add data for stats about emails opened clicked etc
312
  $this->data['subscribers'][$keysus]['emails']=0;
313
  $this->data['subscribers'][$keysus]['opened']=0;
@@ -330,9 +274,7 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
330
  }else{
331
  $this->data['subscribers'][$keysus]['lists'].=', '.$this->data['lists'][$userlist['list_id']]['name'];
332
  }
333
-
334
  }
335
-
336
  }
337
  }
338
  }
@@ -348,6 +290,7 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
348
  $this->messages['insert'][false]=__('Subscriber has not been saved.',WYSIJA);
349
  $this->messages['update'][true]=__('Subscriber has been modified. [link]Edit again[/link].',WYSIJA);
350
  $this->messages['update'][false]=__('Subscriber has not been modified.',WYSIJA);
 
351
  parent::WYSIJA_control_back();
352
 
353
  //we change the default model of the controller based on the action
@@ -367,9 +310,38 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
367
  if(!isset($_REQUEST['action']) || !$_REQUEST['action']) {
368
  $this->defaultDisplay();
369
  $this->checkTotalSubscribers();
 
 
 
 
 
370
  }
371
- else $this->_tryAction($_REQUEST['action']);
372
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
373
  }
374
 
375
  /**
@@ -391,30 +363,49 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
391
  $this->notice(sprintf(__('%1$s subscribers have been added to "%2$s".',WYSIJA),$this->_affected_rows,$result['name']));
392
  else
393
  $this->notice(sprintf(__('%1$s subscriber have been added to "%2$s".',WYSIJA),$this->_affected_rows,$result['name']));
394
- $this->redirect('admin.php?page=wysija_subscribers&filter-list='.$data['listid']);
395
  }
396
 
397
  /**
398
- * bulk action move to list
399
- * @param type $data = array('list_id'=>?)
 
400
  */
401
- function movetolist($data){
402
- $helpU=WYSIJA::get('user','helper');
403
- if(!empty($this->_batch_select))
404
- $helpU->moveToList($data['listid'],$this->_batch_select, true);
405
- else
406
- $helpU->moveToList($data['listid'],$_POST['wysija']['user']['user_id']);
407
 
408
- $modelL=WYSIJA::get('list','model');
409
- $result=$modelL->getOne(array('name'),array('list_id'=>$data['listid']));
 
 
 
410
 
411
- if($this->_affected_rows > 1)
412
- $this->notice(sprintf(__('%1$s subscribers have been moved to "%2$s".',WYSIJA),$this->_affected_rows,$result['name']));
413
- else
414
- $this->notice(sprintf(__('%1$s subscriber have been moved to "%2$s".',WYSIJA),$this->_affected_rows,$result['name']));
415
- $this->redirect('admin.php?page=wysija_subscribers&filter-list='.$data['listid']);
 
 
 
 
 
416
  }
417
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
418
  /**
419
  * Bulk action remove subscribers from all existing lists
420
  * @param type $data = array('list_id'=>?)
@@ -427,10 +418,10 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
427
  $helpU->removeFromLists(array(),$_POST['wysija']['user']['user_id']);
428
 
429
  if($this->_affected_rows > 1)
430
- $this->notice(sprintf(__('%1$s subscribers have been removed from all exising lists.',WYSIJA),$this->_affected_rows));
431
  else
432
- $this->notice(sprintf(__('%1$s subscriber have been removed from all exising lists.',WYSIJA),$this->_affected_rows));
433
- $this->defaultDisplay();
434
  }
435
 
436
  /**
@@ -450,7 +441,8 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
450
  $this->notice(sprintf(__('%1$s subscribers have been removed from "%2$s".',WYSIJA),$this->_affected_rows, $result['name']));
451
  else
452
  $this->notice(sprintf(__('%1$s subscriber have been removed from "%2$s".',WYSIJA),$this->_affected_rows, $result['name']));
453
- $this->redirect('admin.php?page=wysija_subscribers&filter-list='.$data['listid']);
 
454
  }
455
 
456
  /**
@@ -467,7 +459,7 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
467
  $this->notice(sprintf(__('%1$s subscribers have been confirmed.',WYSIJA),$this->_affected_rows));
468
  else
469
  $this->notice(sprintf(__('%1$s subscriber have been confirmed.',WYSIJA),$this->_affected_rows));
470
- $this->defaultDisplay();
471
  }
472
 
473
  /**
@@ -572,62 +564,38 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
572
 
573
  function edit($id=false){
574
 
575
- if(isset($_REQUEST['id']) || $id){
576
- if(!$id) $id=$_REQUEST['id'];
577
-
578
- $this->js[]='wysija-validator';
579
- $this->js[]='wysija-charts';
580
-
581
- $this->data=array();
582
- $this->data['user']=$this->modelObj->getDetails(array('user_id'=>$id),true);
583
- if(!$this->data['user']){
584
- $this->notice(__('No subscriber found, most probably because he was deleted.',WYSIJA));
585
- return $this->redirect();
586
- }
587
- $modelList=WYSIJA::get('list','model');
588
- $modelList->limitON=false;
589
- $modelList->orderBy('is_enabled','DESC');
590
- $this->data['list']=$modelList->get(false,array('greater'=>array('is_enabled'=>'-1') ));
591
-
592
- //we prepare the data to be pased to the charts script
593
- $this->data['charts']['title']=' ';
594
- $this->data['charts']['stats']=array();
595
-
596
- //group email user stats by status where userid
597
- $modelEUS=WYSIJA::get('email_user_stat','model');
598
- $modelEUS->setConditions(array('equal'=>array('user_id'=>$id)));
599
- $query='SELECT count(email_id) as emails, status FROM `[wysija]'.$modelEUS->table_name."`";
600
- $query.=$modelEUS->makeWhere();
601
- $query.=' GROUP BY status';
602
- $countss=$modelEUS->query('get_res',$query,ARRAY_A);
603
-
604
- //-2 is an automatic unsubscribed made through bounce processing
605
- $statuses=array('-1'=>__('Bounced',WYSIJA),'0'=>__('Unopened',WYSIJA),'1'=>__('Opened',WYSIJA),'2'=>__('Clicked',WYSIJA),'3'=>__('Unsubscribed',WYSIJA) ,'-2'=>__('Unsubscribed',WYSIJA));
606
- foreach($countss as $count){
607
- $this->data['charts']['stats'][]=array('name'=>$statuses[$count['status']],'number'=>$count['emails']);
608
- }
609
 
610
- //email_user_url
611
- $modelEUU=WYSIJA::get('email_user_url','model');
612
- $modelEUU->setConditions(array('equal'=>array('user_id'=>$id)));
613
- $query='SELECT A.*,B.*,C.subject as name FROM `[wysija]'.$modelEUU->table_name."` as A JOIN `[wysija]url` as B on A.url_id=B.url_id JOIN `[wysija]email` as C on C.email_id=A.email_id ";
614
- $query.=$modelEUS->makeWhere();
615
- $query.=' ORDER BY A.number_clicked DESC ';
616
- $this->data['clicks']=$modelEUS->query('get_res',$query,ARRAY_A);
617
 
618
- foreach($this->data['clicks'] as $k => &$v){
619
- $v['url']=urldecode(utf8_encode($v['url']));
620
- }
 
 
 
621
 
622
- $chartsencoded=base64_encode(json_encode($this->data['charts']));
623
- wp_enqueue_script('wysija-admin-subscribers-edit-manual', WYSIJA_URL.'js/admin-subscribers-edit-manual.php?data='.$chartsencoded, array( 'wysija-charts' ), true);
 
 
 
 
624
 
625
- $this->viewObj->title=__('Edit',WYSIJA).' '.$this->data['user']['details']['email'];
 
 
 
 
 
 
626
 
627
- }else{
628
- $this->error('Cannot edit element primary key is missing : '. get_class($this));
629
- }
630
 
 
 
631
  }
632
 
633
  function deletelist(){
@@ -639,23 +607,20 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
639
  * 2 delete the list campaigns references
640
  * 4 delete the list
641
  */
642
- $model=WYSIJA::get('list','model');
643
- $data=$model->getOne(array('name','namekey','welcome_mail_id'),array('list_id'=>(int)$_REQUEST['id']));
644
 
645
  if($data && isset($data['namekey']) && ($data['namekey']!='users')){
646
 
647
  //there is no welcome email per list that's old stuff
648
- //$modelRECYCLE=WYSIJA::get('email','model');
649
- //$modelRECYCLE->delete(array('email_id'=>$data['welcome_mail_id']));
650
-
651
- $modelRECYCLE=WYSIJA::get('user_list','model');
652
- $modelRECYCLE->delete(array('list_id'=>$_REQUEST['id']));
653
 
654
- $modelRECYCLE=WYSIJA::get('campaign_list','model');
655
- $modelRECYCLE->delete(array('list_id'=>$_REQUEST['id']));
656
 
657
- $model->reset();
658
- $model->delete(array('list_id'=>$_REQUEST['id']));
659
 
660
  $this->notice(sprintf(__('List "%1$s" has been deleted.',WYSIJA),$data['name']));
661
  }else{
@@ -670,8 +635,8 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
670
  function synchlist(){
671
  $this->requireSecurity();
672
 
673
- $helperU=WYSIJA::get('user','helper');
674
- $helperU->synchList($_REQUEST['id']);
675
 
676
  $this->redirect('admin.php?page=wysija_subscribers&action=lists');
677
  }
@@ -682,8 +647,8 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
682
  global $current_user;
683
 
684
  if(is_multisite() && is_super_admin( $current_user->ID )){
685
- $helperU=WYSIJA::get('user','helper');
686
- $helperU->synchList($_REQUEST['id'],true);
687
  }
688
 
689
  $this->redirect('admin.php?page=wysija_subscribers&action=lists');
@@ -702,7 +667,7 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
702
  if($_REQUEST['wysija']['list']['is_public']=='on')$_REQUEST['wysija']['list']['is_public']=1;
703
  else $_REQUEST['wysija']['list']['is_public']=0;
704
  }else{
705
- $_REQUEST['wysija']['list']['is_public']=0;
706
  }
707
 
708
  if($update){
@@ -725,17 +690,17 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
725
  function importpluginsave($id=false){
726
  $this->requireSecurity();
727
  $this->_resetGlobMsg();
728
- $modelConfig=WYSIJA::get('config','model');
729
- $importHelper=WYSIJA::get('import','helper');
730
- $pluginsImportable=$modelConfig->getValue('pluginsImportableEgg');
731
- $pluginsImported=array();
732
  foreach($_REQUEST['wysija']['import'] as $table_name =>$result){
733
- $connection_info=$importHelper->getPluginsInfo($table_name);
734
 
735
  if($result){
736
- $pluginsImported[]=$table_name;
737
- if(!$connection_info) $connection_info=$pluginsImportable[$table_name];
738
- $importHelper->import($table_name,$connection_info);
739
  sleep(2);
740
  $this->notice(sprintf(__('Import from plugin %1$s has been completed.',WYSIJA),"<strong>'".$connection_info['name']."'</strong>"));
741
  }else{
@@ -744,7 +709,7 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
744
 
745
  }
746
 
747
- $modelConfig->save(array('pluginsImportedEgg'=>$pluginsImported));
748
 
749
  $this->redirect('admin.php?page=wysija_subscribers&action=lists');
750
  }
@@ -754,14 +719,14 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
754
 
755
  $this->viewObj->title=__('Import subscribers from plugins',WYSIJA);
756
 
757
- $modelConfig=WYSIJA::get('config','model');
758
 
759
  $this->data=array();
760
- $this->data['plugins']=$modelConfig->getValue('pluginsImportableEgg');
761
- $importedOnes=$modelConfig->getValue('pluginsImportedEgg');
762
 
763
- if($importedOnes){
764
- foreach($importedOnes as $tablename){
765
  unset( $this->data['plugins'][$tablename]);
766
  }
767
  }
@@ -782,188 +747,85 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
782
  }
783
 
784
  function importmatch(){
785
- $this->js[]='wysija-validator';
786
- $helperNumbers=WYSIJA::get('numbers','helper');
787
- $bytes=$helperNumbers->get_max_file_upload();
 
 
 
788
 
789
  if(isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH']>$bytes['maxbytes']){
790
  if(isset($_FILES['importfile']['name']) && $_FILES['importfile']['name']){
791
- $filename=$_FILES['importfile']['name'];
792
  }else{
793
- $filename=__("which you have pasted",WYSIJA);
794
  }
795
 
796
- $this->error(sprintf(__('Upload error, file %1$s is too large! (MAX:%2$s)',WYSIJA),$filename,$bytes['maxmegas']),true);
797
  $this->redirect('admin.php?page=wysija_subscribers&action=import');
798
  return false;
799
  }
800
 
801
- $importfields=get_option("wysija_import_fields");
802
- if(!$importfields) {
803
- $importfields=array(
804
- "fname"=>"firstname",
805
- "firstname"=>"firstname",
806
- "prenom"=>"firstname",
807
- "nom"=>"lastname",
808
- "name"=>"lastname",
809
- "lastname"=>"lastname",
810
- "lname"=>"lastname",
811
- "ipaddress"=>"ip",
812
- "ip"=>"ip",
813
- "addresseip"=>"ip",
814
- );
815
- }
816
 
817
- WYSIJA::update_option('wysija_import_fields',$importfields);
818
 
819
- $this->data=array();
820
-
821
- //is it a text import or a file import?*/
822
- if($_POST['wysija']['import']['type']=="copy"){
823
- if(!isset($_POST['wysija']['user_list']['csv'])){
824
- /* memory limit has been reached*/
825
- $this->error(__("The list you've pasted is too big for the browser. <strong>Upload the file</strong> instead.",WYSIJA),true);
826
- $this->redirect('admin.php?page=wysija_subscribers&action=import');
827
- return false;
828
- }
829
- $csv=trim(stripslashes($_POST['wysija']['user_list']['csv']));
830
- }else{
831
- //dbg($_FILES);
832
- //move_uploaded_file($_importfile, $destination);
833
- $csv=trim(file_get_contents($_FILES['importfile']['tmp_name']));
834
- }
835
-
836
- $csv=str_replace(array("\r","\n\n","\n\t\t\n\t\n\t\n\t\n","\n\t\t\n\t\n\t\n","\xEF\xBB\xBF","\n\t\n","\n(+1)"),array("\n","\n","\n ;","\n","",";",""),$csv);
837
-
838
- //this might be gmail recipients rare paste ...
839
- if(!preg_match_all('/<([a-z0-9_\'&\.\-\+])+\@(([a-z0-9\-])+\.)+([a-z0-9]{2,10})+>/i',$csv,$matches)){
840
- //return false;
841
- }else{
842
-
843
- if(substr($csv, -1)!=",") $csv=trim($csv).",";
844
-
845
- $csv=str_replace(array(">, \r",">, \n",">,\r",">,\n",">, "),">,",$csv);
846
- $matchess=explode(">,",$csv);
847
- array_pop($matchess);
848
-
849
- if(count($matches[0])==count($matchess)){
850
- //this is gmail simple paste
851
- $csv=str_replace(array(">,","<"),array("\n",","),$csv);
852
-
853
- }
854
- $csv=trim($csv);
855
- }
856
 
 
857
 
858
- // try different set of enclosure and separator for the csv which can have different look depending on the data carried
859
- $fieldseparatorToTry=array(',',';',"\t");
860
- $fieldenclosurToTry=array('"','');
861
- $foundtheseparator=false;
862
- $foundtheenclosure='';
863
- $userHelper = WYSIJA::get("user","helper");
864
- foreach($fieldenclosurToTry as $enclosure){
865
- foreach($fieldseparatorToTry as $fsep){
866
- $csvArr = $this->_csvToArray($csv,4,$fsep,$enclosure);
 
 
 
867
 
868
- if((count($csvArr)>1 && count($csvArr[0])==count($csvArr[1]))){
869
- if(count($csvArr[0])>1 || $userHelper->validEmail(trim($csvArr[0][0])) || $userHelper->validEmail(trim($csvArr[1][0]))){
870
- $foundtheseparator=$fsep;
871
- $foundtheenclosure=$enclosure;
872
- break(2);
873
- }
874
 
875
- }
 
 
 
 
876
  }
877
- }
878
-
879
- //if it is not a csv file we come out
880
- if(!$foundtheseparator){
881
- $this->notice(str_replace(array('[link]','[/link]'),array('<a href="#">','</a>'),__("The data you are trying to import doesn't appear to be in the CSV format (Comma Separated Values). [link]Read more[/link].",WYSIJA)));
882
- $this->notice(__('The first line of a CSV file should be the column headers : "email","lastname","firstname".',WYSIJA));
883
- $this->notice(__('The second line of a CSV file should be a set of values : "joeeg@example.com","Average","Joe".',WYSIJA));
884
-
885
- $this->notice(__("The two first lines of the file you've uploaded are as follow:",WYSIJA));
886
-
887
- $arraylines=explode("\n",$csv);
888
-
889
- if(empty($arraylines[0])) $text=__("Line is empty",WYSIJA);
890
- else $text=$arraylines[0];
891
- $this->notice("<strong>".$text."</strong>");
892
-
893
- if(empty($arraylines[1])) $text=__("Line is empty",WYSIJA);
894
- else $text=$arraylines[1];
895
- $this->notice("<strong>".$text."</strong>");
896
-
897
- $this->redirect('admin.php?page=wysija_subscribers&action=import');
898
- return false;
899
- }
900
-
901
- $csvArrMax = $this->_csvToArray($csv,0,$foundtheseparator,$foundtheenclosure);
902
-
903
 
904
- $this->data['totalrows']=count($csvArrMax);
905
- end($csvArrMax);
906
- $this->data['lastrow']=current($csvArrMax);
907
- $csvArrMax=null;
908
-
909
- $upload_dir = wp_upload_dir();
910
-
911
- //try to make a wysija dir to save the import file
912
- $fileHelp=WYSIJA::get('file','helper');
913
- $resultdir=$fileHelp->makeDir('import');
914
- if(!$resultdir) {
915
- $this->redirect('admin.php?page=wysija_subscribers&action=import');
916
- return false;
917
  }
918
 
919
- $filename='import-'.time().'.csv';
920
- $handle=fopen($resultdir.$filename, 'w');
921
- fwrite($handle, $csv);
922
- fclose($handle);
923
-
924
- $foundEmail=0;
925
- $keyemail=array();
926
-
927
- foreach($csvArr as $key => $csvrow){
928
- foreach($csvrow as $keyfield =>$val){
929
- if($userHelper->validEmail(trim($val))){
930
- $foundEmail++;
931
 
932
- $keyemail[$keyfield]=$csvArr[0][$keyfield];
933
- }
 
 
 
 
 
 
 
 
 
 
 
 
934
  }
935
- }
936
-
937
- $this->data['errormatch'] = false;
938
- if((count($csvArr)<2) || ((count($csvArr) -1) > $foundEmail)){
939
- $this->error(sprintf(__('There might be a problem with the list you are trying to import. We have identified %1$s emails out of %2$s rows.',WYSIJA),$foundEmail,count($csvArr)),true);
940
- $this->data['errormatch'] = true;
941
- }
942
-
943
- $this->data['csv'] = $csvArr;
944
- $dataImport=array(
945
- 'csv'=>$filename,
946
- 'fsep'=>$foundtheseparator,
947
- 'fenc'=>$foundtheenclosure);
948
- $this->data['dataImport'] = base64_encode(serialize($dataImport));
949
- $this->data['keyemail'] = $keyemail;
950
-
951
- //test if the first row is data or not
952
- //test the email column
953
- foreach($this->data['keyemail'] as $k) $keyemail=$k;
954
-
955
- $userHelper = WYSIJA::get("user","helper");
956
-
957
-
958
- if($userHelper->validEmail($keyemail)){
959
- $this->data['firstrowisdata']=true;
960
- }else{
961
- $this->data['totalrows']--;
962
- }
963
-
964
- $this->viewObj->title=__('Import Subscribers',WYSIJA);
965
- $this->viewShow='importmatch';
966
 
 
967
  }
968
 
969
 
@@ -973,311 +835,78 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
973
  $this->requireSecurity();
974
  $this->_resetGlobMsg();
975
 
976
- //to avoid timeout when importing a lot of data apparently.
977
- global $wpdb;
978
- $wpdb->query('set session wait_timeout=600');
979
-
980
- //import the contacts
981
- //1-check that a list is selected and that there is a csv file pasted
982
- //2-save the list if necessary
983
- //3-save the contacts and record them for each list selected
984
-
985
  //we need to save a new list in that situation
986
- if(isset($_REQUEST['wysija']['list'])){
987
- $model=WYSIJA::get('list','model');
988
- $data=array();
989
- $data['is_enabled']=1;
990
- $data['name']=$_REQUEST['wysija']['list']['newlistname'];
991
- $_REQUEST['wysija']['user_list']['list'][]=$model->insert($data);
992
  }
993
 
 
994
  if(!isset($_REQUEST['wysija']['user_list']['list']) || !$_REQUEST['wysija']['user_list']['list']){
995
  $this->error(__('You need to select at least one list.',WYSIJA),true);
996
  return $this->importmatch();
997
  }
998
 
999
- //is it a new list or not
1000
- //try to make a wysija dir
1001
- $csvData=unserialize(base64_decode($_REQUEST['wysija']['dataImport']));
1002
- $csvfilename=$csvData['csv'];
1003
-
1004
- $fileHelp=WYSIJA::get('file','helper');
1005
- $resultFile=$fileHelp->get($csvfilename,'import');
1006
- if(!$resultFile){
1007
- $upload_dir = wp_upload_dir();
1008
- $this->error(sprintf(__('Cannot access CSV file. Verify access rights to this directory "%1$s"',WYSIJA),$upload_dir['basedir']),true);
1009
- return $this->import();
1010
- }
1011
 
1012
- //get the temp csv file
1013
- $csvdata=file_get_contents($resultFile);
1014
-
1015
- $csvArr = $this->_csvToArray($csvdata,0,$csvData['fsep'],$csvData['fenc']);
1016
- $datatoinsert=array();
1017
- $emailKey='';
1018
- foreach($_POST['wysija']['match'] as $key=> $val){
1019
- if($val!='nomatch'){
1020
- $datatoinsert[$key]=trim($val);
1021
- }
1022
- if($val == 'email'){
1023
- $emailKey= $key;
1024
- }
1025
- }
1026
- //dbg($datatoinsert);
1027
- if(!in_array('status',$datatoinsert)){
1028
- $datatoinsert['status']='status';
1029
- }
1030
-
1031
- $queryStart='INSERT IGNORE INTO [wysija]user (`'.implode('` ,`',$datatoinsert).'`,`created_at`) VALUES ';
1032
-
1033
- //$linescount=count($csvArr);
1034
- //detect the emails that are duplicate in the import file
1035
- $emailsCount=array();
1036
-
1037
- $header_row=$csvArr[0];
1038
- //we process the sql insertion 200 by 200 so that we are safe with the server
1039
- $csvChunks=array_chunk($csvArr, 200);
1040
- $csvArr=null;
1041
- $j=0;
1042
- $linescount=0;
1043
- $dataNumbers=array('invalid'=>array(),'inserted'=>0,'outof'=>0,'list_added'=>0,'list_user_ids'=>0,'list_list_ids'=>count($_REQUEST['wysija']['user_list']['list']),'emails_queued'=>0);
1044
- $ignored_row_count=0;
1045
- foreach($csvChunks as $keyChunk =>$arra){
1046
- foreach($arra as $keyline=> $emailline){
1047
- if(isset($emailline[$emailKey])){
1048
- if(isset($emailsCount[$emailline[$emailKey]])) {
1049
- $emailsCount[$emailline[$emailKey]]++;
1050
- //$arra[$keyline]
1051
- }else{
1052
- $emailsCount[$emailline[$emailKey]]=1;
1053
- }
1054
- }else{
1055
- //if the record doesn't have the attribute email then we just ignore it
1056
- $ignored_row_count++;
1057
- unset($arra[$keyline]);
1058
- }
1059
- }
1060
-
1061
- $result=$this->_importRows($queryStart,$arra,$j,$datatoinsert,$emailKey,$dataNumbers);
1062
-
1063
- if($result!==false) $j++;
1064
- else{
1065
- $try=0;
1066
- while($result===false && $try<3){
1067
- $result=$this->_importRows($queryStart,$arra,$j,$datatoinsert,$emailKey,$dataNumbers);
1068
- $try++;
1069
- }
1070
- if($result){
1071
- $j++;
1072
- }else{
1073
-
1074
- $this->error(__('There seems to be an error with the list you\'re trying to import.',WYSIJA),true);
1075
- $this->redirect('admin.php?page=wysija_subscribers&action=import');
1076
- return false;
1077
- }
1078
- }
1079
- $linescount=$linescount+$result;
1080
- }
1081
-
1082
- if(!isset($_POST['firstrowisdata'])) {
1083
- //save the importing fields to be able to match them the next time
1084
- $importfields=get_option('wysija_import_fields');
1085
- foreach($_POST['wysija']['match'] as $key=> $val){
1086
- if($val!='nomatch') {
1087
- $importfields[$header_row[$key]]=$val;
1088
- }
1089
- }
1090
- WYSIJA::update_option('wysija_import_fields',$importfields);
1091
  }
1092
 
1093
  //get a list of list name
1094
- $model=WYSIJA::get('list','model');
1095
- $results=$model->get(array('name'),array('list_id'=>$_REQUEST['wysija']['user_list']['list']));
1096
-
1097
- $listnames=array();
1098
- foreach($results as $k =>$v) $listnames[]=$v['name'];
1099
-
1100
- $helper_user=WYSIJA::get('user','helper');
1101
- $helper_user->refreshUsers();
1102
-
1103
- foreach($emailsCount as $emailkeycount =>$countemailfile){
1104
- if($countemailfile==1) unset($emailsCount[$emailkeycount]);
1105
- }
1106
-
1107
- if($linescount<0) $linescount=0;
1108
-
1109
- $dataNumbers['ignored']=($dataNumbers['outof']-$dataNumbers['inserted']);
1110
- $dataNumbers['ignored_list']=(($dataNumbers['list_user_ids']*$dataNumbers['list_list_ids'])-$dataNumbers['list_added']);
1111
- // $this->notice(sprintf(__('%1$s subscribers have been added to database. (%2$s were ignored)',WYSIJA),$dataNumbers['inserted'],$dataNumbers['ignored']));
1112
-
1113
- $ignored_row_count;//this contain some ignored row because the email attribute was not detected. I say there should be a message for those
1114
-
1115
- $this->notice(sprintf(__('%1$s subscribers added to %2$s.', WYSIJA),
1116
- $dataNumbers['list_user_ids'],
1117
- '"'.implode('", "',$listnames).'"'
1118
- ));
1119
-
1120
- if(count($emailsCount)>0){
1121
- $listemails='';
1122
- $m=0;
1123
- foreach($emailsCount as $emailkeyalready => $occurences){
1124
- if($m>0)$listemails.=', ';
1125
- $listemails.= $emailkeyalready.' ('.$occurences.')';
1126
- $m++;
1127
  }
1128
  //$emailsalreadyinserted=array_keys($emailsCount);
1129
- $this->notice(sprintf(__('%1$s emails appear more than once in your file : %2$s.',WYSIJA),count($emailsCount),$listemails),0);
1130
  }
1131
 
1132
- if(count($dataNumbers['invalid'])>0){
1133
- $this->notice(sprintf(__('%1$s emails are not valid : %2$s.',WYSIJA),count($dataNumbers['invalid']),implode(', ',$dataNumbers['invalid'])),0);
 
1134
  }
1135
 
1136
  $this->redirect();
1137
  }
1138
 
1139
- function _importRows($query,$csvArr,$count,$datatoinsert,$emailKey,&$dataNumbers){
1140
- $allEmails=array();
1141
- $time=time();
1142
- $linescount=count($csvArr);
1143
- $nbfields=count($datatoinsert);
1144
-
1145
- foreach($csvArr as $k=> $line){
1146
- if(!(count($line)>=(count($datatoinsert)-1))){
1147
-
1148
- unset($csvArr[$k]);
1149
- $linescount--;
1150
- }
1151
- }
1152
-
1153
- $outof=0;
1154
- $j=1;
1155
- $helperUser=WYSIJA::get('user','helper');
1156
- global $wpdb;
1157
- foreach($csvArr as $kline=> $line){
1158
- //dbg($csvArr,0);
1159
- if(!isset($_POST['firstrowisdata']) && $j==1 && $count==0) {
1160
- $j++;
1161
- continue;
1162
- }
1163
- $i=1;
1164
- $values='';
1165
- if(isset($datatoinsert['status'])) $line['status']=1;
1166
- foreach($line as $kl => &$vl){
1167
- if(isset($datatoinsert[$kl])){
1168
- if($emailKey===$kl){
1169
- $vl=trim($vl);
1170
- if($helperUser->validEmail($vl)){
1171
- $allEmails[]=$vl;
1172
- $outof++;
1173
- }else{
1174
- $dataNumbers['invalid'][]=$vl;
1175
-
1176
- unset($csvArr[$kline]);
1177
- $linescount--;
1178
- continue 2;
1179
- }
1180
- }
1181
- $values.="'". mysql_real_escape_string($vl,$wpdb->dbh)."'";
1182
- if($nbfields>$i) $values.=',';
1183
- else $values.=','.$time;
1184
- $i++;
1185
- }
1186
- }
1187
-
1188
- $query.=" ($values) ";
1189
- if($linescount>$j) $query.=',';
1190
- $j++;
1191
-
1192
- }
1193
-
1194
- //replace query to import the subscribers
1195
- $modelWysija=new WYSIJA_model();
1196
- $resultqry=$modelWysija->query($query);
1197
-
1198
- //$outof=$linescount;
1199
- global $wpdb;
1200
-
1201
- $linescount=$wpdb->rows_affected;
1202
- $dataNumbers['inserted']+=$wpdb->rows_affected;
1203
- $dataNumbers['outof']+=$outof;
1204
-
1205
- if($resultqry===false) {
1206
- $this->error(__('Error when inserting emails.',WYSIJA),true);
1207
- return false;
1208
- }
1209
-
1210
-
1211
- //select query to get all of there ids
1212
- $user_ids=$this->modelObj->get(array('user_id'),array('email'=>$allEmails));
1213
- $wpdb->rows_affected=0;
1214
-
1215
- //insert query per list
1216
- $query='INSERT IGNORE INTO [wysija]user_list (`list_id` ,`user_id`,`sub_date`) VALUES ';
1217
- $time_now=time();
1218
- foreach($_REQUEST['wysija']['user_list']['list'] as $keyl=> $list_id){
1219
-
1220
- //for each list pre selected go through that process
1221
- foreach($user_ids as $key=> $userid){
1222
-
1223
- //inserting each user id to this list
1224
- $query.="($list_id,".$userid['user_id'].', '.$time_now.')';
1225
-
1226
- //if this is not the last row we put a comma for the next row
1227
- if(count($user_ids)>($key+1)){
1228
- $query.=',';
1229
- }
1230
- }
1231
-
1232
- //if this is not the last row we put a comma for the next row
1233
- if(count($_REQUEST['wysija']['user_list']['list'])>($keyl+1)){
1234
- $query.=',';
1235
- }
1236
- }
1237
- $resultqry2=$modelWysija->query($query);
1238
-
1239
- $dataNumbers['list_added']+=$wpdb->rows_affected;
1240
- $dataNumbers['list_user_ids']+=count($user_ids);
1241
-
1242
- // take care of active follow ups retro-activity
1243
- $helper_email=WYSIJA::get('email','helper');
1244
- $follow_ups_per_list=$helper_email->get_active_follow_ups(array('email_id','params'),true);
1245
-
1246
- if(!empty($follow_ups_per_list)){
1247
- foreach($_REQUEST['wysija']['user_list']['list'] as $list_id){
1248
- //checking if this list has a list of follow ups
1249
- if(isset($follow_ups_per_list[$list_id])){
1250
-
1251
- //for each follow up of that list we queu an email
1252
- foreach($follow_ups_per_list[$list_id] as $key_queue=>$follow_up){
1253
- //insert query per active followup
1254
- $query_queue='INSERT IGNORE INTO [wysija]queue (`email_id` ,`user_id`,`send_at`) ';
1255
- $query_queue.=' SELECT '.$follow_up['email_id'].' , B.user_id , '.($time_now+$follow_up['delay']);
1256
- $query_queue.=' FROM [wysija]user_list as B';
1257
- $query_queue.=' WHERE B.list_id='.(int)$list_id.' AND sub_date='.$time_now;
1258
-
1259
- $resultqry3=$modelWysija->query($query_queue);
1260
-
1261
- $dataNumbers['emails_queued']+=$wpdb->rows_affected;
1262
- }
1263
- }
1264
- }
1265
- }
1266
-
1267
- if($resultqry2===false) {
1268
- $this->error(__('Error when inserting list.',WYSIJA),true);
1269
- return false;
1270
- }
1271
- if($resultqry==0) return '0';
1272
- return $linescount;
1273
- }
1274
 
1275
  function export(){
1276
  $this->js[]='wysija-validator';
1277
 
1278
  $this->viewObj->title=__('Export Subscribers',WYSIJA);
1279
  $this->data=array();
1280
- $this->data['lists']=$this->_getLists(false);
 
 
 
 
 
 
 
 
 
 
1281
  $this->viewShow='export';
1282
  }
1283
 
@@ -1292,13 +921,33 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
1292
  }
1293
 
1294
  function exportlist(){
1295
- $number=count($_REQUEST['wysija']['user']['user_id']);
1296
- $this->viewObj->title=sprintf(__('Exporting %1$s subscribers',WYSIJA),$number);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1297
  $this->data=array();
 
1298
  $this->data['subscribers'] = $_REQUEST['wysija']['user']['user_id'];
1299
  $this->data['user'] = $_REQUEST['wysija']['user'];//for batch-selecting
 
 
 
1300
  $this->data['filter'] = $_REQUEST['wysija']['filter'];//for batch-selecting
1301
- $this->viewShow='export';
1302
  }
1303
 
1304
 
@@ -1325,146 +974,34 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
1325
 
1326
  // make sure the total count of subscribers is updated
1327
  $helper_user->refreshUsers();
1328
- $this->redirect();
1329
  }
1330
 
1331
- /**
1332
- * function generating an export file based on an array of user_ids
1333
- */
1334
  /**
1335
  * function generating an export file based on an array of user_ids
1336
  */
1337
  function export_get(){
1338
  @ini_set('max_execution_time',0);
1339
 
1340
- //prepare the columns that need to be exported
1341
- $model=WYSIJA::get('user_field','model');
1342
- $fields=$model->getFields();
1343
- $namefields=array();
1344
- foreach($_POST['wysija']['export']['fields'] as $keyfield){
1345
- $namefields[]=$fields[$keyfield];
1346
- }
1347
-
1348
- //create the export file step by step
1349
- $file_header=implode(';',$namefields)."\n";
1350
- //generate temp file
1351
- $fileHelp=WYSIJA::get('file','helper');
1352
- $resultFile=$fileHelp->temp($file_header,'export','.csv');
1353
-
1354
- //open the created file in append mode
1355
- $handle=fopen($resultFile['path'], 'a');
1356
-
1357
- //get a list of user_ids to export
1358
- if(isset($_POST['wysija']['export']['user_ids'])
1359
- && $_POST['wysija']['export']['user_ids']
1360
- && empty($this->_batch_select)){
1361
- $userids=unserialize(base64_decode($_POST['wysija']['export']['user_ids']));
1362
- $this->write_data_to_export_file($handle,$userids);
1363
- $useridsrows = count($userids);
1364
- $userids = null;// free memory
1365
- }else{
1366
- //based on filters get a list of user_ids
1367
- $userids = array();
1368
- $useridsrows = 0;
1369
- if(!empty($this->_batch_select)){ // batch select and export
1370
- $useridsrows = $this->_batch_select['count'];
1371
- $qry = $this->_batch_select['original_query'];
1372
- }elseif(isset($_POST['wysija']['export']['filter']['list']) && $_POST['wysija']['export']['filter']['list']){ // select list(s) and export
1373
- $where='';
1374
- if(!is_array($_POST['wysija']['export']['filter']['list']))
1375
- $_POST['wysija']['export']['filter']['list'] = array($_POST['wysija']['export']['filter']['list']);
1376
- if(isset($_POST['wysija']['export']['filter']['confirmed'])){
1377
- $where=' AND B.status>0 ';
1378
- }
1379
- $from = ' `[wysija]user_list` as A
1380
- JOIN `[wysija]user` as B on A.user_id=B.user_id';
1381
- $where = ' A.list_id IN ('.implode(',',$_POST['wysija']['export']['filter']['list']).')'.$where;
1382
- $qry='SELECT B.user_id FROM '.$from . ' WHERE ' .$where;
1383
- $qry_count='SELECT COUNT(DISTINCT A.user_id) FROM '.$from . ' WHERE ' .$where;
1384
- }else{ // export all list
1385
- $from = '`[wysija]user` as A';
1386
- $where = '1';
1387
- if(isset($_POST['wysija']['export']['filter']['confirmed'])){
1388
- $where ='A.status>0';
1389
- }
1390
- $qry='SELECT A.user_id FROM '. $from . ' WHERE '. $where;
1391
- $qry_count='SELECT COUNT(DISTINCT A.user_id) FROM '. $from . ' WHERE '. $where . ' ';
1392
- }
1393
- $user_ids_chunks = array(); // chunk rows into separated batchs, limit by $this->_export_batch
1394
- $qry_batchs = array(); // store all batched queries
1395
- if(empty($useridsrows)){
1396
- $useridsrows_result = $this->modelObj->getResults($qry_count, ARRAY_N);
1397
- $useridsrows = (int)$useridsrows_result[0][0];
1398
- }
1399
-
1400
- if($useridsrows <= $this->_export_batch){
1401
- $useridsdb=$this->modelObj->getResults($qry,ARRAY_N);
1402
- foreach($useridsdb as $uarr){
1403
- $userids[]=$uarr[0];
1404
- }
1405
- $this->write_data_to_export_file($handle,$userids);
1406
- $userids = null;// free memory
1407
- }
1408
- else{
1409
- $pages = ceil($useridsrows / $this->_export_batch);//pagination
1410
- for ($i = 0; $i < $pages; $i++) {
1411
- $qrybatch = $qry. ' ORDER BY user_id ASC LIMIT '.($i*$this->_export_batch) . ',' . $this->_export_batch;
1412
- $useridsdb=$this->modelObj->getResults($qrybatch,ARRAY_N);
1413
- foreach($useridsdb as $uarr){
1414
- $userids[]=$uarr[0];
1415
- }
1416
- $this->write_data_to_export_file($handle,$userids);
1417
- unset($userids);// free memory
1418
- unset($useridsdb);//free memory
1419
- }
1420
- }
1421
- }
1422
 
 
1423
 
 
1424
 
1425
-
1426
-
1427
- fclose($handle);
1428
-
1429
- $url=get_bloginfo('wpurl').'/wp-admin/admin.php?page=wysija_subscribers&action=exportedFileGet&file='.base64_encode($resultFile['path']);
1430
  $this->notice(str_replace(
1431
  array('[link]','[/link]'),
1432
  array('<a href="'.$url.'" target="_blank" class="exported-file" >','</a>'),
1433
- sprintf(__('%1$s subscribers were exported. Get the exported file [link]here[/link].',WYSIJA),$useridsrows)));
1434
 
1435
  if(isset($_REQUEST['camp_id'])){
1436
  $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id='.$_REQUEST['camp_id']);
1437
  }else{
1438
- $this->redirect();
1439
- }
1440
- }
1441
-
1442
- function write_data_to_export_file(&$handle, $userids){
1443
- $user_ids_chunks=array_chunk($userids, 200);
1444
- $userids = null;// free memory
1445
-
1446
-
1447
- $modelUser=WYSIJA::get('user','model');
1448
- foreach($user_ids_chunks as $userid_chunk){
1449
- //get the full data for that specific chunk of ids
1450
- $data=$modelUser->get($_POST['wysija']['export']['fields'],array('user_id'=>$userid_chunk));
1451
-
1452
- if(in_array('created_at', $_POST['wysija']['export']['fields'])){
1453
- foreach($data as $key=>$row){
1454
- $data[$key]['created_at']=date_i18n(get_option('date_format'),$row['created_at']);
1455
- }
1456
- }
1457
-
1458
- //append content to the file
1459
- foreach($data as $row){
1460
- fwrite($handle, implode(';',$row)."\n");
1461
- }
1462
  }
1463
-
1464
-
1465
  }
1466
 
1467
-
1468
  function exportedFileGet(){
1469
  if(isset($_REQUEST['file'])){
1470
  $helper=WYSIJA::get('file','helper');
@@ -1472,57 +1009,12 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
1472
  }
1473
  }
1474
 
1475
- /**
1476
- *
1477
- * @param type $input
1478
- * @param type $rowstoread
1479
- * @param type $delimiter
1480
- * @param type $enclosure
1481
- * @param type $linedelimiter
1482
- * @return array
1483
- */
1484
- function _csvToArray($input,$rowstoread=0 , $delimiter=',',$enclosure='',$linedelimiter="\n"){
1485
- $header = null;
1486
- $data = array();
1487
-
1488
- $csvData = explode($linedelimiter,$input);
1489
- $i=1;
1490
- foreach($csvData as $csvLine){
1491
- if($rowstoread!=0 && $i>$rowstoread) return $data;
1492
-
1493
- /* str_getcsv only exists in php5 ...*/
1494
- if(!function_exists("str_getcsv")){
1495
- $data[]= $this->csv_explode($csvLine, $delimiter,$enclosure);
1496
- }else{
1497
- $data[] = str_getcsv($csvLine, $delimiter,$enclosure);
1498
- }
1499
 
1500
- $i++;
1501
- }
1502
 
1503
- return $data;
 
1504
  }
1505
 
1506
- function csv_explode($str,$delim, $enclose, $preserve=false){
1507
- $resArr = array();
1508
- $n = 0;
1509
- if(empty($enclose)){
1510
- $resArr = explode($delim, $str);
1511
- }else{
1512
- $expEncArr = explode($enclose, $str);
1513
- foreach($expEncArr as $EncItem){
1514
- if($n++%2){
1515
- array_push($resArr, array_pop($resArr) . ($preserve?$enclose:'') . $EncItem.($preserve?$enclose:''));
1516
- }else{
1517
- $expDelArr = explode($delim, $EncItem);
1518
- array_push($resArr, array_pop($resArr) . array_shift($expDelArr));
1519
- $resArr = array_merge($resArr, $expDelArr);
1520
- }
1521
- }
1522
- }
1523
-
1524
- return $resArr;
1525
- }
1526
 
1527
 
1528
 
@@ -1547,40 +1039,13 @@ class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
1547
 
1548
  function _getForm($id=false){
1549
  if($id){
1550
- $modelList=WYSIJA::get('list','model');
1551
 
1552
- return $modelList->getLists($id);
1553
  }else{
1554
  $array=array('name'=>'','list_id'=>'','description'=>'','is_public'=>true,'is_enabled'=>true);
1555
  return $array;
1556
  }
1557
 
1558
  }
1559
-
1560
- function cleanQueueFromAlreadySent(){
1561
- $model_queue=WYSIJA::get('queue','model');
1562
- $model_email=WYSIJA::get('email','model');
1563
- $model_email->setConditions(array('type'=>2));
1564
- $autonewsletter=$model_email->getRows(array('email_id','params'));
1565
- $rows_affected=0;
1566
- foreach ($autonewsletter as $data){
1567
- $model_email->getParams($data);
1568
- global $wpdb;
1569
- if(isset($data['params']['autonl']['event']) && $data['params']['autonl']['event']=='subs-2-nl'){
1570
- $query_queue='DELETE FROM [wysija]queue';
1571
- $query_queue.=' WHERE email_id='.(int)$data['email_id'].' AND user_id ';
1572
- $query_queue.='IN (SELECT B.user_id FROM [wysija]email_user_stat as B WHERE B.email_id='.(int)$data['email_id'].')';
1573
- $result=$model_queue->query($query_queue);
1574
- $rows_affected+=$wpdb->rows_affected;
1575
- }
1576
-
1577
- }
1578
-
1579
- if($result){
1580
-
1581
- echo 'query successfully run<br/>';
1582
- echo $rows_affected.' rows in the queue table have been deleted';
1583
- }
1584
- exit;
1585
- }
1586
  }
1
  <?php
2
  defined('WYSIJA') or die('Restricted access');
3
  class WYSIJA_control_back_subscribers extends WYSIJA_control_back{
4
+ var $model='user';
5
+ var $view='subscribers';
6
+ var $list_columns=array('user_id','firstname', 'lastname','email','created_at');
7
  var $searchable=array('email','firstname', 'lastname');
 
8
  var $_separators = array(',', ';'); // csv separator; comma is for standard csv, semi-colon is good for Excel
9
  var $_default_separator = ';';
10
 
11
+ /**
12
+ * Inactive users = users who never opened or clicked
13
+ * @todo: disabled on 2.6. Once it's enabled, please double check in term of "inactive users".
14
+ * OR - users who never opened or clicked
15
+ * OR - users who never opened or clicked AND received at least 1 newsletter.
16
+ * @var boolean
17
+ */
18
+ var $_filter_by_inactive_users = true;
19
 
20
+ function WYSIJA_control_back_subscribers(){
21
+ WYSIJA_control_back::WYSIJA_control_back();
22
+ if ($this->_filter_by_inactive_users) {
23
+ if (
24
+ // default display
25
+ empty($_REQUEST['action'])
26
+ // bulk action
27
+ || !empty($_REQUEST['doaction']) && trim(strtolower($_REQUEST['doaction'])) === 'apply'
28
+ ) {
29
+ $this->modelObj->prepare_inactive_users_table();
30
+ }
31
+ }
32
  }
33
 
34
  function save(){
108
  $notEqual=array_merge($core_listids, $arrayLists);
109
 
110
  //unsubscribe from lists which exist in the old list but does not exist in the new list
111
+ $unsubsribe_list = array_diff(array_keys($oldlistids), $arrayLists);
112
  if(!empty($unsubsribe_list))
113
  {
114
  $modelUL->reset();
115
  $modelUL->update(array('unsub_date'=>time()),array('user_id'=>$id,'list_id'=>$unsubsribe_list));
116
  }
117
  $modelUL->reset();
118
+
119
+ /*
120
+ Custom Fields.
121
+ */
122
+ if (isset($_POST['wysija']['field'])) {
123
+ WJ_FieldHandler::handle_all(
124
+ $_POST['wysija']['field'], $id
125
+ );
126
+ }
127
+
128
+
129
  }else{
130
  //instead of going through a classic save we should save through the helper
131
  $data=$_REQUEST['wysija'];
144
  return true;
145
  }
146
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
147
 
148
+ /**
149
+ * Get selected lists
150
+ * @return array
151
+ */
152
+ protected function get_selected_lists() {
153
+ $result = array();
154
+ if (isset($_REQUEST['wysija']['filter']['filter_list'])) {
155
+ $result[] = $_REQUEST['wysija']['filter']['filter_list'];
156
+ } elseif (!empty($_REQUEST['filter-list'])) {
157
+ $lists = explode(',', trim($_REQUEST['filter-list']));// currently, only single list is allowed.
158
+ if (!empty($lists)) {
159
+ $result = array_merge ($result, $lists);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
160
  }
 
161
  }
162
+ return $result;
163
+ }
164
 
165
+ function defaultDisplay(){
166
+ $this->viewShow=$this->action='main';
167
+ $this->js[]='wysija-admin-list';
168
+ $this->viewObj->msgPerPage = __('Subscribers per page:',WYSIJA);
169
+
170
+ $this->jsTrans['selecmiss'] = __('Select at least 1 subscriber!',WYSIJA);
171
+
172
+ // get the total count for subscribed, unsubscribed and unconfirmed users
173
+ $select = array( 'COUNT(`user_id`) AS users' , 'status' , 'MAX(`created_at`) AS `max_create_at`');
174
+ $count_group_by = 'status';
175
+ $count_by_status = $this->modelObj->get_subscribers( $select , array() , $count_group_by );
176
+ if ($this->_filter_by_inactive_users) {
177
+ $inactive_users = $this->modelObj->count_inactive_users();
178
+ if ($inactive_users) {
179
+ array_unshift($count_by_status, array(
180
+ 'users' => $inactive_users['count'],
181
+ 'status' => -99,//-99 = inactive
182
+ 'max_create_at' => $inactive_users['max_created_at']
183
+ ));
184
+ }
185
+ }
186
+
187
+
188
+ $counts = $this->modelObj->structure_user_status_count_array($count_by_status);
189
+ $arr_max_create_at = $this->modelObj->get_max_create($count_by_status);
190
+
191
+ // count the rows based on the filters
192
+ $filters = $this->modelObj->detect_filters();
193
+
194
+ $select = array( 'COUNT(DISTINCT([wysija]user.user_id)) as total_users', 'MAX([wysija]user.created_at) as max_create_at');
195
+ $count_rows = $this->modelObj->get_subscribers( $select, $filters);
196
+
197
+ // without filter we already have the total number of subscribers
198
+ $this->data['max_create_at'] = null; //max value of create_at field of current list of users
199
+ if(!empty($filters)){
200
+ // used for pagination
201
+ $this->modelObj->countRows = $count_rows['total_users'];
202
+ // used for
203
+ $this->data['max_create_at'] = $count_rows['max_create_at'];
204
+ }else{
205
+ $this->data['max_create_at'] = !empty($arr_max_create_at) ? max($arr_max_create_at) : 0;
206
+ $this->modelObj->countRows=$counts['all'];
207
  }
208
 
209
+ $select = array(
210
+ '[wysija]user.firstname',
211
+ '[wysija]user.lastname',
212
+ '[wysija]user.status',
213
+ '[wysija]user.email',
214
+ '[wysija]user.created_at',
215
+ '[wysija]user.last_opened',
216
+ '[wysija]user.last_clicked',
217
+ '[wysija]user_list.user_id'
218
+ );
219
 
220
+ $this->data['subscribers'] = $this->modelObj->get_subscribers($select , $filters, '', false, true);
 
221
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
222
  $this->data['current_counts'] = $this->modelObj->countRows;
223
  $this->data['show_batch_select'] = ($this->modelObj->limit >= $this->modelObj->countRows) ? false : true;
224
+ $this->data['selected_lists'] = $this->get_selected_lists();
225
  $this->modelObj->reset();
226
 
 
 
 
 
 
227
 
228
+ // make the data object for the listing view
229
+ $model_list = WYSIJA::get('list','model');
230
+ $lists_db = $model_list->getLists();
231
 
 
 
 
232
  $lists=array();
233
+
234
+ foreach($lists_db as $listobj){
235
+ $lists[$listobj['list_id']]=$listobj;
 
 
236
  }
 
237
 
238
  $user_ids=array();
239
  foreach($this->data['subscribers'] as $subscriber){
240
  $user_ids[]=$subscriber['user_id'];
241
  }
242
 
243
+ // 3 - user_list request
244
  if($user_ids){
245
  $modeluList=WYSIJA::get('user_list','model');
246
  $userlists=$modeluList->get(array('list_id','user_id','unsub_date'),array('user_id'=>$user_ids));
249
  $this->data['lists']=$lists;
250
  $this->data['counts']=array_reverse($counts);
251
 
252
+ // regrouping all the data in the same array
 
 
253
  foreach($this->data['subscribers'] as $keysus=>$subscriber){
254
+ // default key while we don't have the data
255
  //TODO add data for stats about emails opened clicked etc
256
  $this->data['subscribers'][$keysus]['emails']=0;
257
  $this->data['subscribers'][$keysus]['opened']=0;
274
  }else{
275
  $this->data['subscribers'][$keysus]['lists'].=', '.$this->data['lists'][$userlist['list_id']]['name'];
276
  }
 
277
  }
 
278
  }
279
  }
280
  }
290
  $this->messages['insert'][false]=__('Subscriber has not been saved.',WYSIJA);
291
  $this->messages['update'][true]=__('Subscriber has been modified. [link]Edit again[/link].',WYSIJA);
292
  $this->messages['update'][false]=__('Subscriber has not been modified.',WYSIJA);
293
+ $this->cleanup_form();
294
  parent::WYSIJA_control_back();
295
 
296
  //we change the default model of the controller based on the action
310
  if(!isset($_REQUEST['action']) || !$_REQUEST['action']) {
311
  $this->defaultDisplay();
312
  $this->checkTotalSubscribers();
313
+ } else {
314
+ $this->_tryAction($_REQUEST['action']);
315
+ }
316
+ if ( isset($_REQUEST['method']) && !empty($_REQUEST['method'])){
317
+ $this->_tryAction($_REQUEST['method']);
318
  }
319
+ }
320
 
321
+ /**
322
+ * We are using the same form for different purposes:
323
+ * - Bulk actions
324
+ * - Filter by list
325
+ * We need to remove all un-necessary values from interface
326
+ */
327
+ protected function cleanup_form() {
328
+ if (!empty($_REQUEST['doaction'])) {
329
+ $action_type = strtolower(trim($_REQUEST['doaction']));
330
+ switch ($action_type)
331
+ {
332
+ // Filter by list
333
+ case 'filter':
334
+ if (!empty($_REQUEST['wysija']['user']))
335
+ unset($_REQUEST['wysija']['user']);
336
+ if (!empty($_REQUEST['action']))
337
+ unset($_REQUEST['action']);
338
+ break;
339
+ // Bulk action. Nothing to do, because we will invoke _tryAction() directly right after this step
340
+ case 'apply':
341
+ default:
342
+ break;
343
+ }
344
+ }
345
  }
346
 
347
  /**
363
  $this->notice(sprintf(__('%1$s subscribers have been added to "%2$s".',WYSIJA),$this->_affected_rows,$result['name']));
364
  else
365
  $this->notice(sprintf(__('%1$s subscriber have been added to "%2$s".',WYSIJA),$this->_affected_rows,$result['name']));
366
+ $this->redirect_after_bulk_action();
367
  }
368
 
369
  /**
370
+ * Moves subscriber to another list.
371
+ *
372
+ * @param array $data List id to move, $data = array('listid' => 1);
373
  */
374
+ function movetolist($data) {
375
+ $helper_user = WYSIJA::get('user', 'helper');
 
 
 
 
376
 
377
+ if (!empty($this->_batch_select)) {
378
+ $helper_user->moveToList($data['listid'], $this->_batch_select, true);
379
+ } elseif (isset($_POST['wysija']['user']['user_id'])) {
380
+ $helper_user->moveToList($data['listid'], $_POST['wysija']['user']['user_id']);
381
+ }
382
 
383
+ $model_list = WYSIJA::get('list','model');
384
+ $result = $model_list->getOne(array('name'), array('list_id' => $data['listid']));
385
+
386
+ if ($this->_affected_rows > 1) {
387
+ $this->notice(sprintf(__('%1$s subscribers have been moved to "%2$s".',WYSIJA), $this->_affected_rows, $result['name']));
388
+ } else {
389
+ $this->notice(sprintf(__('%1$s subscriber have been moved to "%2$s".',WYSIJA), $this->_affected_rows, $result['name']));
390
+ }
391
+
392
+ $this->redirect_after_bulk_action();
393
  }
394
 
395
+ /**
396
+ * After performing a bulk action, let's keep the current list filter
397
+ */
398
+ protected function redirect_after_bulk_action() {
399
+ $filter_list = !empty($_REQUEST['wysija']['filter']['filter_list']) ? $_REQUEST['wysija']['filter']['filter_list'] : 0;
400
+ if (empty($filter_list)) {// view all lists
401
+ $this->redirect('admin.php?page=wysija_subscribers');
402
+ } elseif (is_numeric($filter_list)) {
403
+ $this->redirect('admin.php?page=wysija_subscribers&filter-list='.$filter_list);
404
+ } else {// subscribers in no list
405
+ $this->redirect('admin.php?page=wysija_subscribers&filter-list=orphaned');
406
+ }
407
+ }
408
+
409
  /**
410
  * Bulk action remove subscribers from all existing lists
411
  * @param type $data = array('list_id'=>?)
418
  $helpU->removeFromLists(array(),$_POST['wysija']['user']['user_id']);
419
 
420
  if($this->_affected_rows > 1)
421
+ $this->notice(sprintf(__('%1$s subscribers have been removed from all existing lists.',WYSIJA),$this->_affected_rows));
422
  else
423
+ $this->notice(sprintf(__('%1$s subscriber have been removed from all existing lists.',WYSIJA),$this->_affected_rows));
424
+ $this->redirect_after_bulk_action();
425
  }
426
 
427
  /**
441
  $this->notice(sprintf(__('%1$s subscribers have been removed from "%2$s".',WYSIJA),$this->_affected_rows, $result['name']));
442
  else
443
  $this->notice(sprintf(__('%1$s subscriber have been removed from "%2$s".',WYSIJA),$this->_affected_rows, $result['name']));
444
+
445
+ $this->redirect_after_bulk_action();
446
  }
447
 
448
  /**
459
  $this->notice(sprintf(__('%1$s subscribers have been confirmed.',WYSIJA),$this->_affected_rows));
460
  else
461
  $this->notice(sprintf(__('%1$s subscriber have been confirmed.',WYSIJA),$this->_affected_rows));
462
+ $this->redirect_after_bulk_action();
463
  }
464
 
465
  /**
564
 
565
  function edit($id=false){
566
 
567
+ if (empty($_REQUEST['id']) && empty($id)){
568
+ $this->error('Cannot edit element primary key is missing : '. get_class($this));
569
+ return;
570
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
571
 
572
+ if(!$id) $id=$_REQUEST['id'];
 
 
 
 
 
 
573
 
574
+ // get detail info of current user
575
+ $this->data['user']=$this->modelObj->getDetails(array('user_id'=>$id));
576
+ if(!$this->data['user']){
577
+ $this->notice(__('No subscriber found, most probably because he was deleted.',WYSIJA));
578
+ return $this->redirect();
579
+ }
580
 
581
+ // get list info
582
+ $model_list=WYSIJA::get('list','model');
583
+ $model_list->limitON=false;
584
+ $model_list->orderBy('is_enabled','DESC');
585
+ $this->data['list']=$model_list->get(false,array('greater'=>array('is_enabled'=>'-1') ));
586
+ $this->viewObj->title=__('Edit',WYSIJA).' '.$this->data['user']['details']['email'];
587
 
588
+ // execute hooks
589
+ $hook_params = array(
590
+ 'user_id' => $id
591
+ );
592
+ $this->data['hooks']['hook_subscriber_left'] = apply_filters('hook_subscriber_left',WYSIJA_module::execute_hook('hook_subscriber_left', $hook_params), $hook_params);
593
+ $this->data['hooks']['hook_subscriber_right'] = apply_filters('hook_subscriber_right',WYSIJA_module::execute_hook('hook_subscriber_right', $hook_params), $hook_params);
594
+ $this->data['hooks']['hook_subscriber_bottom'] = apply_filters('hook_subscriber_bottom',WYSIJA_module::execute_hook('hook_subscriber_bottom', $hook_params), $hook_params);
595
 
 
 
 
596
 
597
+ // prepare js, for rendering
598
+ $this->js[]='wysija-validator';
599
  }
600
 
601
  function deletelist(){
607
  * 2 delete the list campaigns references
608
  * 4 delete the list
609
  */
610
+ $model_list=WYSIJA::get('list','model');
611
+ $data=$model_list->getOne(array('name','namekey','welcome_mail_id'),array('list_id'=>(int)$_REQUEST['id']));
612
 
613
  if($data && isset($data['namekey']) && ($data['namekey']!='users')){
614
 
615
  //there is no welcome email per list that's old stuff
616
+ $model_user_list=WYSIJA::get('user_list','model');
617
+ $model_user_list->delete(array('list_id'=>$_REQUEST['id']));
 
 
 
618
 
619
+ $model_campaign_list=WYSIJA::get('campaign_list','model');
620
+ $model_campaign_list->delete(array('list_id'=>$_REQUEST['id']));
621
 
622
+ $model_list->reset();
623
+ $model_list->delete(array('list_id'=>$_REQUEST['id']));
624
 
625
  $this->notice(sprintf(__('List "%1$s" has been deleted.',WYSIJA),$data['name']));
626
  }else{
635
  function synchlist(){
636
  $this->requireSecurity();
637
 
638
+ $helper_user=WYSIJA::get('user','helper');
639
+ $helper_user->synchList($_REQUEST['id']);
640
 
641
  $this->redirect('admin.php?page=wysija_subscribers&action=lists');
642
  }
647
  global $current_user;
648
 
649
  if(is_multisite() && is_super_admin( $current_user->ID )){
650
+ $helper_user=WYSIJA::get('user','helper');
651
+ $helper_user->synchList($_REQUEST['id'],true);
652
  }
653
 
654
  $this->redirect('admin.php?page=wysija_subscribers&action=lists');
667
  if($_REQUEST['wysija']['list']['is_public']=='on')$_REQUEST['wysija']['list']['is_public']=1;
668
  else $_REQUEST['wysija']['list']['is_public']=0;
669
  }else{
670
+ //$_REQUEST['wysija']['list']['is_public']=0; It's wrong. If is_public is not passed by interface, leave it as it is.
671
  }
672
 
673
  if($update){
690
  function importpluginsave($id=false){
691
  $this->requireSecurity();
692
  $this->_resetGlobMsg();
693
+ $model_config=WYSIJA::get('config','model');
694
+ $helper_import=WYSIJA::get('plugins_import','helper');
695
+ $plugins_importable=$model_config->getValue('pluginsImportableEgg');
696
+ $plugins_imported=array();
697
  foreach($_REQUEST['wysija']['import'] as $table_name =>$result){
698
+ $connection_info=$helper_import->getPluginsInfo($table_name);
699
 
700
  if($result){
701
+ $plugins_imported[]=$table_name;
702
+ if(!$connection_info) $connection_info=$plugins_importable[$table_name];
703
+ $helper_import->import($table_name,$connection_info);
704
  sleep(2);
705
  $this->notice(sprintf(__('Import from plugin %1$s has been completed.',WYSIJA),"<strong>'".$connection_info['name']."'</strong>"));
706
  }else{
709
 
710
  }
711
 
712
+ $model_config->save(array('pluginsImportedEgg'=>$plugins_imported));
713
 
714
  $this->redirect('admin.php?page=wysija_subscribers&action=lists');
715
  }
719
 
720
  $this->viewObj->title=__('Import subscribers from plugins',WYSIJA);
721
 
722
+ $model_config=WYSIJA::get('config','model');
723
 
724
  $this->data=array();
725
+ $this->data['plugins']=$model_config->getValue('pluginsImportableEgg');
726
+ $imported_plugins=$model_config->getValue('pluginsImportedEgg');
727
 
728
+ if($imported_plugins){
729
+ foreach($imported_plugins as $tablename){
730
  unset( $this->data['plugins'][$tablename]);
731
  }
732
  }
747
  }
748
 
749
  function importmatch(){
750
+ $this->jsTrans['subscribers_import_match_confirmation_1'] = __('The selected value is already matched to another column.', WYSIJA);
751
+ $this->jsTrans['subscribers_import_match_confirmation_2'] = __('Can you confirm that this column is corresponding to that field?', WYSIJA);
752
+ $this->js[] = 'wysija-validator';
753
+ wp_enqueue_script('jquery-matchColumn', WYSIJA_URL.'js/jquery/jquery.matchColumn.js', array('jquery'), WYSIJA::get_version());
754
+ $helper_numbers = WYSIJA::get('numbers','helper');
755
+ $bytes = $helper_numbers->get_max_file_upload();
756
 
757
  if(isset($_SERVER['CONTENT_LENGTH']) && $_SERVER['CONTENT_LENGTH']>$bytes['maxbytes']){
758
  if(isset($_FILES['importfile']['name']) && $_FILES['importfile']['name']){
759
+ $file_name = $_FILES['importfile']['name'];
760
  }else{
761
+ $file_name = __('which you have pasted',WYSIJA);
762
  }
763
 
764
+ $this->error(sprintf(__('Upload error, file %1$s is too large! (MAX:%2$s)',WYSIJA) , $file_name , $bytes['maxmegas']),true);
765
  $this->redirect('admin.php?page=wysija_subscribers&action=import');
766
  return false;
767
  }
768
 
769
+ $import = new WJ_Import();
770
+ $this->data = $import->scan_csv_file();
 
 
 
 
 
 
 
 
 
 
 
 
 
771
 
772
+ if($this->data === false) $this->redirect('admin.php?page=wysija_subscribers&action=import');
773
 
774
+ $this->viewObj->title=__('Import Subscribers',WYSIJA);
775
+ $this->viewShow='importmatch';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
776
 
777
+ }
778
 
779
+ /**
780
+ *
781
+ * @param type $input
782
+ * @param type $rowstoread
783
+ * @param type $delimiter
784
+ * @param type $enclosure
785
+ * @param type $linedelimiter
786
+ * @return array
787
+ */
788
+ function _csvToArray($input,$rowstoread=0 , $delimiter=',',$enclosure='',$linedelimiter="\n"){
789
+ $header = null;
790
+ $data = array();
791
 
792
+ $csvData = explode($linedelimiter,$input);
793
+ $i=1;
794
+ foreach($csvData as $csvLine){
795
+ if($rowstoread!=0 && $i>$rowstoread) return $data;
 
 
796
 
797
+ /* str_getcsv only exists in php5 ...*/
798
+ if(!function_exists("str_getcsv")){
799
+ $data[]= $this->csv_explode($csvLine, $delimiter,$enclosure);
800
+ }else{
801
+ $data[] = str_getcsv($csvLine, $delimiter,$enclosure);
802
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
803
 
804
+ $i++;
 
 
 
 
 
 
 
 
 
 
 
 
805
  }
806
 
807
+ return $data;
808
+ }
 
 
 
 
 
 
 
 
 
 
809
 
810
+ function csv_explode($str,$delim, $enclose, $preserve=false){
811
+ $resArr = array();
812
+ $n = 0;
813
+ if(empty($enclose)){
814
+ $resArr = explode($delim, $str);
815
+ }else{
816
+ $expEncArr = explode($enclose, $str);
817
+ foreach($expEncArr as $EncItem){
818
+ if($n++%2){
819
+ array_push($resArr, array_pop($resArr) . ($preserve?$enclose:'') . $EncItem.($preserve?$enclose:''));
820
+ }else{
821
+ $expDelArr = explode($delim, $EncItem);
822
+ array_push($resArr, array_pop($resArr) . array_shift($expDelArr));
823
+ $resArr = array_merge($resArr, $expDelArr);
824
  }
825
+ }
826
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
827
 
828
+ return $resArr;
829
  }
830
 
831
 
835
  $this->requireSecurity();
836
  $this->_resetGlobMsg();
837
 
 
 
 
 
 
 
 
 
 
838
  //we need to save a new list in that situation
839
+ if(!empty($_REQUEST['wysija']['list']['newlistname'])){
840
+ $model_list = WYSIJA::get('list','model');
841
+ $data_list = array();
842
+ $data_list['is_enabled'] = 1;
843
+ $data_list['name'] = $_REQUEST['wysija']['list']['newlistname'];
844
+ $_REQUEST['wysija']['user_list']['list'][] = $model_list->insert($data_list);
845
  }
846
 
847
+ //if there is no list selected, we return to the same form prompting the user to take action
848
  if(!isset($_REQUEST['wysija']['user_list']['list']) || !$_REQUEST['wysija']['user_list']['list']){
849
  $this->error(__('You need to select at least one list.',WYSIJA),true);
850
  return $this->importmatch();
851
  }
852
 
853
+ $import = new WJ_Import();
854
+ $data_numbers = $import->import_subscribers();
855
+ $duplicate_emails_count = $import->get_duplicate_emails_count();
 
 
 
 
 
 
 
 
 
856
 
857
+ if($data_numbers === false){
858
+ return $this->redirect('admin.php?page=wysija_subscribers&action=import');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
859
  }
860
 
861
  //get a list of list name
862
+ $model = WYSIJA::get('list','model');
863
+ $results = $model->get(array('name'),array('list_id'=>$_REQUEST['wysija']['user_list']['list']));
864
+
865
+ $list_names=array();
866
+ foreach($results as $k =>$v) $list_names[]=$v['name'];
867
+
868
+ $this->notice( sprintf(__('%1$s subscribers added to %2$s.', WYSIJA),
869
+ $data_numbers['list_user_ids'],
870
+ '"'.implode('", "',$list_names).'"'
871
+ ) );
872
+
873
+ if(count($duplicate_emails_count)>0){
874
+ $list_emails = '';
875
+ $i = 0;
876
+ foreach($duplicate_emails_count as $email_address => $occurences){
877
+ if( $i > 0 )$list_emails.=', ';
878
+ $list_emails.= $email_address.' ('.$occurences.')';
879
+ $i++;
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
880
  }
881
  //$emailsalreadyinserted=array_keys($emailsCount);
882
+ $this->notice(sprintf(__('%1$s emails appear more than once in your file : %2$s.',WYSIJA),count($duplicate_emails_count),$list_emails),0);
883
  }
884
 
885
+ if(count($data_numbers['invalid'])>0){
886
+ $string = sprintf(__('%1$s emails are not valid : %2$s.',WYSIJA),count($data_numbers['invalid']), utf8_encode(implode(', ',$data_numbers['invalid'])));
887
+ $this->notice($string,0);
888
  }
889
 
890
  $this->redirect();
891
  }
892
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
893
 
894
  function export(){
895
  $this->js[]='wysija-validator';
896
 
897
  $this->viewObj->title=__('Export Subscribers',WYSIJA);
898
  $this->data=array();
899
+ //$this->data['lists']=$this->_getLists();
900
+ $this->data['lists']=$modelList=WYSIJA::get('list','model');
901
+ $listsDB=$modelList->getLists();
902
+
903
+ $lists=array();
904
+
905
+ foreach($listsDB as $listobj){
906
+ $lists[$listobj['list_id']]=$listobj;
907
+ }
908
+ $this->data['lists']=$lists;
909
+
910
  $this->viewShow='export';
911
  }
912
 
921
  }
922
 
923
  function exportlist(){
924
+
925
+ if(!empty($_REQUEST['wysija']['user']['force_select_all'])){
926
+
927
+ $select = array( 'COUNT(DISTINCT([wysija]user.user_id)) as total_users');
928
+ if(!empty($_REQUEST['wysija']['filter']['filter_list'])){
929
+ $select[] = '[wysija]user_list.list_id';
930
+ }
931
+
932
+ // filters for unsubscribed
933
+ $filters = $this->modelObj->detect_filters();
934
+
935
+ $count = $this->modelObj->get_subscribers( $select, $filters );
936
+ $number = $count['total_users'];
937
+ } else {
938
+ $number = count($_REQUEST['wysija']['user']['user_id']);
939
+ }
940
+
941
+ $this->viewObj->title = sprintf(__('Exporting %1$s subscribers',WYSIJA),$number);
942
  $this->data=array();
943
+
944
  $this->data['subscribers'] = $_REQUEST['wysija']['user']['user_id'];
945
  $this->data['user'] = $_REQUEST['wysija']['user'];//for batch-selecting
946
+
947
+ if(!empty($_REQUEST['search'])) $_REQUEST['wysija']['filter']['search'] = $_REQUEST['search'];
948
+
949
  $this->data['filter'] = $_REQUEST['wysija']['filter'];//for batch-selecting
950
+ $this->viewShow = 'export';
951
  }
952
 
953
 
974
 
975
  // make sure the total count of subscribers is updated
976
  $helper_user->refreshUsers();
977
+ $this->redirect_after_bulk_action();
978
  }
979
 
 
 
 
980
  /**
981
  * function generating an export file based on an array of user_ids
982
  */
983
  function export_get(){
984
  @ini_set('max_execution_time',0);
985
 
986
+ $export = new WJ_Export();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
987
 
988
+ if(!empty($this->_batch_select)) $export->batch_select = $this->_batch_select;
989
 
990
+ $file_path_result = $export->export_subscribers();
991
 
992
+ $url=get_bloginfo('wpurl').'/wp-admin/admin.php?page=wysija_subscribers&action=exportedFileGet&file='.base64_encode($file_path_result);
 
 
 
 
993
  $this->notice(str_replace(
994
  array('[link]','[/link]'),
995
  array('<a href="'.$url.'" target="_blank" class="exported-file" >','</a>'),
996
+ sprintf(__('%1$s subscribers were exported. Get the exported file [link]here[/link].',WYSIJA),$export->get_user_ids_rows())));
997
 
998
  if(isset($_REQUEST['camp_id'])){
999
  $this->redirect('admin.php?page=wysija_campaigns&action=viewstats&id='.$_REQUEST['camp_id']);
1000
  }else{
1001
+ $this->redirect();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1002
  }
 
 
1003
  }
1004
 
 
1005
  function exportedFileGet(){
1006
  if(isset($_REQUEST['file'])){
1007
  $helper=WYSIJA::get('file','helper');
1009
  }
1010
  }
1011
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1012
 
 
 
1013
 
1014
+ function bulk_action(){
1015
+ return true;
1016
  }
1017
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1018
 
1019
 
1020
 
1039
 
1040
  function _getForm($id=false){
1041
  if($id){
1042
+ $model_list=WYSIJA::get('list','model');
1043
 
1044
+ return $model_list->get_one_list($id);
1045
  }else{
1046
  $array=array('name'=>'','list_id'=>'','description'=>'','is_public'=>true,'is_enabled'=>true);
1047
  return $array;
1048
  }
1049
 
1050
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1051
  }
controllers/front.php CHANGED
@@ -43,10 +43,12 @@ class WYSIJA_control_front extends WYSIJA_control{
43
  return $result;
44
  }
45
 
46
- function redirect($location){
47
- //header("Location: $location", true, $status);
 
 
 
48
  wp_redirect($location);
49
  exit;
50
  }
51
-
52
- }
43
  return $result;
44
  }
45
 
46
+ function redirect($location) {
47
+ // make sure we encode square brackets as wp_redirect will strip them off
48
+ $location = str_replace(array('[', ']'), array('%5B', '%5D'), $location);
49
+
50
+ // redirect to specified location
51
  wp_redirect($location);
52
  exit;
53
  }
54
+ }
 
controllers/front/confirm.php CHANGED
@@ -29,65 +29,20 @@ class WYSIJA_control_front_confirm extends WYSIJA_control_front{
29
  * return boolean
30
  */
31
  function subscribe(){
32
- $list_ids=array();
33
- if(isset($_REQUEST['wysiconf'])) $list_ids= unserialize(base64_decode($_REQUEST['wysiconf']));
34
- $model_list=WYSIJA::get('list','model');
35
- $lists_names_res=$model_list->get(array('name'),array('list_id'=>$list_ids));
36
- $names=array();
37
- foreach($lists_names_res as $nameob) $names[]=$nameob['name'];
38
-
39
- $model_config=WYSIJA::get('config','model');
40
- // we need to call the translation otherwise it will not be loaded and translated
41
- $model_config->add_translated_default();
42
-
43
- $this->title=$model_config->getValue('subscribed_title');
44
- if(!isset($model_config->values['subscribed_title'])) $this->title=__('You\'ve subscribed to: %1$s',WYSIJA);
45
- $this->title=sprintf($this->title, implode(', ', $names));
46
-
47
- $this->subtitle=$model_config->getValue('subscribed_subtitle');
48
- if(!isset($model_config->values['subscribed_subtitle'])) $this->subtitle=__("Yup, we've added you to our list. You'll hear from us shortly.",WYSIJA);
49
-
50
  if(!isset($_REQUEST['demo'])){
51
- if($this->_testKeyuser()){
52
- //user is not confirmed yet
53
 
54
- if((int)$this->userData['details']['status']<1){
55
- $this->helperUser->subscribe($this->userData['details']['user_id'],true, false,$list_ids);
56
- $this->helperUser->uid=$this->userData['details']['user_id'];
57
- // send a notification to the email specified in the settings if required to
58
- if($model_config->getValue('emails_notified') && $model_config->getValue('emails_notified_when_sub')){
59
- $this->helperUser->_notify($this->userData['details']['email']);
60
- }
61
- return true;
62
- }else{
63
- if(isset($_REQUEST['wysiconf'])){
64
- $needs_subscription=false;
65
- foreach($this->userData['lists'] as $list){
66
- if(in_array($list['list_id'],$list_ids) && (int)$list['sub_date']<1){
67
- $needs_subscription=true;
68
- }
69
- }
70
-
71
- if($needs_subscription){
72
- $this->helperUser->subscribe($this->userData['details']['user_id'],true,false,$list_ids);
73
- $this->title=sprintf($model_config->getValue('subscribed_title'), implode(', ', $names));
74
- $this->subtitle=$model_config->getValue('subscribed_subtitle');
75
- // send a notification to the email specified in the settings if required to
76
- if($model_config->getValue('emails_notified') && $model_config->getValue('emails_notified_when_sub')){
77
- $this->helperUser->_notify($this->userData['details']['email'], true, $list_ids);
78
- }
79
-
80
- }else{
81
- $this->title=sprintf(__('You are already subscribed to : %1$s',WYSIJA), implode(', ', $names));
82
- }
83
- }else{
84
- $this->title=__('You are already subscribed.',WYSIJA);
85
- }
86
- return true;
87
- }
88
 
 
 
89
 
90
- }
 
91
  }
92
 
93
  return true;
@@ -99,13 +54,13 @@ class WYSIJA_control_front_confirm extends WYSIJA_control_front{
99
  // we need to call the translation otherwise it will not be loaded and translated
100
  $model_config->add_translated_default();
101
 
102
- $this->title=$model_config->getValue('unsubscribed_title');
103
- if(!isset($model_config->values['unsubscribed_title'])) $this->title=__("You've unsubscribed!",WYSIJA);
104
 
105
- $this->subtitle=$model_config->getValue('unsubscribed_subtitle');
106
- if(!isset($model_config->values['unsubscribed_subtitle'])) $this->subtitle=__("Great, you'll never hear from us again!",WYSIJA);
107
 
108
- $undo_paramsurl=array(
109
  'wysija-page'=>1,
110
  'controller'=>'confirm',
111
  'action'=>'undounsubscribe',
@@ -124,13 +79,16 @@ class WYSIJA_control_front_confirm extends WYSIJA_control_front{
124
  return false;
125
  }
126
  }
127
- }
128
- else
129
  $undo_paramsurl['demo'] = 1;
 
 
 
130
 
131
- $this->subtitle .= str_replace(
 
132
  array('[link]','[/link]'),
133
- array('<a href="'.WYSIJA::get_permalink($model_config->getValue('confirm_email_link'),$undo_paramsurl).'">','</a>'),
134
  '<p><b>'.__('You made a mistake? [link]Undo unsubscribe[/link].',WYSIJA)).'</b></p>';
135
  return true;
136
  }
@@ -254,16 +212,18 @@ class WYSIJA_control_front_confirm extends WYSIJA_control_front{
254
  $modelUL->backSave=true;
255
  /* list of core list */
256
  $modelLIST=WYSIJA::get('list','model');
257
- $results=$modelLIST->get(array('list_id'),array('is_enabled'=>'0'));
258
- $core_listids=array();
 
 
259
  foreach($results as $res){
260
- $core_listids[]=$res['list_id'];
261
  }
262
 
263
  //0 - get current lists of the user
264
  $userlists=$modelUL->get(array('list_id','unsub_date'),array('user_id'=>$id));
265
 
266
- $oldlistids=$newlistids=array();
267
  foreach($userlists as $listdata) $oldlistids[$listdata['list_id']]=$listdata['unsub_date'];
268
 
269
  $config=WYSIJA::get('config','model');
@@ -276,7 +236,7 @@ class WYSIJA_control_front_confirm extends WYSIJA_control_front{
276
  //if the list is not already recorded for the user then we will need to insert it
277
  if(!isset($oldlistids[$list_id])){
278
  $modelUL->reset();
279
- $newlistids[]=$list_id;
280
  $dataul=array('user_id'=>$id,'list_id'=>$list_id,'sub_date'=>time());
281
  //if double optin is on then we want to send a confirmation email for newly added subscription
282
  if($dbloptin){
@@ -299,21 +259,44 @@ class WYSIJA_control_front_confirm extends WYSIJA_control_front{
299
 
300
 
301
  //if a confirmation email needs to be sent then we send it
302
- if($dbloptin && !empty($newlistids)){
303
- $hUser->sendConfirmationEmail($id,true,$newlistids);
 
 
 
 
 
 
 
 
 
 
 
 
 
304
  }
305
 
306
  // list ids
307
  $list_ids = !empty($_POST['wysija']['user_list']['list_id']) ? $_POST['wysija']['user_list']['list_id'] : array();
308
  if(is_array($list_ids) === false) $list_ids = array();
309
 
310
- $notEqual = array_merge($core_listids, $list_ids);
311
 
312
  //delete the lists from which you've removed yourself
313
  $condiFirst = array('notequal'=>array('list_id'=> $notEqual), 'equal' => array('user_id' => $id, 'unsub_date' => 0));
314
  $modelUL=WYSIJA::get('user_list','model');
315
  $modelUL->update(array('unsub_date'=>time()),$condiFirst);
316
  $modelUL->reset();
 
 
 
 
 
 
 
 
 
 
317
  $this->notice(__('Newsletter profile has been updated.',WYSIJA));
318
  $this->subscriptions();
319
 
@@ -322,4 +305,4 @@ class WYSIJA_control_front_confirm extends WYSIJA_control_front{
322
  }
323
  return true;
324
  }
325
- }
29
  * return boolean
30
  */
31
  function subscribe(){
32
+ $helper_user = WYSIJA::get('user','helper');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
33
  if(!isset($_REQUEST['demo'])){
34
+ $helper_user->confirm_user();
 
35
 
36
+ if(!empty($helper_user->title)) $this->title = $helper_user->title;
37
+ if(!empty($helper_user->subtitle)) $this->optional_subtitle = $helper_user->subtitle;
38
+ }else{
39
+ $model_config=WYSIJA::get('config','model');
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
40
 
41
+ // we need to call the translation otherwise it will not be loaded and translated
42
+ $model_config->add_translated_default();
43
 
44
+ $this->title = sprintf($model_config->getValue('subscribed_title'), 'demo');
45
+ $this->optional_subtitle=$model_config->getValue('subscribed_subtitle');
46
  }
47
 
48
  return true;
54
  // we need to call the translation otherwise it will not be loaded and translated
55
  $model_config->add_translated_default();
56
 
57
+ $this->title = $model_config->getValue('unsubscribed_title');
58
+ if(!isset($model_config->values['unsubscribed_title'])) $this->title = __("You've unsubscribed!",WYSIJA);
59
 
60
+ $this->optional_subtitle = $model_config->getValue('unsubscribed_subtitle');
61
+ if(!isset($model_config->values['unsubscribed_subtitle'])) $this->optional_subtitle = __("Great, you'll never hear from us again!",WYSIJA);
62
 
63
+ $undo_paramsurl = array(
64
  'wysija-page'=>1,
65
  'controller'=>'confirm',
66
  'action'=>'undounsubscribe',
79
  return false;
80
  }
81
  }
82
+ }else{
 
83
  $undo_paramsurl['demo'] = 1;
84
+ }
85
+
86
+ $link_undo = WYSIJA::get_permalink($model_config->getValue('unsubscribe_page'),$undo_paramsurl);
87
 
88
+
89
+ $this->undo_unsubscribe = str_replace(
90
  array('[link]','[/link]'),
91
+ array('<a href="'.$link_undo.'">','</a>'),
92
  '<p><b>'.__('You made a mistake? [link]Undo unsubscribe[/link].',WYSIJA)).'</b></p>';
93
  return true;
94
  }
212
  $modelUL->backSave=true;
213
  /* list of core list */
214
  $modelLIST=WYSIJA::get('list','model');
215
+
216
+ // Using "like" condition in order to force sql query to OR (instead of AND). It'll be incorrct if status contains other values than 0/1.
217
+ $results=$modelLIST->get(array('list_id'),array('like' => array('is_enabled'=>0, 'is_public' => 0)));
218
+ $static_listids=array();
219
  foreach($results as $res){
220
+ $static_listids[]=$res['list_id'];
221
  }
222
 
223
  //0 - get current lists of the user
224
  $userlists=$modelUL->get(array('list_id','unsub_date'),array('user_id'=>$id));
225
 
226
+ $oldlistids=$new_list_ids=array();
227
  foreach($userlists as $listdata) $oldlistids[$listdata['list_id']]=$listdata['unsub_date'];
228
 
229
  $config=WYSIJA::get('config','model');
236
  //if the list is not already recorded for the user then we will need to insert it
237
  if(!isset($oldlistids[$list_id])){
238
  $modelUL->reset();
239
+ $new_list_ids[]=$list_id;
240
  $dataul=array('user_id'=>$id,'list_id'=>$list_id,'sub_date'=>time());
241
  //if double optin is on then we want to send a confirmation email for newly added subscription
242
  if($dbloptin){
259
 
260
 
261
  //if a confirmation email needs to be sent then we send it
262
+
263
+ if($dbloptin && !empty($new_list_ids)){
264
+ $send_confirmation = true;
265
+ $send_confirmation = apply_filters('mpoet_confirm_new_list_subscriptions_page', $send_confirmation);
266
+
267
+ if($send_confirmation === true){
268
+ $hUser->sendConfirmationEmail($id,true,$new_list_ids);
269
+ }else{
270
+ // this case has been made so that when subscribers add themselves to a
271
+ // list through the edit your subscription form they don't receive a confirmation email they already confirmed.
272
+ // so they receive also the autorespo,nders correspondign to that list immediately.
273
+ $helper_user = WYSIJA::get('user','helper');
274
+ $_REQUEST['wysiconf'] = base64_encode(serialize($new_list_ids));
275
+ $helper_user->confirm_user();
276
+ }
277
  }
278
 
279
  // list ids
280
  $list_ids = !empty($_POST['wysija']['user_list']['list_id']) ? $_POST['wysija']['user_list']['list_id'] : array();
281
  if(is_array($list_ids) === false) $list_ids = array();
282
 
283
+ $notEqual = array_merge($static_listids, $list_ids);
284
 
285
  //delete the lists from which you've removed yourself
286
  $condiFirst = array('notequal'=>array('list_id'=> $notEqual), 'equal' => array('user_id' => $id, 'unsub_date' => 0));
287
  $modelUL=WYSIJA::get('user_list','model');
288
  $modelUL->update(array('unsub_date'=>time()),$condiFirst);
289
  $modelUL->reset();
290
+
291
+ /*
292
+ Custom Fields.
293
+ */
294
+ if (isset($_POST['wysija']['field'])) {
295
+ WJ_FieldHandler::handle_all(
296
+ $_POST['wysija']['field'], $id
297
+ );
298
+ }
299
+
300
  $this->notice(__('Newsletter profile has been updated.',WYSIJA));
301
  $this->subscriptions();
302
 
305
  }
306
  return true;
307
  }
308
+ }
controllers/front/email.php CHANGED
@@ -20,27 +20,43 @@ class WYSIJA_control_front_email extends WYSIJA_control_front{
20
  $emailM->getFormat = OBJECT;
21
  // Get config model
22
  $configM = WYSIJA::get('config','model');
23
-
24
  // Helpers
25
  $emailH = WYSIJA::get('email','helper');
26
  $mailerH = WYSIJA::get('mailer','helper');
27
 
 
28
  // Get current email object.
29
- $current_email = $emailM->getOne((int)$_REQUEST['email_id']);
 
 
 
 
 
 
 
 
 
 
 
 
30
 
31
  // Get current user object if possible
32
  $current_user = null;
33
- if(isset($_REQUEST['user_id'])){
34
  // Get User Model
35
  $userM = WYSIJA::get('user','model');
36
  $userM->getFormat = OBJECT;
37
  $current_user = $userM->getOne((int)$_REQUEST['user_id']);
38
  }
39
-
40
  // Parse and replace user tags.
41
  $mailerH->parseUserTags($current_email);
42
  $mailerH->parseSubjectUserTags($current_email);
43
- $mailerH->replaceusertags($current_email, $current_user);
 
 
 
 
44
 
45
  // Set Body
46
  $email_render = $current_email->body;
@@ -56,17 +72,22 @@ class WYSIJA_control_front_email extends WYSIJA_control_front{
56
  $find[] = '[total]';
57
  $replace[] = $current_email->params['autonl']['articles']['total'];
58
  }
59
- if (isset($current_email->params['autonl']['articles']['ids'])){
 
 
 
 
 
 
60
  $find[] = '[number]';
61
- $replace[] = $current_email->params['autonl']['articles']['ids'];
62
  }
63
 
64
- $email_render = str_replace($find, $replace, $email_render);
65
-
66
  // Strip unsubscribe links.
67
- $email_render = $emailH->stripPersonalLinks($email_render);
68
 
69
- echo apply_filters('wysija_preview',$email_render);
70
 
71
  exit;
72
  }
20
  $emailM->getFormat = OBJECT;
21
  // Get config model
22
  $configM = WYSIJA::get('config','model');
23
+ $configM->add_translated_default();
24
  // Helpers
25
  $emailH = WYSIJA::get('email','helper');
26
  $mailerH = WYSIJA::get('mailer','helper');
27
 
28
+ $email_id = (int)$_REQUEST['email_id'];
29
  // Get current email object.
30
+ $current_email = $emailM->getOne($email_id);
31
+
32
+ if($current_email->type==2){
33
+
34
+ $emailM->reset();
35
+ $autonewsHelper = WYSIJA::get('autonews','helper');
36
+ $autonewsHelper->refresh_automatic_content(array($email_id));
37
+ $emailM->getFormat = OBJECT;
38
+ $current_email = $emailM->getOne($email_id);
39
+ }
40
+
41
+
42
+
43
 
44
  // Get current user object if possible
45
  $current_user = null;
46
+ if(isset($_REQUEST['user_id']) && (int)$_REQUEST['user_id'] > 0 ){
47
  // Get User Model
48
  $userM = WYSIJA::get('user','model');
49
  $userM->getFormat = OBJECT;
50
  $current_user = $userM->getOne((int)$_REQUEST['user_id']);
51
  }
 
52
  // Parse and replace user tags.
53
  $mailerH->parseUserTags($current_email);
54
  $mailerH->parseSubjectUserTags($current_email);
55
+ $mailerH->replaceusertags($current_email, $current_user);
56
+ // Start tracking if this preview is opened from a newsletter
57
+ if ($current_user !== null) {
58
+ $mailerH->tracker_replaceusertags($current_email, $current_user);
59
+ }
60
 
61
  // Set Body
62
  $email_render = $current_email->body;
72
  $find[] = '[total]';
73
  $replace[] = $current_email->params['autonl']['articles']['total'];
74
  }
75
+
76
+ // if (isset($current_email->params['autonl']['articles']['ids'])){
77
+ // $find[] = '[number]';
78
+ // $replace[] = count($current_email->params['autonl']['articles']['ids']);
79
+ // }
80
+
81
+ if (isset($current_email->params['autonl']['total_child'])){
82
  $find[] = '[number]';
83
+ $replace[] = $current_email->params['autonl']['total_child'];
84
  }
85
 
86
+ $email_render1 = str_replace($find, $replace, $email_render);
 
87
  // Strip unsubscribe links.
88
+ $email_render2 = $emailH->stripPersonalLinks($email_render1);
89
 
90
+ echo apply_filters('wysija_preview',$email_render2);
91
 
92
  exit;
93
  }
controllers/front/module.php ADDED
@@ -0,0 +1,38 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ /**
4
+ * http://wy351s.local/?wysija-page=1&controller=confirm&wysija-key=4d5c04e327932b99d394f0963fa71dc4&action=subscriptions&wysijap=subscriptions&demo=1
5
+ * http://wy351s.local/?wysija-page=1&controller=module&action=init&wysijap=subscriptions&module=a&hook=newsletter
6
+ */
7
+ defined('WYSIJA') or die('Restricted access');
8
+
9
+ class WYSIJA_control_front_module extends WYSIJA_control_front{
10
+ /**
11
+ *
12
+ * @var string title of the page
13
+ */
14
+ public $subtitle;
15
+
16
+ /**
17
+ *
18
+ * @var html content of the page
19
+ */
20
+ public $title;
21
+
22
+ /**
23
+ * Dispatcher of module
24
+ */
25
+ public function init() {
26
+ if (empty($_REQUEST['module']) || empty($_REQUEST['hook'])) {
27
+ wp_redirect( home_url() ); exit;
28
+ }
29
+ $module_name = $_REQUEST['module'];
30
+ $hook = $_REQUEST['hook'];
31
+ $extension = !empty($_REQUEST['extension'])
32
+ ?
33
+ in_array($_REQUEST['extension'], array(WYSIJA, WYSIJANLP)) ? $_REQUEST['extension'] : WYSIJA
34
+ : WYSIJA;
35
+ $hook_params = array_merge($_REQUEST, array('controller_object' => $this));
36
+ $this->subtitle = WYSIJA_module::get_instance_by_name($module_name, $extension)->{'hook_'.$hook}($hook_params);
37
+ }
38
+ }
controllers/front/stats.php CHANGED
@@ -5,296 +5,52 @@ defined('WYSIJA') or die('Restricted access');
5
  class WYSIJA_control_front_stats extends WYSIJA_control_front{
6
  var $model='' ;
7
  var $view='';
 
 
 
 
 
 
 
 
8
 
9
  function WYSIJA_control_front_stats(){
10
  parent::WYSIJA_control_front();
11
  }
12
 
13
-
14
- function rm_url_param($param_rm=array(), $query='')
15
- {
16
- if(!$query) return $query;
17
- $queries=explode('?',$query);
18
- $params=array();
19
- parse_str($queries[1], $params);
20
-
21
- foreach($param_rm as $param_rmuniq)
22
- unset($params[$param_rmuniq]);
23
- $newquery = $queries[0];
24
-
25
- if($params){
26
- $newquery.='?';
27
- $i=0;
28
- foreach($params as $k => $v){
29
- if($i>0) $newquery .= '&';
30
- $newquery.=$k.'='.$v;
31
- $i++;
32
-
33
- }
34
- }else return $newquery;
35
-
36
- return substr($newquery,1);
37
- }
38
-
39
  /**
40
  * count the click statistic and redirect to the right url
41
  * @return boolean
42
  */
43
  function analyse(){
44
- if(isset($_REQUEST['debug'])){
45
- if(version_compare(phpversion(), '5.4')>= 0){
46
- error_reporting(E_ALL ^ E_STRICT);
47
-
48
- }else{
49
- error_reporting(E_ALL);
50
- }
51
- ini_set('display_errors', '1');
52
- }
53
  if(isset($_REQUEST['email_id']) && isset($_REQUEST['user_id'])){
54
- $email_id=(int)$_REQUEST['email_id'];
55
- $user_id=(int)$_REQUEST['user_id'];
56
-
57
- //debug message
58
- if(isset($_REQUEST['debug'])) echo '<h2>isset email_id and user_id</h2>';
59
-
60
- $requesturlencoded=false;
61
- if(isset($_REQUEST['urlencoded'])){
62
- $requesturlencoded=$_REQUEST['urlencoded'];
63
- }elseif(isset($_REQUEST['urlpassed'])){
64
- $requesturlencoded=$_REQUEST['urlpassed'];
65
- }
66
-
67
- if($requesturlencoded){
68
- //clicked stats
69
- if(isset($_REQUEST['no64'])){
70
- $recordedUrl=$decodedUrl=$requesturlencoded;
71
- }else{
72
- $recordedUrl=$decodedUrl=base64_decode($requesturlencoded);
73
- }
74
- if(strpos($recordedUrl, 'utm_source')!==false){
75
- $recordedUrl=$this->rm_url_param(array('utm_source','utm_campaign','utm_medium'),$recordedUrl);
76
- }
77
-
78
- //debug message
79
- if(isset($_REQUEST['debug'])) echo '<h2>isset urlencoded '.$decodedUrl.'</h2>';
80
-
81
- if($email_id && !isset($_REQUEST['demo'])){ //if not email_id that means it is an email preview
82
- //look for url entry and insert if not exists
83
- $modelUrl=WYSIJA::get('url','model');
84
-
85
- $urlObj=$modelUrl->getOne(false,array('url'=>$recordedUrl));
86
-
87
- if(!$urlObj){
88
- //we need to insert in url
89
- $modelUrl->insert(array('url'=>$recordedUrl));
90
- $urlObj=$modelUrl->getOne(false,array('url'=>$recordedUrl));
91
- }
92
- $modelUrl=null;
93
-
94
- //look for email_user_url entry and insert if not exists
95
- $modelEmailUserUrl=WYSIJA::get('email_user_url','model');
96
- $dataEmailUserUrl=array('email_id'=>$email_id,'user_id'=>$user_id,'url_id'=>$urlObj['url_id']);
97
- $emailUserUrlObj=$modelEmailUserUrl->getOne(false,$dataEmailUserUrl);
98
- $uniqueclick=false;
99
- if(!$emailUserUrlObj){
100
- //we need to insert in email_user_url
101
- $modelEmailUserUrl->reset();
102
- $query_EmailUserUrl='INSERT IGNORE INTO [wysija]email_user_url (`email_id` ,`user_id`,`url_id`) ';
103
- $query_EmailUserUrl.='VALUES ('.$email_id.', '.$user_id.', '.$urlObj['url_id'].')';
104
-
105
- $modelEmailUserUrl->query($query_EmailUserUrl);
106
-
107
- //$modelEmailUserUrl->insert($dataEmailUserUrl);
108
- $uniqueclick=true;
109
- }
110
-
111
- //increment stats counter on email_user_url clicked
112
- $modelEmailUserUrl=WYSIJA::get('email_user_url','model');
113
- $modelEmailUserUrl->update(array('clicked_at'=>time(),'number_clicked'=>'[increment]'),$dataEmailUserUrl);
114
- $modelEmailUserUrl=null;
115
-
116
- //look for url_mail entry and insert if not exists
117
- $modelUrlMail=WYSIJA::get('url_mail','model');
118
- $dataUrlEmail=array('email_id'=>$email_id,'url_id'=>$urlObj['url_id']);
119
- $urlMailObj=$modelUrlMail->getOne(false,$dataUrlEmail);
120
- if(!$urlMailObj){
121
- //we need to insert in url_mail
122
- $modelUrlMail->reset();
123
- $modelUrlMail->insert($dataUrlEmail);
124
- }
125
-
126
- $dataUpdate=array('total_clicked'=>'[increment]');
127
- if(!$uniqueclick) $dataUpdate['unique_clicked']='[increment]';
128
- //increment stats counter on url_mail clicked
129
- $modelUrlMail->update($dataUpdate,$dataUrlEmail);
130
- $modelUrlMail=null;
131
-
132
- $statusEmailUserStat=2;
133
- if(in_array($recordedUrl,array('[unsubscribe_link]','[subscriptions_link]','[view_in_browser_link]'))){
134
- $this->subscriberClass = WYSIJA::get('user','model');
135
- $this->subscriberClass->getFormat=OBJECT;
136
-
137
- //check if the security hash is passed to insure privacy
138
- $receiver=$link=false;
139
- if(isset($_REQUEST['hash'])){
140
- if($_REQUEST['hash']==md5(AUTH_KEY.$recordedUrl.$user_id)){
141
- $receiver = $this->subscriberClass->getOne(array('user_id'=>$user_id));
142
- }else{
143
- die('Security check failure.');
144
- }
145
- }else{
146
- //link is not valid anymore
147
- //propose to resend the newsletter with good links ?
148
- $link=$this->subscriberClass->getResendLink($user_id,$email_id);
149
- }
150
-
151
-
152
- switch($recordedUrl){
153
- case '[unsubscribe_link]':
154
- //we need to make sure that this link belongs to that user
155
- if($receiver){
156
- $link=$this->subscriberClass->getUnsubLink($receiver,true);
157
- $statusEmailUserStat=3;
158
- }
159
- break;
160
- case '[subscriptions_link]':
161
- if($receiver){
162
- $link=$this->subscriberClass->getEditsubLink($receiver,true);
163
- }
164
- break;
165
- case '[view_in_browser_link]':
166
- $modelEmail=WYSIJA::get('email','model');
167
- $dataEmail=$modelEmail->getOne(false,array('email_id'=>$email_id));
168
- $emailH=WYSIJA::get('email','helper');
169
- $link=$emailH->getVIB($dataEmail);
170
- break;
171
- }
172
-
173
- //if the subscriber still exists in the DB we will have a link
174
- if($link){
175
- $decodedUrl=$link;
176
- }else{
177
- //the subscriber doesn't appear in the DB we can redirect to the web version
178
- $decodedUrl=$this->_get_browser_link($email_id);
179
-
180
- return $this->redirect($decodedUrl);
181
- }
182
-
183
- }else{
184
-
185
- if(strpos($decodedUrl, 'http://' )=== false && strpos($decodedUrl, 'https://' )=== false) $decodedUrl='http://'.$decodedUrl;
186
- //check that there is no broken unsubscribe link such as http://[unsubscribe_link]
187
- if(strpos($decodedUrl, '[unsubscribe_link]')!==false){
188
- $this->subscriberClass = WYSIJA::get('user','model');
189
- $this->subscriberClass->getFormat=OBJECT;
190
- $receiver = $this->subscriberClass->getOne($user_id);
191
- $decodedUrl=$this->subscriberClass->getUnsubLink($receiver,true);
192
- }
193
-
194
- if(strpos($decodedUrl, '[view_in_browser_link]')!==false){
195
- $link=$this->_get_browser_link($email_id);
196
- $decodedUrl=$link;
197
- }
198
-
199
- }
200
-
201
- //debug information
202
- if(isset($_REQUEST['debug'])) echo '<h2>isset decoded url '.$decodedUrl.'</h2>';
203
-
204
- $modelEmailUS=WYSIJA::get('email_user_stat','model');
205
- $exists=$modelEmailUS->getOne(false,array('equal'=>array('email_id'=>$email_id,'user_id'=>$user_id), 'less'=>array('status'=>$statusEmailUserStat)));
206
- $dataupdate=array('status'=>$statusEmailUserStat);
207
- if($exists && isset($exists['opened_at']) && !(int)$exists['opened_at']){
208
- $dataupdate['opened_at']=time();
209
- }
210
-
211
- $modelEmailUS->reset();
212
- $modelEmailUS->colCheck=false;
213
- $modelEmailUS->update($dataupdate,array('equal'=>array('email_id'=>$email_id,'user_id'=>$user_id), 'less'=>array('status'=>$statusEmailUserStat)));
214
-
215
-
216
- }else{
217
- if(in_array($recordedUrl,array('[unsubscribe_link]','[subscriptions_link]','[view_in_browser_link]'))){
218
- $modelU=WYSIJA::get('user','model');
219
- $modelU->getFormat=OBJECT;
220
- $objUser=$modelU->getOne(false,array('wpuser_id'=>get_current_user_id()));
221
- switch($recordedUrl){
222
- case '[unsubscribe_link]':
223
- $link=$modelU->getConfirmLink($objUser,'unsubscribe',false,true).'&demo=1';
224
-
225
- break;
226
- case '[subscriptions_link]':
227
- $link=$modelU->getConfirmLink($objUser,'subscriptions',false,true).'&demo=1';
228
- //$link=$this->subscriberClass->getEditsubLink($receiver,true);
229
- break;
230
- case 'view_in_browser_link':
231
- case '[view_in_browser_link]':
232
- if(!$email_id) $email_id=$_REQUEST['id'];
233
-
234
- $link=$this->_get_browser_link($email_id);
235
- break;
236
- }
237
- $decodedUrl=$link;
238
-
239
- }else{
240
- if(strpos($decodedUrl, 'http://' )=== false && strpos($decodedUrl, 'https://' )=== false) $decodedUrl='http://'.$decodedUrl;
241
- }
242
- if(isset($_REQUEST['debug'])) {
243
- echo '<h2>not email_id </h2>';
244
- }
245
- }
246
-
247
- //sometimes this will be a life saver :)
248
- $decodedUrl = str_replace('&amp;','&',$decodedUrl);
249
- if(isset($_REQUEST['debug'])) {
250
- echo '<h2>final decoded url '.$decodedUrl.'</h2>';
251
- exit;
252
- }
253
- $this->redirect($decodedUrl);
254
-
255
 
 
 
 
 
 
 
256
  }else{
257
- //opened stat */
258
- //$modelEmail=WYSIJA::get("email","model");
259
- //$modelEmail->update(array('number_opened'=>"[increment]"),array("email_id"=>$email_id));
260
-
261
- $modelEmailUS=WYSIJA::get('email_user_stat','model');
262
- $modelEmailUS->reset();
263
- $modelEmailUS->update(
264
- array('status'=>1,'opened_at'=>time()),
265
- array('email_id'=>$email_id,'user_id'=>$user_id,'status'=>0));
266
-
267
- header( 'Cache-Control: no-store, no-cache, must-revalidate' );
268
- header( 'Cache-Control: post-check=0, pre-check=0', false );
269
- header( 'Pragma: no-cache' );
270
-
271
- if(empty($picture)) $picture = WYSIJA_DIR_IMG.'statpicture.png';
272
- $handle = fopen($picture, 'r');
273
-
274
- if(!$handle) exit;
275
- header('Content-type: image/png');
276
- $contents = fread($handle, filesize($picture));
277
- fclose($handle);
278
- echo $contents;
279
- exit;
280
  }
281
-
282
-
283
  }
284
 
285
  return true;
286
  }
287
-
288
- function _get_browser_link($email_id){
289
- $paramsurl=array(
290
- 'wysija-page'=>1,
291
- 'controller'=>'email',
292
- 'action'=>'view',
293
- 'email_id'=>$email_id,
294
- 'user_id'=>0
295
- );
296
- $config=WYSIJA::get('config','model');
297
- return WYSIJA::get_permalink($config->getValue('confirm_email_link'),$paramsurl);
 
298
  }
299
-
300
  }
5
  class WYSIJA_control_front_stats extends WYSIJA_control_front{
6
  var $model='' ;
7
  var $view='';
8
+
9
+ /**
10
+ * Possible characters to be url encoded
11
+ * @var array
12
+ */
13
+ protected $characters_to_encode = array(
14
+ '@'
15
+ );
16
 
17
  function WYSIJA_control_front_stats(){
18
  parent::WYSIJA_control_front();
19
  }
20
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
21
  /**
22
  * count the click statistic and redirect to the right url
23
  * @return boolean
24
  */
25
  function analyse(){
 
 
 
 
 
 
 
 
 
26
  if(isset($_REQUEST['email_id']) && isset($_REQUEST['user_id'])){
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
27
 
28
+ $WJ_Stats = new WJ_Stats();
29
+ if(!empty($WJ_Stats->clicked_url)){
30
+ // clicked stats
31
+ $url = $this->encode_url($WJ_Stats->subscriber_clicked());
32
+ do_action('mpoet_click_stats', $WJ_Stats);
33
+ $this->redirect($url);
34
  }else{
35
+ // opened stat
36
+ $WJ_Stats->subscriber_opened();
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
37
  }
 
 
38
  }
39
 
40
  return true;
41
  }
42
+
43
+ /**
44
+ * Encode some special characters in url
45
+ * @param string $url
46
+ * @return string
47
+ */
48
+ protected function encode_url($url) {
49
+ return str_replace(
50
+ $this->characters_to_encode,
51
+ array_map('urlencode', $this->characters_to_encode),
52
+ $url
53
+ );
54
  }
55
+
56
  }
core/base.php CHANGED
@@ -1,1146 +1,1427 @@
1
  <?php
2
  // Require constants.
3
- require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'constants.php');
 
4
  // Require global classes autoloader
5
- require_once(dirname(__FILE__).DIRECTORY_SEPARATOR.'autoloader.php');
 
 
 
 
 
 
 
 
6
 
7
- defined('WYSIJA') or die('Restricted access');
8
- global $wysija_msg;
9
- global $wysija_wpmsg;
10
- if(!$wysija_msg) $wysija_msg=array();
11
- $wysija_wpmsg=array();
12
  class WYSIJA_object{
13
 
14
- function WYSIJA_object(){
15
-
16
- }
17
-
18
- /**
19
- * return a plugin version safely anywhere in any hook and stock it staticaly
20
- * @staticvar array $versions
21
- * @param string $plugin_name
22
- * @return array|string
23
- */
24
- public static function get_version($plugin_name=false) {
25
- static $versions=array();
26
- if(isset($versions[$plugin_name])) return $versions[$plugin_name];
27
- if ( ! function_exists( 'get_plugins' ) ) {
28
- if(file_exists(ABSPATH . 'wp-admin'.DS.'includes'.DS.'plugin.php')){
29
- require_once( ABSPATH . 'wp-admin'.DS.'includes'.DS.'plugin.php' );
30
- }
31
- }
32
- if (function_exists( 'get_plugins' ) ) {
33
- if(!$plugin_name) $plugin_name='wysija-newsletters/index.php';
34
- $plugin_file=WYSIJA_PLG_DIR.str_replace('/',DS,$plugin_name);
35
- $plugin_data = get_plugin_data( $plugin_file );
36
- $versions[$plugin_name] = $plugin_data['Version'];
37
- }else{
38
- $versions[$plugin_name]='undefined';
39
- }
40
- return $versions[$plugin_name];
41
- }
42
-
43
-
44
-
45
- /**
46
- * get the current_user data in a safe manner making sure a field exists before returning it's value
47
- * @global type $current_user
48
- * @param string $field
49
- * @return mixed
50
- */
51
- public static function wp_get_userdata($field=false){
52
- //WordPress globals be careful there
53
- global $current_user;
54
- if($field){
55
- if(function_exists('get_currentuserinfo')) get_currentuserinfo();
56
- if(isset($current_user->$field))
57
- return $current_user->$field;
58
- elseif(isset($current_user->data->$field))
59
- return $current_user->data->$field;
60
- else{
61
- return $current_user;
62
- }
63
- }
64
- return $current_user;
65
- }
66
-
67
- /**
68
- * set a global notice message
69
- * @global array $wysija_wpmsg
70
- * @param type $msg
71
- */
72
- function wp_notice($msg){
73
- global $wysija_wpmsg;
74
-
75
- //add the hook only once
76
- if(!$wysija_wpmsg) add_action('admin_notices', array($this,'wp_msgs'));
77
-
78
- //record msgs
79
- $wysija_wpmsg['updated'][]=$msg;
80
- }
81
-
82
- /**
83
- * set a global error message
84
- * @global array $wysija_wpmsg
85
- * @param type $msg
86
- */
87
- function wp_error($msg){
88
- global $wysija_wpmsg;
89
-
90
- //add the hook only once
91
- if(!$wysija_wpmsg) add_action('admin_notices', array($this,'wp_msgs'));
92
-
93
- //record msgs
94
- $wysija_wpmsg['error'][]=$msg;
95
- }
96
-
97
- /**
98
- * prints a global message in the WordPress' backend identified as belonging to wysija
99
- * we tend to avoid as much as possible printing messages globally, since this is ugly
100
- * and make the administrators immune to beige-yellowish messages :/
101
- * @global array $wysija_wpmsg
102
- */
103
- function wp_msgs() {
104
- global $wysija_wpmsg;
105
- foreach($wysija_wpmsg as $keymsg => $wp2){
106
- $msgs= '<div class="'.$keymsg.' fade">';
107
- foreach($wp2 as $mymsg)
108
- $msgs.= '<p><strong>Wysija</strong> : '.$mymsg.'</p>';
109
- $msgs.= '</div>';
110
- }
111
-
112
- echo $msgs;
113
- }
114
-
115
- /**
116
- * returns an error message, it will appear as a red pinkish message in our interfaces
117
- * @param string $msg
118
- * @param boolean $public if set to true it will appear as a full message, otherwise it will appear behind a "Show more details." link
119
- * @param boolean $global if set to true it will appear on all of the backend interfaces, not only wysija's own
120
- */
121
- function error($msg,$public=false,$global=false){
122
- $status='error';
123
- if($global) $status='g-'.$status;
124
- $this->setInfo($status,$msg,$public);
125
- }
126
-
127
- /**
128
- * returns a success message, it will appear as a beige yellowish message in our interfaces
129
- * @param string $msg
130
- * @param boolean $public if set to true it will appear as a full message, otherwise it will appear behind a "Show more details." link
131
- * @param boolean $global if set to true it will appear on all of the backend interfaces, not only wysija's own
132
- */
133
- function notice($msg,$public=true,$global=false){
134
- $status='updated';
135
- if($global) $status='g-'.$status;
136
- $this->setInfo($status,$msg,$public);
137
- }
138
-
139
- /**
140
- * store all of the error and success messages in a global variable
141
- * @global type $wysija_msg
142
- * @param type $status whether this is a success message or an error message
143
- * @param type $msg
144
- * @param type $public if set to true it will appear as a full message, otherwise it will appear behind a "Show more details." link
145
- */
146
- function setInfo($status,$msg,$public=false){
147
- global $wysija_msg;
148
- if(!$public) {
149
-
150
- if(!isset($wysija_msg['private'][$status])){
151
- $wysija_msg['private']=array();
152
- $wysija_msg['private'][$status]=array();
153
- }
154
- array_push($wysija_msg['private'][$status], $msg);
155
- }else{
156
- if(!isset($wysija_msg[$status])) $wysija_msg[$status]=array();
157
- array_push($wysija_msg[$status], $msg);
158
- }
159
-
160
- }
161
-
162
- /**
163
- * read the global function containing all of the error messages and print them
164
- * @global type $wysija_msg
165
- * @return type
166
- */
167
- function getMsgs(){
168
- global $wysija_msg;
169
-
170
- if(isset($wysija_msg['private']['error'])){
171
- $wysija_msg['error'][]=str_replace(array('[link]','[/link]'),array('<a class="showerrors" href="javascript:;">','</a>'),__('An error occured. [link]Show more details.[/link]',WYSIJA));
172
- }
173
-
174
- if(isset($wysija_msg['private']['updated'])){
175
- $wysija_msg['updated'][]=str_replace(array('[link]','[/link]'),array('<a class="shownotices" href="javascript:;">','</a>'),__('[link]Show more details.[/link]',WYSIJA));
176
- }
177
- if(isset($wysija_msg['private'])){
178
- $prv=$wysija_msg['private'];
179
- unset($wysija_msg['private']);
180
- if(isset($prv['error'])) $wysija_msg['xdetailed-errors']=$prv['error'];
181
- if(isset($prv['updated'])) $wysija_msg['xdetailed-updated']=$prv['updated'];
182
- }
183
- return $wysija_msg;
184
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
185
  }
186
 
187
 
188
  class WYSIJA_help extends WYSIJA_object{
189
- var $controller=null;
190
- function WYSIJA_help(){
191
-
192
- if(!defined('DOING_AJAX')){
193
- add_action('init', array($this, 'register_scripts'), 1);
194
- }
195
- add_action('widgets_init', array($this, 'widgets_init'), 1);
196
- }
197
-
198
- function widgets_init() {
199
- //load the widget file
200
- require_once(WYSIJA_WIDGETS.'wysija_nl.php');
201
- register_widget('WYSIJA_NL_Widget');
202
- }
203
-
204
- function register_scripts(){
205
- if(defined('WPLANG') && WPLANG!=''){
206
- $locale=explode('_',WPLANG);
207
- $wplang=$locale[0];
208
- }else{
209
- $wplang='en';
210
- }
211
-
212
- if(file_exists(WYSIJA_DIR.'js'.DS.'validate'.DS.'languages'.DS.'jquery.validationEngine-'.$wplang.'.js')){
213
- wp_register_script('wysija-validator-lang',WYSIJA_URL.'js/validate/languages/jquery.validationEngine-'.$wplang.'.js', array( 'jquery' ),WYSIJA::get_version(),true );
214
- }else{
215
- wp_register_script('wysija-validator-lang',WYSIJA_URL.'js/validate/languages/jquery.validationEngine-en.js', array( 'jquery' ),WYSIJA::get_version(),true );
216
- }
217
- wp_register_script('wysija-validator',WYSIJA_URL.'js/validate/jquery.validationEngine.js', array( 'jquery' ),WYSIJA::get_version(),true );
218
- wp_register_script('wysija-front-subscribers', WYSIJA_URL.'js/front-subscribers.js', array( 'jquery' ),WYSIJA::get_version(),true);
219
-
220
-
221
- wp_register_script('wysija-form', WYSIJA_URL.'js/forms.js', array( 'jquery' ),WYSIJA::get_version());
222
- wp_register_style('validate-engine-css',WYSIJA_URL.'css/validationEngine.jquery.css',array(),WYSIJA::get_version());
223
- wp_register_script('wysija-admin-ajax', WYSIJA_URL.'js/admin-ajax.js',array(),WYSIJA::get_version());
224
- wp_register_script('wysija-admin-ajax-proto', WYSIJA_URL.'js/admin-ajax-proto.js',array(),WYSIJA::get_version());
225
-
226
- if(defined('WYSIJA_SIDE') && WYSIJA_SIDE=='front') wp_enqueue_style('validate-engine-css');
227
-
228
- }
229
-
230
-
231
- /**
232
- * when doing an ajax request in admin this is the first place we come to
233
- */
234
- function ajax() {
235
-
236
- $resultArray=array();
237
- if(!$_REQUEST || !isset($_REQUEST['controller']) || !isset($_REQUEST['task'])){
238
- $resultArray=array('result'=>false);
239
- }else{
240
- $wysijapp='wysija-newsletters';
241
- if(isset($_REQUEST['wysijaplugin'])) $wysijapp=$_REQUEST['wysijaplugin'];
242
-
243
- $this->controller=WYSIJA::get($_REQUEST['controller'],'controller', false, $wysijapp);
244
-
245
- if(method_exists($this->controller, $_REQUEST['task'])){
246
- $resultArray['result']=$this->controller->$_REQUEST['task']();
247
- }else{
248
- $this->error('Method "'.$_REQUEST['task'].'" doesn\'t exist for controller : "'.$_REQUEST['controller']);
249
- }
250
- }
251
-
252
- $resultArray['msgs'] = $this->getMsgs();
253
-
254
- //this header will allow ajax request from the home domain, this can be a lifesaver when domain mapping is on
255
- if(function_exists('home_url')) header('Access-Control-Allow-Origin: '.home_url());
256
-
257
- header('Content-type: application/json');
258
- $jsonData = json_encode($resultArray);
259
-
260
- //in some case scenario our client will have jquery forcing the jsonp so we need to adapt ourselves
261
- if(isset($_REQUEST['callback'])) {
262
- $hJSONP = WYSIJA::get('jsonp', 'helper');
263
- if($hJSONP->isValidCallback($_REQUEST['callback'])) {
264
- print $_REQUEST['callback'] . '('.$jsonData.');';
265
- }
266
- } else {
267
- print $jsonData;
268
- }
269
- die();
270
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
271
  }
272
 
273
 
274
  class WYSIJA extends WYSIJA_object{
275
 
276
- function WYSIJA(){
277
-
278
- }
279
-
280
- /**
281
- * function created at the beginning to handle particular cases with WP get_permalink it got much smaller recently
282
- * @param int $pageid
283
- * @param array $params
284
- * @param boolean $simple
285
- * @return type
286
- */
287
- public static function get_permalink($pageid,$params=array(),$simple=false){
288
- $hWPtools=WYSIJA::get('wp_tools','helper');
289
- return $hWPtools->get_permalink($pageid,$params,$simple);
290
- }
291
-
292
- /**
293
- * translate the plugin
294
- * @staticvar boolean $extensionloaded
295
- * @param type $extendedplugin
296
- * @return boolean
297
- */
298
- public static function load_lang($extendedplugin=false){
299
- static $extensionloaded = false;
300
-
301
- //we return the entire array of extensions loaded if non is specified
302
- if(!$extendedplugin) return $extensionloaded;
303
-
304
- //we only need to load this translation loader once on init
305
- if(!$extensionloaded){
306
- add_action('init', array('WYSIJA','load_lang_init'));
307
- }
308
- //each plugin has a different name
309
- if ( !$extensionloaded || !isset($extensionloaded[$extendedplugin])) {
310
- $transstring = null;
311
- switch($extendedplugin){
312
- case 'wysija-newsletters':
313
- $transstring=WYSIJA;
314
- break;
315
- case 'wysijashop':
316
- $transstring=WYSIJASHOP;
317
- break;
318
- case 'wysijacrons':
319
- $transstring=WYSIJACRONS;
320
- break;
321
- case 'wysija-newsletters-premium':
322
- $transstring=WYSIJANLP;
323
- break;
324
- case 'get_all':
325
- return $extensionloaded;
326
- }
327
-
328
- //store all the required translations to be loaded in the static variable
329
- if($transstring !== null) {
330
- $extensionloaded[$extendedplugin] = $transstring;
331
- }
332
- }
333
- }
334
-
335
- /**
336
- * check if the user is tech support as this can be used to switch the language back to english when helping our customers
337
- * @global type $current_user
338
- * @param type $debugmode
339
- * @return type
340
- */
341
- public static function is_wysija_admin($debugmode=false){
342
- //to allow wysija team members to work in english mode if debug is activated
343
- global $current_user;
344
-
345
- if((int)$debugmode>0 && empty($current_user)) return true;
346
-
347
- if(isset($current_user->data->user_email) &&
348
- (strpos($current_user->data->user_email, '@wysija.com') !== false
349
- || strpos($current_user->data->user_email, '@bencaubere.com') !== false)) {
350
- return true;
351
- }
352
- return false;
353
- }
354
-
355
- /**
356
- * this function exists just to fix the issue with qtranslate :/ (it only fix it partially)
357
- * @param type $extendedplugin
358
- */
359
- public static function load_lang_init($extendedplugin=false){
360
- $config=WYSIJA::get('config','model');
361
- $debugmode=(int)$config->getValue('debug_new');
362
- if($debugmode==0 || ($debugmode>0 && !WYSIJA::is_wysija_admin($debugmode))){
363
- $extensionloaded=WYSIJA::load_lang('get_all');
364
- foreach($extensionloaded as $extendedplugin => $transstring){
365
- $filename=WYSIJA_PLG_DIR.$extendedplugin.DS.'languages'.DS.$transstring.'-'.get_locale().'.mo';
366
- if(file_exists($filename)) load_textdomain($transstring, $filename);
367
- }
368
- }
369
- }
370
-
371
- /**
372
- * function to generate objects of different types, managing file requiring in order to be the most efficient
373
- * @staticvar array $arrayOfObjects
374
- * @param string $name
375
- * @param string $type : in which folder do we go and pick the class
376
- * @param boolean $force_side : this parameter is almost never set to true,
377
- * it will be useful for instance if you want to get a back controller
378
- * from the frontend, it was used maybe in the shop but it can be ignored for wysija-newsletters
379
- * @param type $extended_plugin : used only when calling the url from a different plugin it is used watch those files :
380
- * -core/controller.php line 21, 23 ,24
381
- * @param type $load_lang : the load lang is in the get to be sure we don't forget to load the language file for each plugin at least once
382
- * the way I see it it could be moved to the index.php of each plugin. for now only wysija-newsletters is translated anyway
383
- * @return boolean
384
- */
385
- public static function get($name,$type,$force_side=false,$extended_plugin='wysija-newsletters',$load_lang=true){
386
- static $array_of_objects;
387
-
388
- if($load_lang) WYSIJA::load_lang($extended_plugin);
389
-
390
- // store all the objects made so that we can reuse them accross the application if the object is already set we return it immediately
391
- if(isset($array_of_objects[$extended_plugin][$type.$name])) {
392
- return $array_of_objects[$extended_plugin][$type.$name];
393
- }
394
-
395
- // which folder do we pick for controllersand views ? back or front ?
396
- if($force_side) {
397
- $side=$force_side;
398
- } else {
399
- $side=WYSIJA_SIDE;
400
- }
401
-
402
- // for each plugin we will define the $extended_constant variable if it's not defined already
403
- // also we will defined the $extended_plugin_name which corresponds to the folder name and also will be used to build the class to be called
404
- switch($extended_plugin){
405
- case 'wysija-newsletters-premium':
406
- $extended_constant='WYSIJANLP';
407
- if(!defined($extended_constant)) define($extended_constant,$extended_constant);
408
- $extended_plugin_name='wysijanlp';
409
- break;
410
- case 'wysija-newsletters':
411
- $extended_constant='WYSIJA';
412
- if(!defined($extended_constant)) define($extended_constant,$extended_constant);
413
- $extended_plugin_name='wysija';
414
- break;
415
- default :
416
- $extended_constant=strtoupper($extended_plugin);
417
- if(!defined($extended_constant)) define($extended_constant,$extended_constant);
418
- $extended_plugin_name=$extended_plugin;
419
- }
420
-
421
- // security to protect against dangerous ./../ includes
422
- $name = preg_replace('#[^a-z0-9_]#i','',$name);
423
-
424
- // this switch will require_once the file needed and build a the class name depending on the parameters passed to the function
425
- switch($type){
426
- case 'controller':
427
- // require the parent class necessary
428
- require_once(WYSIJA_CORE.'controller.php');
429
-
430
- $ctrdir=WYSIJA_PLG_DIR.$extended_plugin.DS.'controllers'.DS;
431
-
432
- // if we are doing ajax we don't go to one side, ajax is for frontend or backend in the same folder
433
- if(defined('DOING_AJAX')) {
434
- $class_path=$ctrdir.'ajax'.DS.$name.'.php';
435
- }else {
436
- // the other controllers are called in a side folder back or front
437
- $class_path=$ctrdir.$side.DS.$name.'.php';
438
- // require the side specific controller file
439
- require_once(WYSIJA_CTRL.$side.'.php');
440
- }
441
- $class_name = strtoupper($extended_plugin_name).'_control_'.$side.'_'.$name;
442
- break;
443
- case 'view':
444
- $viewdir=WYSIJA_PLG_DIR.$extended_plugin.DS.'views'.DS;
445
- // let's get the right path for the view front or back and the right class_name
446
- $class_path=$viewdir.$side.DS.$name.'.php';
447
- $class_name = strtoupper($extended_plugin_name).'_view_'.$side.'_'.$name;
448
-
449
- // require the common view file and the side view file
450
- require_once(WYSIJA_CORE.'view.php');
451
- require_once(WYSIJA_VIEWS.$side.'.php');
452
- break;
453
- case 'helper':
454
- $helpdir=WYSIJA_PLG_DIR.$extended_plugin.DS.'helpers'.DS;
455
- $class_path=$helpdir.$name.'.php';
456
- $class_name = strtoupper($extended_plugin_name).'_help_'.$name;
457
-
458
- break;
459
- case 'model':
460
- $modeldir=WYSIJA_PLG_DIR.$extended_plugin.DS.'models'.DS;
461
- $class_path=$modeldir.$name.'.php';
462
- $class_name = strtoupper($extended_plugin_name).'_model_'.$name;
463
- // require the parent class necessary
464
- require_once(WYSIJA_CORE.'model.php');
465
- break;
466
- case 'widget':
467
- $modeldir=WYSIJA_PLG_DIR.$extended_plugin.DS.'widgets'.DS;
468
- $class_path=$modeldir.$name.'.php';
469
- if($name=='wysija_nl') $class_name='WYSIJA_NL_Widget';
470
- else $class_name = strtoupper($extended_plugin_name).'_widget_'.$name;
471
- break;
472
- default:
473
- WYSIJA::setInfo('error','WYSIJA::get does not accept this type of file "'.$type.'" .');
474
- return false;
475
- }
476
-
477
- if(!file_exists($class_path)) {
478
- WYSIJA::setInfo('error','file has not been recognised '.$class_path);
479
- return;
480
- }
481
-
482
- // require the file needed once and store & return the object needed
483
- require_once($class_path);
484
- return $array_of_objects[$extended_plugin][$type.$name]=new $class_name($extended_plugin_name);
485
-
486
- }
487
-
488
- /**
489
- * log function to spot some strange issues when sending emails for instance
490
- * @param type $key
491
- * @param type $data
492
- * @param type $category
493
- * @return type
494
- */
495
- public static function log($key='default',$data='empty',$category='default'){
496
- $config=WYSIJA::get('config','model');
497
-
498
- if(defined('WYSIJA_DBG') && WYSIJA_DBG>1 && $category && (int)$config->getValue('debug_log_'.$category)>0){
499
-
500
- $optionlog=get_option('wysija_log');
501
- if ( false === $optionlog ){
502
- add_option( 'wysija_log', array() ,'','no');
503
- $optionlog=array();
504
- }
505
-
506
- $optionlog[$category][(string)microtime(true)][$key]=$data;
507
- update_option('wysija_log', $optionlog);
508
- }
509
- return false;
510
- }
511
-
512
- /**
513
- * the filter to add option to the cron frequency instead of being stuck with hourly, daily and twicedaily...
514
- * we can add filters but we cannot delete other values such as the default ones, as this might break other plugins crons
515
- * @param type $param
516
- * @return type
517
- */
518
- public static function filter_cron_schedules( $param ) {
519
- $frequencies=array(
520
- 'one_min' => array(
521
- 'interval' => 60,
522
- 'display' => __( 'Once every minutes',WYSIJA)
523
- ),
524
- 'two_min' => array(
525
- 'interval' => 120,
526
- 'display' => __( 'Once every two minutes',WYSIJA)
527
- ),
528
- 'five_min' => array(
529
- 'interval' => 300,
530
- 'display' => __( 'Once every five minutes',WYSIJA)
531
- ),
532
- 'ten_min' => array(
533
- 'interval' => 600,
534
- 'display' => __( 'Once every ten minutes',WYSIJA)
535
- ),
536
- 'fifteen_min' => array(
537
- 'interval' => 900,
538
- 'display' => __( 'Once every fifteen minutes',WYSIJA)
539
- ),
540
- 'thirty_min' => array(
541
- 'interval' => 1800,
542
- 'display' => __( 'Once every thirty minutes',WYSIJA)
543
- ),
544
- 'two_hours' => array(
545
- 'interval' => 7200,
546
- 'display' => __( 'Once every two hours',WYSIJA)
547
- ),
548
- 'eachweek' => array(
549
- 'interval' => 604800,
550
- 'display' => __( 'Once a week',WYSIJA)
551
- ),
552
- 'each28days' => array(
553
- 'interval' => 2419200,
554
- 'display' => __( 'Once every 28 days',WYSIJA)
555
- ),
556
- );
557
-
558
- return array_merge($param, $frequencies);
559
- }
560
-
561
- /**
562
- * scheduled task for sending the emails in the queue, the frequency is set in the settings
563
- */
564
- public static function croned_queue() {
565
- //create the automatic post notifications email if there is any
566
- $autoNL=WYSIJA::get('autonews','helper');
567
- $autoNL->checkPostNotif();
568
-
569
- //queue the scheduled newsletter also if there are any
570
- $autoNL->checkScheduled();
571
- $config=WYSIJA::get('config','model');
572
- if((int)$config->getValue('total_subscribers')<2000 ){
573
- $helperQ=WYSIJA::get('queue','helper');
574
- $helperQ->report=false;
575
- WYSIJA::log('croned_queue process',true,'cron');
576
- $helperQ->process();
577
- }
578
- }
579
-
580
-
581
- /**
582
- * everyday we make sure not to leave any trash files
583
- * remove temporary files
584
- */
585
- public static function croned_daily() {
586
-
587
- @ini_set('max_execution_time',0);
588
-
589
- /*user refresh count total*/
590
- $helper_user = WYSIJA::get('user','helper');
591
- $helper_user->refreshUsers();
592
-
593
- /*clear temporary folders*/
594
- $helper_file = WYSIJA::get('file','helper');
595
- $helper_file->clear();
596
-
597
- /*clear queue from unsubscribed*/
598
- $helper_queue = WYSIJA::get('queue','helper');
599
- $helper_queue->clear();
600
-
601
- $model_config = WYSIJA::get('config','model');
602
-
603
- /* send daily report about emails sent */
604
- if($model_config->getValue('emails_notified_when_dailysummary')){
605
- $helper_stats = WYSIJA::get('stats','helper');
606
- $helper_stats->sendDailyReport();
607
- }
608
-
609
- }
610
-
611
- // Weekly cron
612
- public static function croned_weekly() {
613
-
614
- @ini_set('max_execution_time',0);
615
-
616
- $model_config = WYSIJA::get('config','model');
617
-
618
- // If enabled, flag MixPanel sending on next page load.
619
- if ($model_config->getValue('analytics') == 1) {
620
- $model_config->save(array('send_analytics_now' => 1));
621
- }
622
-
623
- }
624
-
625
- // Monthly cron
626
- public static function croned_monthly() {
627
-
628
- @ini_set('max_execution_time',0);
629
-
630
- $model_config = WYSIJA::get('config','model');
631
-
632
- /* send daily report about emails sent */
633
- if ($model_config->getValue('sharedata')) {
634
- $helper_stats = WYSIJA::get('stats','helper');
635
- $helper_stats->share();
636
- }
637
-
638
- }
639
-
640
- /**
641
- * when we deactivate the plugin we clear the WP install from those cron records
642
- */
643
- public static function deactivate() {
644
- wp_clear_scheduled_hook('wysija_cron_queue');
645
- wp_clear_scheduled_hook('wysija_cron_bounce');
646
- wp_clear_scheduled_hook('wysija_cron_daily');
647
- wp_clear_scheduled_hook('wysija_cron_weekly');
648
- wp_clear_scheduled_hook('wysija_cron_monthly');
649
- }
650
-
651
-
652
- /**
653
- * wysija's redirect allows to save some variables for the next page load such as notices etc..
654
- * @global type $wysija_msg
655
- * @global type $wysija_queries
656
- * @global type $wysija_queries_errors
657
- * @param type $redirectTo
658
- */
659
- public static function redirect($redirectTo){
660
- //save the messages
661
- global $wysija_msg,$wysija_queries,$wysija_queries_errors;
662
- WYSIJA::update_option('wysija_msg',$wysija_msg);
663
- WYSIJA::update_option('wysija_queries',$wysija_queries);
664
- WYSIJA::update_option('wysija_queries_errors',$wysija_queries_errors);
665
- wp_redirect($redirectTo);
666
- exit;
667
- }
668
-
669
- /**
670
- * custom post type for wysija is call wysijap as in wysija's post
671
- */
672
- public static function create_post_type() {
673
-
674
- //by default there is url rewriteing on wysijap custom post, though in one client case I had to deactivate it.
675
- //as this is rare we just need to set this setting to activate it
676
- //by default let's deactivate the url rewriting of the wysijap confirmation page because it is breaking in some case.
677
- $show_interface=false;
678
- if(defined('WYSIJA_DBG') && WYSIJA_DBG>1) $show_interface=true;
679
- register_post_type( 'wysijap',
680
- array(
681
- 'labels' => array(
682
- 'name' => __('Wysija page'),
683
- 'singular_name' => __('Wysija page')
684
- ),
685
- 'public' => true,
686
- 'has_archive' => false,
687
- 'show_ui' =>$show_interface,
688
- 'show_in_menu' =>$show_interface,
689
- 'rewrite' => false,
690
- 'show_in_nav_menus'=>false,
691
- 'can_export'=>false,
692
- 'publicly_queryable'=>true,
693
- 'exclude_from_search'=>true,
694
- )
695
- );
696
-
697
- if(!get_option('wysija_post_type_updated')) {
698
- $modelPosts=new WYSIJA_model();
699
- $modelPosts->tableWP=true;
700
- $modelPosts->table_prefix='';
701
- $modelPosts->table_name='posts';
702
- $modelPosts->noCheck=true;
703
- $modelPosts->pk='ID';
704
- if($modelPosts->exists(array('post_type'=>'wysijapage'))){
705
- $modelPosts->update(array('post_type'=>'wysijap'),array('post_type'=>'wysijapage'));
706
- flush_rewrite_rules( false );
707
- }
708
- WYSIJA::update_option('wysija_post_type_updated',time());
709
- }
710
-
711
- if(!get_option('wysija_post_type_created')) {
712
- flush_rewrite_rules( false );
713
- WYSIJA::update_option('wysija_post_type_created',time());
714
- }
715
-
716
- }
717
-
718
- /**
719
- * wysija update_option function is very similar to WordPress' one but it
720
- * can also manage new options not automatically loaded each time
721
- * @param type $option_name
722
- * @param type $newvalue
723
- * @param type $defaultload this parameter is the advantage other Wp's update_option here
724
- */
725
- public static function update_option($option_name,$newvalue,$defaultload='no'){
726
- if ( get_option( $option_name ) != $newvalue ) {
727
- update_option( $option_name, $newvalue );
728
- } else {
729
- add_option( $option_name, $newvalue, '', $defaultload );
730
- }
731
- }
732
-
733
- /**
734
- * When a WordPress user is added we also need to add it to the subscribers list
735
- * @param type $user_id
736
- * @return type
737
- */
738
- public static function hook_add_WP_subscriber($user_id) {
739
- $data=get_userdata($user_id);
740
-
741
-
742
- //check first if a subscribers exists if it doesn't then let's insert it
743
- $model_config=WYSIJA::get('config','model');
744
- $model_user=WYSIJA::get('user','model');
745
- $model_user->getFormat=ARRAY_A; // there is one case where we were getting an object instead of an array
746
- $subscriber_exists=$model_user->getOne(array('user_id'),array('email'=>$data->user_email));
747
-
748
- $first_name=$data->first_name;
749
- $last_name=$data->last_name;
750
- if(!$data->first_name && !$data->last_name) $first_name=$data->display_name;
751
-
752
- $model_user->reset();
753
- if($subscriber_exists){
754
- $user_id=$subscriber_exists['user_id'];
755
- // we need to update the current subscriber using it's id
756
- $model_user->update(array('wpuser_id'=>$data->ID,'firstname'=>$first_name,'lastname'=>$last_name),array('user_id'=>$user_id));
757
- }else{
758
- $model_user->noCheck=true;
759
- $user_id=$model_user->insert(array('email'=>$data->user_email,'wpuser_id'=>$data->ID,'firstname'=>$first_name,'lastname'=>$last_name,'status'=>$model_config->getValue('confirm_dbleoptin')));
760
- }
761
-
762
- $model_user_list=WYSIJA::get('user_list','model');
763
- $model_user_list->insert(array('user_id'=>$user_id,'list_id'=>$model_config->getValue('importwp_list_id'),'sub_date'=>time()),true);
764
-
765
- $helper_user=WYSIJA::get('user','helper');
766
- $helper_user->sendAutoNl($user_id,$data,'new-user');
767
- return true;
768
- }
769
-
770
- /**
771
- * when a WordPress user is updated we also need to update the corresponding subscriber
772
- * @param type $user_id
773
- * @return type
774
- */
775
- public static function hook_edit_WP_subscriber($user_id) {
776
- $data=get_userdata($user_id);
777
-
778
- //check first if a subscribers exists if it doesn't then let's insert it
779
- $model_user=WYSIJA::get('user','model');
780
- $model_config=WYSIJA::get('config','model');
781
- $model_user_list=WYSIJA::get('user_list','model');
782
-
783
- $subscriber_exists=$model_user->getOne(array('user_id'),array('email'=>$data->user_email));
784
-
785
- $model_user->reset();
786
-
787
- $first_name=$data->first_name;
788
- $last_name=$data->last_name;
789
- if(!$data->first_name && !$data->last_name) $first_name=$data->display_name;
790
-
791
- if($subscriber_exists){
792
- $user_id=$subscriber_exists['user_id'];
793
-
794
- $model_user->update(array('wpuser_id'=>$data->ID, 'email'=>$data->user_email,'firstname'=>$first_name,'lastname'=>$last_name),array('user_id'=>$user_id));
795
-
796
- $result=$model_user_list->getOne(false,array('user_id'=>$user_id,'list_id'=>$model_config->getValue('importwp_list_id')));
797
- $model_user_list->reset();
798
- if(!$result)
799
- $model_user_list->insert(array('user_id'=>$user_id,'list_id'=>$model_config->getValue('importwp_list_id'),'sub_date'=>time()));
800
- }else{
801
- //chck that we didnt update the email
802
- $subscriber_exists=$model_user->getOne(false,array('wpuser_id'=>$data->ID));
803
-
804
- if($subscriber_exists){
805
- $user_id=$subscriber_exists['user_id'];
806
-
807
- $model_user->update(array('email'=>$data->user_email,'firstname'=>$first_name,'lastname'=>$last_name),array('wpuser_id'=>$data->ID));
808
-
809
- $result=$model_user_list->getOne(false,array('user_id'=>$user_id,'list_id'=>$model_config->getValue('importwp_list_id')));
810
- $model_user_list->reset();
811
- if(!$result)
812
- $model_user_list->insert(array('user_id'=>$user_id,'list_id'=>$model_config->getValue('importwp_list_id'),'sub_date'=>time()));
813
- }else{
814
- $model_user->noCheck=true;
815
- $user_id=$model_user->insert(array('email'=>$data->user_email,'wpuser_id'=>$data->ID,'firstname'=>$first_name,'lastname'=>$last_name,'status'=>$model_config->getValue('confirm_dbleoptin')));
816
- $model_user_list->insert(array('user_id'=>$user_id,'list_id'=>$model_config->getValue('importwp_list_id'),'sub_date'=>time()));
817
- }
818
- }
819
- return true;
820
- }
821
-
822
- /**
823
- * when a wp user is deleted we also delete the subscriber corresponding to it
824
- * @param type $user_id
825
- */
826
- public static function hook_del_WP_subscriber($user_id) {
827
- $model_config=WYSIJA::get('config','model');
828
- $model_user=WYSIJA::get('user','model');
829
- $data = $model_user->getOne(array('email','user_id'),array('wpuser_id'=>$user_id));
830
- $model_user->delete(array('email'=>$data['email']));
831
- $model_user=WYSIJA::get('user_list','model');
832
- $model_user->delete(array('user_id'=>$data['user_id'],'list_id'=>$model_config->getValue('importwp_list_id')));
833
- }
834
-
835
- /**
836
- * post notification transition hook, know when a post really gets published
837
- * @param type $new_status
838
- * @param type $old_status
839
- * @param type $post
840
- * @return type
841
- */
842
- public static function hook_postNotification_transition($new_status, $old_status, $post) {
843
- //we run some process only if the status of the post changes from something to publish
844
- if( $new_status=='publish' && $old_status!=$new_status){
845
- $model_email = WYSIJA::get('email', 'model');
846
- $emails = $model_email->get(false, array('type' => 2, 'status' => array(1, 3, 99)));
847
- if(!empty($emails)){
848
- //we loop through all of the automatic emails
849
- foreach($emails as $key => $email) {
850
- //we will try to give birth to a child email only if the automatic newsletter is a post notification email and in immediate mode
851
- if(is_array($email) && $email['params']['autonl']['event'] === 'new-articles' && $email['params']['autonl']['when-article'] === 'immediate') {
852
- WYSIJA::log('post_transition_hook_give_birth',array('postID'=>$post->ID,'postID'=>$post->post_title,'old_status'=>$old_status,'new_status'=>$new_status),'post_notif');
853
- $model_email->reset();
854
- $model_email->give_birth($email, $post->ID);
855
- }
856
- }
857
- }
858
- }
859
-
860
- return true;
861
- }
862
-
863
- /**
864
- * uninstall process not used
865
- */
866
- public static function uninstall(){
867
- $helperUS=WYSIJA::get('uninstall','helper');
868
- $helperUS->uninstall();
869
- }
870
-
871
- /**
872
- * this function is run when wysija gets activated
873
- * there is no installation process here, all is about checking the global status of the app
874
- */
875
- public static function activate(){
876
- $encoded_option=get_option('wysija');
877
- $installApp=false;
878
- if($encoded_option){
879
- $values=unserialize(base64_decode($encoded_option));
880
- if(isset($values['installed'])) $installApp=true;
881
- }
882
-
883
- //test again for plugins on reactivation
884
- if($installApp){
885
- $helper_import=WYSIJA::get('import','helper');
886
- $helper_import->testPlugins();
887
-
888
- //resynch wordpress list
889
- $helper_user=WYSIJA::get('user','helper');
890
- $helper_user->synchList($values['importwp_list_id']);
891
- }
892
- }
893
-
894
- /**
895
- * the is_plugin_active functions from WordPress sometimes are not loaded so here is one that works for single and multisites anywhere in the code
896
- * @param type $pluginName
897
- * @return type
898
- */
899
- public static function is_plugin_active($pluginName){
900
- $arrayactiveplugins=get_option('active_plugins');
901
- //we check in the list of the site options if the plugin is activated
902
- if(in_array($pluginName, $arrayactiveplugins)) {
903
- //plugin is activated for that site
904
- return true;
905
- }
906
-
907
- //if this is a multisite it might not be activated in the site option but network activated though
908
- if(is_multisite()){
909
- $plugins = get_site_option('active_sitewide_plugins');
910
- //plugin is activated for that multisite
911
- if(isset($plugins[$pluginName])){
912
- return true;
913
- }
914
- }
915
- return false;
916
- }
917
-
918
- /**
919
- * make sure that the current user has the good access rights corresponding to its role
920
- * @global type $current_user
921
- * @return type
922
- */
923
- public static function update_user_caps(){
924
- global $current_user;
925
-
926
- if(empty($current_user)) get_currentuserinfo();
927
- if(empty($current_user)) return false;
928
- $current_user->get_role_caps();
929
-
930
- return true;
931
- }
932
-
933
- /**
934
- * test whether the plugin is a beta version or not
935
- * 2.4.4.4 is a beta
936
- * 2.4.4 is a bug fix release
937
- * 2.4 is a feature release
938
- * @param string $plugin_name
939
- */
940
- public static function is_beta($plugin_name=false){
941
- if(count(explode('.', WYSIJA::get_version($plugin_name))) > 3 ) return true;
942
- return false;
943
- }
944
-
945
- /**
946
- * depending where it's used the base function from WordPress doesn't work, so this one will work anywhere
947
- * @param type $capability
948
- * @return type
949
- */
950
- public static function current_user_can($capability){
951
- if(!$capability) return false;
952
- WYSIJA::update_user_caps();
953
- if(!current_user_can($capability)) return false;
954
- return true;
955
- }
956
-
957
- /**
958
- * this function get and sets the cron schedules when Wysija's own cron system is active
959
- * @staticvar type $cron_schedules
960
- * @param type $schedule
961
- * @return type
962
- */
963
- public static function get_cron_schedule($schedule='queue'){
964
- static $cron_schedules;
965
-
966
- //if the cron schedules are already loaded statically then we just have to return the right schedule value
967
- if(!empty($cron_schedules)){
968
- if($schedule=='all') return $cron_schedules;
969
- if(isset($cron_schedules[$schedule])) {
970
- return $cron_schedules[$schedule];
971
- }else{
972
- WYSIJA::set_cron_schedule($schedule);
973
- return false;
974
- }
975
- }else{
976
- //this is the first time this function is executed so let's get them from the db and store them statically
977
- $cron_schedules=get_option('wysija_schedules',array());
978
- if(!empty($cron_schedules)){
979
- if(isset($cron_schedules[$schedule])) return $cron_schedules[$schedule];
980
- else return false;
981
- }else{
982
- WYSIJA::set_cron_schedule();
983
- return false;
984
- }
985
- }
986
- return false;
987
- }
988
-
989
- /**
990
- * return the frequency for each cron task needed by wysija
991
- * @return type an array of frequencies
992
- */
993
- public static function get_cron_frequencies(){
994
- $mConfig=WYSIJA::get('config','model');
995
- $fHelper=WYSIJA::get('forms','helper');
996
-
997
- if(is_multisite() && $mConfig->getValue('sending_method')=='network'){
998
- $sending_emails_each=$mConfig->getValue('ms_sending_emails_each');
999
- }else{
1000
- $sending_emails_each=$mConfig->getValue('sending_emails_each');
1001
- }
1002
-
1003
- $queue_frequency=$fHelper->eachValuesSec[$sending_emails_each];
1004
- $bounce_frequency=99999999999999;
1005
- if(isset($fHelper->eachValuesSec[$mConfig->getValue('bouncing_emails_each')])) $bounce_frequency=$fHelper->eachValuesSec[$mConfig->getValue('bouncing_emails_each')];
1006
- return array('queue'=>$queue_frequency,'bounce'=>$bounce_frequency,'daily'=>86400,'weekly'=>604800,'monthly'=>2419200);
1007
- }
1008
-
1009
- /**
1010
- * set the next cron schedule
1011
- * TODO : needs probably to make the difference of running process for the next schedule, so that there is no delay(this is only problematic on some slow servers)
1012
- * @param string $schedule
1013
- * @param int $lastsaved
1014
- * @param boolean $set_running
1015
- * @return boolean
1016
- */
1017
- public static function set_cron_schedule($schedule=false,$lastsaved=0,$set_running=false){
1018
- $cron_schedules=array();
1019
-
1020
- $start_time=$lastsaved;
1021
- if(!$start_time) $start_time=time();
1022
- $processes=WYSIJA::get_cron_frequencies();
1023
- if(!$schedule){
1024
- foreach($processes as $process => $frequency){
1025
- $next_schedule=$start_time+$frequency;
1026
- $prev_schedule=0;
1027
- if(isset($cron_schedules[$process]['running']) && $cron_schedules[$process]['running']) $prev_schedule=$cron_schedules[$process]['running'];
1028
- $cron_schedules[$process]=array(
1029
- 'next_schedule'=>$next_schedule,
1030
- 'prev_schedule'=>$prev_schedule,
1031
- 'running'=>false);
1032
- }
1033
- }else{
1034
- $cron_schedules=WYSIJA::get_cron_schedule('all');
1035
- if($set_running){
1036
- $cron_schedules[$schedule]['running']=$set_running;
1037
- }else{
1038
- $running=0;
1039
- if(isset($cron_schedules[$schedule]['running'])) $running=$cron_schedules[$schedule]['running'];
1040
- //if the process is not running or has been running for more than 15 minutes then we set the next_schedule date
1041
- if(!$running || time()>$running+900){
1042
- $next_schedule=$start_time+$processes[$schedule];
1043
- $cron_schedules[$schedule]=array(
1044
- 'next_schedule'=>$next_schedule,
1045
- 'prev_schedule'=>$running,
1046
- 'running'=>false);
1047
- }
1048
- }
1049
- }
1050
- WYSIJA::update_option('wysija_schedules',$cron_schedules,'yes');
1051
- return true;
1052
- }
1053
-
1054
- /**
1055
- * check that there is no passed schedules that need to be executed now
1056
- * @return void
1057
- */
1058
- public static function cron_check() {
1059
-
1060
- $cron_schedules=WYSIJA::get_cron_schedule('all');
1061
- if(empty($cron_schedules)) return;
1062
- else{
1063
- $processes=WYSIJA::get_cron_frequencies();
1064
- $updatedsched=false;
1065
- foreach($cron_schedules as $proc => &$params){
1066
- $running=0;
1067
- if(isset($params['running'])) $running=$params['running'];
1068
- //if the process has timedout we reschedule the next execution
1069
- if($running && time()>$running+900){
1070
- //WYSIJA::setInfo('error','modifying next schedule for '.$proc);
1071
- $next_schedule=time()+$processes[$proc];
1072
- $params=array(
1073
- 'next_schedule'=>$next_schedule,
1074
- 'prev_schedule'=>$running,
1075
- 'running'=>false);
1076
- $updatedsched=true;
1077
- }
1078
- }
1079
- if($updatedsched){
1080
- //WYSIJA::setInfo('error','updating scheds');
1081
- WYSIJA::update_option('wysija_schedules',$cron_schedules,'yes');
1082
- }
1083
-
1084
- }
1085
-
1086
- $timenow=time();
1087
- $processesToRun=array();
1088
- foreach($cron_schedules as $process =>$scheduled_times){
1089
- if((!$scheduled_times['running'] || (int)$scheduled_times['running']+900<$timenow) && $scheduled_times['next_schedule']<$timenow){
1090
- $processesToRun[]=$process;
1091
- }
1092
- }
1093
-
1094
- $model_config=WYSIJA::get('config','model');
1095
- $page_view_trigger=(int)$model_config->getValue('cron_page_hit_trigger');
1096
- if(!empty($processesToRun) && $page_view_trigger===1){
1097
- //call the cron url
1098
-
1099
- $cron_url=site_url( 'wp-cron.php').'?'.WYSIJA_CRON.'&action=wysija_cron&process='.implode(',',$processesToRun).'&silent=1';
1100
- $cron_request = apply_filters( 'cron_request', array(
1101
- 'url' => $cron_url,
1102
- 'args' => array( 'timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters( 'https_local_ssl_verify', true ) )
1103
- ) );
1104
-
1105
- wp_remote_post( $cron_url, $cron_request['args'] );
1106
- //TODO we should use the http class there
1107
- //$hHTTP=WYSIJA::get('http','helper');
1108
- //$hHTTP->request_timeout($cron_url);
1109
-
1110
- }
1111
- }
1112
-
1113
- /**
1114
- * Function somehow necessary to avoid some conflicts in windows server and WordPress autoload of plugins language file
1115
- * @param type $boolean
1116
- * @param type $domain
1117
- * @param type $mofile
1118
- * @return boolean
1119
- */
1120
- public static function override_load_textdomain($boolean, $domain, $mofile){
1121
- $extensionloaded=WYSIJA::load_lang('get_all');
1122
-
1123
- if(isset($extensionloaded[$domain]) && !@file_exists($mofile)){
1124
- return true;
1125
- }
1126
-
1127
- return false;
1128
- }
1129
-
1130
- /**
1131
- * function to rewrite the path of the file if the file doesn't exist
1132
- * @param type $mofile
1133
- * @param type $domain
1134
- * @return type
1135
- */
1136
- public static function load_textdomain_mofile($mofile, $domain){
1137
- $extensionloaded=WYSIJA::load_lang('get_all');
1138
-
1139
- if(isset($extensionloaded[$domain]) && !file_exists($mofile)){
1140
- return WYSIJA_PLG_DIR.$domain.DS.'languages'.DS.$extensionloaded[$domain].'-'.get_locale().'.mo';
1141
- }
1142
- return $mofile;
1143
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1144
  }
1145
 
1146
  // subscribers/wp-user synch hooks
@@ -1151,134 +1432,141 @@ add_action('profile_update', array('WYSIJA', 'hook_edit_WP_subscriber'), 1);
1151
  add_action('delete_user', array('WYSIJA', 'hook_del_WP_subscriber'), 1);
1152
  // for multisite
1153
  add_action('deleted_user', array('WYSIJA', 'hook_del_WP_subscriber'), 1);
 
1154
 
 
 
1155
 
1156
  // post notif trigger
1157
  add_action('transition_post_status', array('WYSIJA', 'hook_postNotification_transition'), 1, 3);
 
 
 
1158
 
1159
  // add image size for emails
1160
- add_image_size( 'wysija-newsletters-max', 600, 99999 );
1161
 
1162
  $modelConf=WYSIJA::get('config','model');
1163
  if($modelConf->getValue('installed_time')){
1164
 
1165
- // START all that concerns the CRON
1166
- // make sure we check when is the schedule due with wysija's cron
1167
- if($modelConf->getValue('cron_manual')){
1168
- // if WP cron tasks are still set, we clear them
1169
- if(wp_get_schedule('wysija_cron_queue')) WYSIJA::deactivate();
1170
-
1171
- // set the crons schedule for each process
1172
- WYSIJA::get_cron_schedule();
1173
-
1174
- // check that there is no late cron schedules if we are using wysija's cron option and that the cron option is triggerred by any page view
1175
- if(!isset($_REQUEST['process'])){
1176
- WYSIJA::cron_check();
1177
- }
1178
-
1179
- // this action is triggerred only by a cron job
1180
- // if we're entering the wysija's cron part, it should end here
1181
- if(isset($_REQUEST['action']) && $_REQUEST['action']=='wysija_cron'){
1182
- add_action('init', 'init_wysija_cron',1);
1183
-
1184
- function init_wysija_cron(){
1185
- $hCron=WYSIJA::get('cron','helper');
1186
- $hCron->run();
1187
- }
1188
- }
1189
-
1190
- // make sure the scheduled tasks are recorded when using WordPress' cron
1191
- }else{
1192
-
1193
- // filter to add new possible frequencies to the cron
1194
- add_filter( 'cron_schedules', array( 'WYSIJA', 'filter_cron_schedules' ) );
1195
-
1196
- // action to handle the scheduled tasks in wysija
1197
- add_action( 'wysija_cron_queue', array( 'WYSIJA', 'croned_queue' ) );
1198
- add_action( 'wysija_cron_daily', array( 'WYSIJA', 'croned_daily' ) );
1199
- add_action( 'wysija_cron_weekly', array( 'WYSIJA', 'croned_weekly' ) );
1200
- add_action( 'wysija_cron_monthly', array( 'WYSIJA', 'croned_monthly' ) );
1201
-
1202
- // same with the weekly task
1203
- if(!wp_next_scheduled('wysija_cron_weekly')){
1204
- wp_schedule_event( $modelConf->getValue('last_save') , 'eachweek', 'wysija_cron_weekly' );
1205
- }
1206
- // the monthly task...
1207
- if(!wp_next_scheduled('wysija_cron_monthly')){
1208
- wp_schedule_event( $modelConf->getValue('last_save') , 'each28days', 'wysija_cron_monthly' );
1209
- }
1210
-
1211
- // the daily task...
1212
- if(!wp_next_scheduled('wysija_cron_daily')){
1213
- wp_schedule_event( $modelConf->getValue('last_save') , 'daily', 'wysija_cron_daily' );
1214
- }
1215
-
1216
-
1217
- if(is_multisite()){
1218
-
1219
- // in the case of multisite and the network's method we schedule with a different frequency
1220
- // this option contains the list of sites already scheduled
1221
- $ms_wysija_bounce_cron = get_site_option('ms_wysija_bounce_cron');
1222
- global $blog_id;
1223
-
1224
- // if this blog is not recorded in our wysija_sending_cron option then we clear its scheduled so that we can reinitialize it
1225
- if(!$ms_wysija_bounce_cron || !isset($ms_wysija_bounce_cron[$blog_id])){
1226
- wp_clear_scheduled_hook('wysija_cron_bounce');
1227
- WYSIJA::set_cron_schedule('queue');
1228
- $ms_wysija_bounce_cron[$blog_id] = 1;
1229
- update_site_option('ms_wysija_bounce_cron',$ms_wysija_bounce_cron);
1230
- }
1231
-
1232
- }
1233
-
1234
- // if the bounce task is not scheduled then we initialize it
1235
- if(!wp_next_scheduled('wysija_cron_bounce')){
1236
- wp_schedule_event( $modelConf->getValue('last_save') , $modelConf->getValue('bouncing_emails_each'), 'wysija_cron_bounce' );
1237
- }
1238
-
1239
- // and the queue processing task ...
1240
- // if we are in a multisite case we make sure that the ms frequency hasn't been changed, if it has we reset it
1241
- if(is_multisite() && $modelConf->getValue('sending_method')=='network'){
1242
- // in the case of multisite and the network's method we schedule with a different frequency
1243
- // this option contains the list of sites already scheduled
1244
- $ms_wysija_sending_cron=get_site_option('ms_wysija_sending_cron');
1245
- global $blog_id;
1246
-
1247
- // if this blog is not recorded in our wysija_sending_cron option then we clear its scheduled so that we can reinitialize it
1248
- if(!$ms_wysija_sending_cron || !isset($ms_wysija_sending_cron[$blog_id])){
1249
- wp_clear_scheduled_hook('wysija_cron_queue');
1250
- WYSIJA::set_cron_schedule('queue');
1251
- $ms_wysija_sending_cron[$blog_id]=1;
1252
- update_site_option('ms_wysija_sending_cron',$ms_wysija_sending_cron);
1253
- }
1254
- }
1255
-
1256
-
1257
- // simply schedule the queue
1258
- if(!wp_next_scheduled('wysija_cron_queue')){
1259
-
1260
- // in the case of multisite and the network's method we schedule with a different frequency
1261
- if(is_multisite() && $modelConf->getValue('sending_method')=='network'){
1262
- $sending_emails_each=$modelConf->getValue('ms_sending_emails_each');
1263
- }else{
1264
- $sending_emails_each=$modelConf->getValue('sending_emails_each');
1265
- }
1266
- wp_schedule_event( $modelConf->getValue('last_save') , $sending_emails_each, 'wysija_cron_queue' );
1267
- }
1268
-
1269
- }// END all that concerns the CRON
1270
-
1271
- // filter fixing a bug with automatic load_text_domain_from WP didn't understand yet why this was necessary...
1272
- // somehow wp_register_script(which is irrelevant) was triggerring this kind of notice
1273
- // Warning: is_readable() [function.is-readable]: open_basedir restriction in effect. File(C:\Domains\website.com\wwwroot\web/wp-content/plugins/C:\Domains\website.com\wwwroot\web\wp-content\plugins\wysija-newsletters/languages/wysija-newsletters-en_US.mo) is not within the allowed path(s): (.;C:\Domains\;C:\PHP\;C:\Sites\;C:\SitesData\;/) in C:\Domains\website.com\wwwroot\web\wp-includes\l10n.php on line 339
1274
- // the only solution is to make sure on our end that the file exists and rewrite it if necessary
1275
- add_filter( 'override_load_textdomain', array( 'WYSIJA', 'override_load_textdomain' ), 10, 3);
1276
- add_filter('load_textdomain_mofile', array( 'WYSIJA', 'load_textdomain_mofile' ), 10, 2);
 
1277
  }
1278
 
1279
  // not yet used but the purpose is to override any notification sent through wp_mail
1280
  if($modelConf->getValue('wp_notifications')){
1281
- $hWPnotif=WYSIJA::get('wp_notifications','helper');
1282
  }
1283
 
1284
  register_deactivation_hook(WYSIJA_FILE, array( 'WYSIJA', 'deactivate' ));
@@ -1287,4 +1575,4 @@ add_action( 'init', array('WYSIJA','create_post_type') );
1287
 
1288
 
1289
  // launch application
1290
- $helper=WYSIJA::get(WYSIJA_SIDE,'helper');
1
  <?php
2
  // Require constants.
3
+ require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'constants.php' );
4
+
5
  // Require global classes autoloader
6
+ require_once( dirname( __FILE__ ) . DIRECTORY_SEPARATOR . 'autoloader.php' );
7
+
8
+ defined( 'WYSIJA' ) or die( 'Restricted access' );
9
+
10
+ global $wysija_msg, $wysija_wpmsg;
11
+ if ( ! $wysija_msg ) {
12
+ $wysija_msg = array();
13
+ }
14
+ $wysija_wpmsg = array();
15
 
 
 
 
 
 
16
  class WYSIJA_object{
17
 
18
+ /**
19
+ * Static variable holding core MailPoet's version
20
+ * @var array
21
+ */
22
+ static $version = '2.6.9';
23
+
24
+ function WYSIJA_object(){
25
+
26
+ }
27
+
28
+ /**
29
+ * Order an array by param name string compare
30
+ *
31
+ * @param array $a Array with the param to compare
32
+ * @param array $b Array with the param to compare
33
+ * @return int Sorting result from strcmp
34
+ */
35
+ public static function sort_by_name( $a, $b ){
36
+ return strcmp( strtolower( $a['name'] ), strtolower( $b['name'] ) );
37
+ }
38
+
39
+ /**
40
+ * Returns the version of based on a path
41
+ *
42
+ * @filter mailpoet/get_version
43
+ * @filter mailpoet/package
44
+ *
45
+ * @param string $path
46
+ * @return string Version of the package
47
+ */
48
+ public static function get_version( $path = null ) {
49
+ return apply_filters( 'mailpoet/get_version', self::$version, apply_filters( 'mailpoet/package', 'core', $path ) );
50
+ }
51
+
52
+ /**
53
+ * get the current_user data in a safe manner making sure a field exists before returning it's value
54
+ * @global type $current_user
55
+ * @param string $field
56
+ * @return mixed
57
+ */
58
+ public static function wp_get_userdata( $field = false ) {
59
+ //WordPress globals be careful there
60
+ global $current_user;
61
+ if ( $field ) {
62
+ if ( function_exists( 'get_currentuserinfo' ) ) {
63
+ // Here is an exception because of one of the weirdest bug
64
+ // the idea is to make sure we don't call get_currentuserinfo on the wysija_subscribers page when on a multisite
65
+ if ( ! ( isset( $_GET['page'] ) && $_GET['page'] === 'wysija_subscribers' && is_multisite() ) ){
66
+ get_currentuserinfo();
67
+ }
68
+ }
69
+ if ( isset( $current_user->{$field} ) ){
70
+ return $current_user->{$field};
71
+ } elseif ( isset( $current_user->data->{$field} ) ){
72
+ return $current_user->data->{$field};
73
+ } else {
74
+ return $current_user;
75
+ }
76
+ }
77
+ return $current_user;
78
+ }
79
+
80
+ /**
81
+ * set a global notice message
82
+ * @global array $wysija_wpmsg
83
+ * @param type $msg
84
+ */
85
+ function wp_notice( $msg ){
86
+ global $wysija_wpmsg;
87
+
88
+ //add the hook only once
89
+ if ( ! $wysija_wpmsg ) {
90
+ add_action( 'admin_notices', array( $this, 'wp_msgs' ) );
91
+ }
92
+
93
+ //record msgs
94
+ $wysija_wpmsg['updated'][] = $msg;
95
+ }
96
+
97
+ /**
98
+ * set a global error message
99
+ * @global array $wysija_wpmsg
100
+ * @param type $msg
101
+ */
102
+ function wp_error( $msg ){
103
+ global $wysija_wpmsg;
104
+
105
+ //add the hook only once
106
+ if ( ! $wysija_wpmsg ){
107
+ add_action( 'admin_notices', array( $this, 'wp_msgs' ) );
108
+ }
109
+
110
+ //record msgs
111
+ $wysija_wpmsg['error'][] = $msg;
112
+ }
113
+
114
+ /**
115
+ * prints a global message in the WordPress' backend identified as belonging to wysija
116
+ * we tend to avoid as much as possible printing messages globally, since this is ugly
117
+ * and make the administrators immune to beige-yellowish messages :/
118
+ * @global array $wysija_wpmsg
119
+ */
120
+ function wp_msgs() {
121
+ global $wysija_wpmsg;
122
+ foreach ( $wysija_wpmsg as $keymsg => $wp2 ){
123
+ $msgs = '<div class="' . $keymsg . ' fade">';
124
+ foreach ( $wp2 as $mymsg ){
125
+ $msgs .= '<p><strong>MailPoet</strong> : ' . $mymsg . '</p>';
126
+ }
127
+ $msgs .= '</div>';
128
+ }
129
+
130
+ // This is bad, we should be checking for valid HTML here.
131
+ echo $msgs;
132
+ }
133
+
134
+ /**
135
+ * returns an error message, it will appear as a red pinkish message in our interfaces
136
+ * @param string $msg
137
+ * @param boolean $public if set to true it will appear as a full message, otherwise it will appear behind a "Show more details." link
138
+ * @param boolean $global if set to true it will appear on all of the backend interfaces, not only wysija's own
139
+ */
140
+ function error( $msg, $public = false, $global = false ){
141
+ $status = 'error';
142
+ if ( $global ){
143
+ $status = 'g-' . $status;
144
+ }
145
+ $this->setInfo( $status, $msg, $public );
146
+ }
147
+
148
+ /**
149
+ * returns a success message, it will appear as a beige yellowish message in our interfaces
150
+ * @param string $msg
151
+ * @param boolean $public if set to true it will appear as a full message, otherwise it will appear behind a "Show more details." link
152
+ * @param boolean $global if set to true it will appear on all of the backend interfaces, not only wysija's own
153
+ */
154
+ function notice( $msg, $public = true, $global = false ){
155
+ $status = 'updated';
156
+ if ( $global ){
157
+ $status = 'g-' . $status;
158
+ }
159
+ $this->setInfo( $status, $msg, $public );
160
+ }
161
+
162
+ /**
163
+ * store all of the error and success messages in a global variable
164
+ * @global type $wysija_msg
165
+ * @param type $status whether this is a success message or an error message
166
+ * @param type $msg
167
+ * @param type $public if set to true it will appear as a full message, otherwise it will appear behind a "Show more details." link
168
+ */
169
+ static function setInfo($status,$msg,$public=false){
170
+ global $wysija_msg;
171
+ if(!$public) {
172
+
173
+ if(!isset($wysija_msg['private'][$status])){
174
+ $wysija_msg['private']=array();
175
+ $wysija_msg['private'][$status]=array();
176
+ }
177
+ array_push($wysija_msg['private'][$status], $msg);
178
+ }else{
179
+ if(!isset($wysija_msg[$status])) $wysija_msg[$status]=array();
180
+ array_push($wysija_msg[$status], $msg);
181
+ }
182
+
183
+ }
184
+
185
+ /**
186
+ * read the global function containing all of the error messages and print them
187
+ * @global type $wysija_msg
188
+ * @return type
189
+ */
190
+ function getMsgs(){
191
+ global $wysija_msg;
192
+
193
+ if(isset($wysija_msg['private']['error'])){
194
+ $wysija_msg['error'][]=str_replace(array('[link]','[/link]'),array('<a class="showerrors" href="javascript:;">','</a>'),__('An error occured. [link]Show more details.[/link]',WYSIJA));
195
+ }
196
+
197
+ if(isset($wysija_msg['private']['updated'])){
198
+ $wysija_msg['updated'][]=str_replace(array('[link]','[/link]'),array('<a class="shownotices" href="javascript:;">','</a>'),__('[link]Show more details.[/link]',WYSIJA));
199
+ }
200
+ if(isset($wysija_msg['private'])){
201
+ $prv=$wysija_msg['private'];
202
+ unset($wysija_msg['private']);
203
+ if(isset($prv['error'])) $wysija_msg['xdetailed-errors']=$prv['error'];
204
+ if(isset($prv['updated'])) $wysija_msg['xdetailed-updated']=$prv['updated'];
205
+ }
206
+ return $wysija_msg;
207
+ }
208
  }
209
 
210
 
211
  class WYSIJA_help extends WYSIJA_object{
212
+ var $controller = null;
213
+
214
+ static $admin_body_class_runner = false;
215
+
216
+ function WYSIJA_help(){
217
+ add_action( 'widgets_init', array( $this, 'widgets_init' ), 1 );
218
+
219
+ // Only load this when ajax is not used
220
+ if ( !( defined( 'DOING_AJAX' ) && DOING_AJAX ) ) {
221
+ add_action( 'init', array( $this, 'register_scripts' ), 1 );
222
+ }
223
+
224
+ add_action( 'admin_enqueue_scripts', array( $this, 'admin_enqueue_scripts' ) );
225
+ add_filter( 'admin_body_class', array( $this, 'admin_body_class' ) );
226
+ }
227
+
228
+ function widgets_init() {
229
+ //load the widget file
230
+ require_once(WYSIJA_WIDGETS.'wysija_nl.php');
231
+ register_widget( 'WYSIJA_NL_Widget' );
232
+ }
233
+
234
+ public function admin_enqueue_scripts(){
235
+ if ( WYSIJA_ITF ){
236
+ wp_enqueue_script( 'mailpoet-global' );
237
+ }
238
+ wp_enqueue_style( 'mailpoet-dashicons' );
239
+ }
240
+
241
+ public function admin_body_class( $body_class_str ){
242
+
243
+ if ( WYSIJA_help::$admin_body_class_runner === true ){
244
+ return $body_class_str;
245
+ }
246
+
247
+ WYSIJA_help::$admin_body_class_runner = true;
248
+
249
+ global $wp_version;
250
+
251
+ $class = array();
252
+ if ( ! empty( $body_class_str ) ){
253
+ $class = explode( ' ', $body_class_str );
254
+ }
255
+
256
+ if ( '3.8' === $wp_version ){
257
+ $class[] = 'mp-menu-icon-font';
258
+ }
259
+
260
+ if ( version_compare( $wp_version, '3.8', '<' ) ){
261
+ $class[] = 'mp-menu-icon-bg';
262
+ } else {
263
+ $class[] = 'mpoet-ui';
264
+ }
265
+
266
+ return implode( ' ', $class );
267
+ }
268
+
269
+ function register_scripts(){
270
+ $helper_toolbox = WYSIJA::get('toolbox','helper');
271
+ $wp_language_code = $helper_toolbox->get_language_code();
272
+ $valid_language = array(
273
+ 'ar',
274
+ 'ca',
275
+ 'cs',
276
+ 'cz',
277
+ 'da',
278
+ 'de',
279
+ 'el',
280
+ 'es',
281
+ 'et',
282
+ 'fa',
283
+ 'fi',
284
+ 'fr',
285
+ 'he',
286
+ 'hr',
287
+ 'hu',
288
+ 'id',
289
+ 'it',
290
+ 'ja',
291
+ 'lt',
292
+ 'nl',
293
+ 'no',
294
+ 'pl',
295
+ 'pt',
296
+ 'pt_BR',
297
+ 'ro',
298
+ 'ru',
299
+ 'sv',
300
+ 'tr',
301
+ 'vi',
302
+ 'zh_CN',
303
+ 'zh_TW',
304
+ );
305
+
306
+
307
+ if ( in_array( $wp_language_code, $valid_language ) ) {
308
+ wp_register_script('wysija-validator-lang',WYSIJA_URL.'js/validate/languages/jquery.validationEngine-'.$wp_language_code.'.js', array( 'jquery' ),WYSIJA::get_version(),true );
309
+ }else{
310
+ wp_register_script('wysija-validator-lang',WYSIJA_URL.'js/validate/languages/jquery.validationEngine-en.js', array( 'jquery' ),WYSIJA::get_version(),true );
311
+ }
312
+ wp_register_script('wysija-validator',WYSIJA_URL.'js/validate/jquery.validationEngine.js', array( 'jquery' ),WYSIJA::get_version(),true );
313
+ wp_register_script('wysija-front-subscribers', WYSIJA_URL.'js/front-subscribers.js', array( 'jquery' ),WYSIJA::get_version(),true);
314
+
315
+ wp_register_style( 'mailpoet-dashicons', WYSIJA_URL . 'css/admin-dashicons.css', array(), WYSIJA::get_version() );
316
+
317
+ wp_register_script('wysija-form', WYSIJA_URL.'js/forms.js', array( 'jquery' ),WYSIJA::get_version());
318
+ wp_register_style('validate-engine-css',WYSIJA_URL.'css/validationEngine.jquery.css',array(),WYSIJA::get_version());
319
+ wp_register_script('wysija-admin-ajax', WYSIJA_URL.'js/admin-ajax.js',array(),WYSIJA::get_version());
320
+ wp_register_script('wysija-admin-ajax-proto', WYSIJA_URL.'js/admin-ajax-proto.js',array(),WYSIJA::get_version());
321
+ wp_register_script( 'mailpoet-global', WYSIJA_URL.'js/admin-global.js', array( 'jquery', 'underscore' ), WYSIJA::get_version() );
322
+
323
+ if(defined('WYSIJA_SIDE') && WYSIJA_SIDE=='front') wp_enqueue_style('validate-engine-css');
324
+
325
+ }
326
+
327
+
328
+ /**
329
+ * All the ajax requests are routed through here
330
+ */
331
+ function ajax() {
332
+
333
+ $result_array = array();
334
+ if( !$_REQUEST || !isset( $_REQUEST['controller'] ) || !isset( $_REQUEST['task'] ) ){
335
+ $result_array = array( 'result' => false );
336
+ }else{
337
+ $plugin_requesting_ajax = 'wysija-newsletters';
338
+
339
+ // we override the plugin resquesting ajax if specified in the request
340
+ if( isset( $_REQUEST['wysijaplugin'] ) ){
341
+ $plugin_requesting_ajax = $_REQUEST['wysijaplugin'];
342
+ }
343
+
344
+ // fetching the right controller
345
+ $this->controller = WYSIJA::get( $_REQUEST['controller'] , 'controller' , false, $plugin_requesting_ajax );
346
+
347
+ // let's make sure the requested task exist
348
+ if( method_exists( $this->controller , $_REQUEST['task'] ) ){
349
+ $result_array['result'] = $this->controller->$_REQUEST['task']();
350
+ }else{
351
+ $this->error( 'Method "' . $_REQUEST['task'] . '" doesn\'t exist for controller : "'.$_REQUEST['controller'] );
352
+ }
353
+ }
354
+
355
+ // get the appended messages triggerred during the task execution
356
+ $result_array['msgs'] = $this->getMsgs();
357
+
358
+ // this header will allow ajax request from the home domain, this can be a lifesaver when domain mapping is on
359
+ if(function_exists('home_url')){
360
+ header('Access-Control-Allow-Origin: '.home_url());
361
+ }
362
+
363
+ // let's encode our response in the json format
364
+ $json_data = json_encode($result_array);
365
+
366
+ // in some case scenarios our client will have jQuery forcing the jsonp so we need to adapt ourselves
367
+ if(isset($_REQUEST['callback'])) {
368
+ // special header for json-p
369
+ header('Content-type: application/javascript');
370
+
371
+ $helper_jsonp = WYSIJA::get('jsonp', 'helper');
372
+ if($helper_jsonp->isValidCallback($_REQUEST['callback'])) {
373
+ print $_REQUEST['callback'] . '('.$json_data.');';
374
+ }
375
+ } else {
376
+ // standard header for unwrapped classic json response
377
+ header('Content-type: application/json');
378
+ print $json_data;
379
+ }
380
+ // our ajax response is printed, no need to let WordPress or 3rd party plugin execute more code
381
+ die();
382
+ }
383
  }
384
 
385
 
386
  class WYSIJA extends WYSIJA_object{
387
 
388
+ function WYSIJA(){
389
+
390
+ }
391
+
392
+ /**
393
+ * function created at the beginning to handle particular cases with WP get_permalink it got much smaller recently
394
+ * @param int $pageid
395
+ * @param array $params
396
+ * @param boolean $simple
397
+ * @return type
398
+ */
399
+ public static function get_permalink( $pageid, $params = array(), $simple = false ){
400
+ $hWPtools = WYSIJA::get( 'wp_tools', 'helper' );
401
+ return $hWPtools->get_permalink( $pageid, $params, $simple );
402
+ }
403
+
404
+ /**
405
+ * translate the plugin
406
+ * @staticvar boolean $extensionloaded
407
+ * @param type $extendedplugin
408
+ * @return boolean
409
+ */
410
+ public static function load_lang( $extendedplugin = false ){
411
+ static $extensionloaded = false;
412
+
413
+ //we return the entire array of extensions loaded if non is specified
414
+ if ( ! $extendedplugin ) {
415
+ return $extensionloaded;
416
+ }
417
+
418
+ //we only need to load this translation loader once on init
419
+ if(!$extensionloaded){
420
+ add_action('init', array('WYSIJA','load_lang_init'));
421
+ }
422
+ //each plugin has a different name
423
+ if ( !$extensionloaded || !isset($extensionloaded[$extendedplugin])) {
424
+ $transstring = null;
425
+ switch($extendedplugin){
426
+ case 'wysija-newsletters':
427
+ $transstring=WYSIJA;
428
+ break;
429
+ case 'wysijashop':
430
+ $transstring=WYSIJASHOP;
431
+ break;
432
+ case 'wysijacrons':
433
+ $transstring=WYSIJACRONS;
434
+ break;
435
+ case 'wysija-newsletters-premium':
436
+ $transstring=WYSIJANLP;
437
+ break;
438
+ case 'get_all':
439
+ return $extensionloaded;
440
+ }
441
+
442
+ //store all the required translations to be loaded in the static variable
443
+ if($transstring !== null) {
444
+ $extensionloaded[$extendedplugin] = $transstring;
445
+ }
446
+ }
447
+ }
448
+
449
+ /**
450
+ * check if the user is tech support as this can be used to switch the language back to english when helping our customers
451
+ * @global type $current_user
452
+ * @param type $debugmode
453
+ * @return type
454
+ */
455
+ public static function is_wysija_admin($debugmode=false){
456
+ //to allow wysija team members to work in english mode if debug is activated
457
+ global $current_user;
458
+
459
+ if((int)$debugmode > 0 && empty($current_user)) return true;
460
+
461
+ if(isset($current_user->data->user_email) && (strpos($current_user->data->user_email, '@mailpoet.com') !== false)) {
462
+ return true;
463
+ }
464
+ return false;
465
+ }
466
+
467
+ /**
468
+ * this function exists just to fix the issue with qtranslate :/ (it only fix it partially)
469
+ * @param type $extended_plugin
470
+ */
471
+ public static function load_lang_init($extended_plugin=false){
472
+ $model_config = WYSIJA::get('config','model');
473
+ $debug_mode = (int)$model_config->getValue('debug_new');
474
+
475
+ if($debug_mode === 0 || ($debug_mode > 0 && WYSIJA::is_wysija_admin($debug_mode) === false)) {
476
+ $extensions_loaded = WYSIJA::load_lang('get_all');
477
+ foreach($extensions_loaded as $extended_plugin => $translation_string){
478
+
479
+ // check for translation file overriding from transstring wp-content/languages/wysija-newsletters/wysija-newsletters-en_US.mo
480
+ $filename = WP_CONTENT_DIR.DS.'languages'.DS.$extended_plugin.DS.$translation_string.'-'.get_locale().'.mo';
481
+
482
+ if( !file_exists($filename) ){
483
+ // get the translation file in our local file
484
+ $filename = WYSIJA_PLG_DIR.$extended_plugin.DS.'languages'.DS.$translation_string.'-'.get_locale().'.mo';
485
+ }
486
+
487
+ // load the translation file with WP's load_textdomain
488
+ if( file_exists( $filename ) ){
489
+ load_textdomain( $translation_string, $filename );
490
+ }
491
+ }
492
+ }
493
+ }
494
+
495
+ /**
496
+ * function to generate objects of different types, managing file requiring in order to be the most efficient
497
+ * @staticvar array $arrayOfObjects
498
+ * @param string $name
499
+ * @param string $type : in which folder do we go and pick the class
500
+ * @param boolean $force_side : this parameter is almost never set to true,
501
+ * it will be useful for instance if you want to get a back controller
502
+ * from the frontend, it was used maybe in the shop but it can be ignored for wysija-newsletters
503
+ * @param type $extended_plugin : used only when calling the url from a different plugin it is used watch those files :
504
+ * -core/controller.php line 21, 23 ,24
505
+ * @param type $load_lang : the load lang is in the get to be sure we don't forget to load the language file for each plugin at least once
506
+ * the way I see it it could be moved to the index.php of each plugin. for now only wysija-newsletters is translated anyway
507
+ * @return boolean
508
+ */
509
+ public static function get($name,$type,$force_side=false,$extended_plugin='wysija-newsletters',$load_lang=true){
510
+ static $array_of_objects;
511
+
512
+ if($load_lang) WYSIJA::load_lang($extended_plugin);
513
+
514
+ // store all the objects made so that we can reuse them accross the application if the object is already set we return it immediately
515
+ if(isset($array_of_objects[$extended_plugin][$type.$name])) {
516
+ return $array_of_objects[$extended_plugin][$type.$name];
517
+ }
518
+
519
+ // which folder do we pick for controllersand views ? back or front ?
520
+ if($force_side) {
521
+ $side=$force_side;
522
+ } else {
523
+ $side=WYSIJA_SIDE;
524
+ }
525
+
526
+ // for each plugin we will define the $extended_constant variable if it's not defined already
527
+ // also we will defined the $extended_plugin_name which corresponds to the folder name and also will be used to build the class to be called
528
+ switch($extended_plugin){
529
+ case 'wysija-newsletters-premium':
530
+ $extended_constant='WYSIJANLP';
531
+ if(!defined($extended_constant)) define($extended_constant,$extended_constant);
532
+ $extended_plugin_name='wysijanlp';
533
+ break;
534
+ case 'wysija-newsletters':
535
+ $extended_constant='WYSIJA';
536
+ if(!defined($extended_constant)) define($extended_constant,$extended_constant);
537
+ $extended_plugin_name='wysija';
538
+ break;
539
+ default :
540
+ $extended_constant=strtoupper($extended_plugin);
541
+ if(!defined($extended_constant)) define($extended_constant,$extended_constant);
542
+ $extended_plugin_name=$extended_plugin;
543
+ }
544
+
545
+ // security to protect against dangerous ./../ includes
546
+ $name = preg_replace('#[^a-z0-9_]#i','',$name);
547
+
548
+ // this switch will require_once the file needed and build a the class name depending on the parameters passed to the function
549
+ switch($type){
550
+ case 'controller':
551
+ // require the parent class necessary
552
+ require_once(WYSIJA_CORE.'controller.php');
553
+
554
+ $ctrdir=WYSIJA_PLG_DIR.$extended_plugin.DS.'controllers'.DS;
555
+ // Require module concept
556
+ require_once(WYSIJA_CORE.'module'.DS.'module.php');
557
+
558
+ // if we are doing ajax we don't go to one side, ajax is for frontend or backend in the same folder
559
+ if(defined('DOING_AJAX')) {
560
+ $class_path=$ctrdir.'ajax'.DS.$name.'.php';
561
+ }else {
562
+ // the other controllers are called in a side folder back or front
563
+ $class_path=$ctrdir.$side.DS.$name.'.php';
564
+ // require the side specific controller file
565
+ require_once(WYSIJA_CTRL.$side.'.php');
566
+ }
567
+ $class_name = strtoupper($extended_plugin_name).'_control_'.$side.'_'.$name;
568
+ break;
569
+ case 'view':
570
+ $viewdir=WYSIJA_PLG_DIR.$extended_plugin.DS.'views'.DS;
571
+ // let's get the right path for the view front or back and the right class_name
572
+ $class_path=$viewdir.$side.DS.$name.'.php';
573
+ $class_name = strtoupper($extended_plugin_name).'_view_'.$side.'_'.$name;
574
+
575
+ // require the common view file and the side view file
576
+ require_once(WYSIJA_CORE.'view.php');
577
+ require_once(WYSIJA_VIEWS.$side.'.php');
578
+ break;
579
+ case 'helper':
580
+ $helpdir=WYSIJA_PLG_DIR.$extended_plugin.DS.'helpers'.DS;
581
+ $class_path=$helpdir.$name.'.php';
582
+ $class_name = strtoupper($extended_plugin_name).'_help_'.$name;
583
+
584
+ break;
585
+ case 'model':
586
+ $modeldir=WYSIJA_PLG_DIR.$extended_plugin.DS.'models'.DS;
587
+ $class_path=$modeldir.$name.'.php';
588
+ $class_name = strtoupper($extended_plugin_name).'_model_'.$name;
589
+ // require the parent class necessary
590
+ require_once(WYSIJA_CORE.'model.php');
591
+ break;
592
+ case 'widget':
593
+ $modeldir=WYSIJA_PLG_DIR.$extended_plugin.DS.'widgets'.DS;
594
+ $class_path=$modeldir.$name.'.php';
595
+ if($name=='wysija_nl') $class_name='WYSIJA_NL_Widget';
596
+ else $class_name = strtoupper($extended_plugin_name).'_widget_'.$name;
597
+ break;
598
+
599
+ case 'module':
600
+ $moduledir = WYSIJA_PLG_DIR . $extended_plugin . DS . 'modules' . DS;
601
+ if (file_exists($moduledir . $name . '.php'))
602
+ $class_path = $moduledir . $name . '.php';
603
+ elseif (file_exists($moduledir . $name . DS . $name . '.php'))
604
+ $class_path = $moduledir . $name . DS . $name . '.php';
605
+ else
606
+ return;
607
+ $class_name = strtoupper($extended_plugin_name) . '_module_' . $name;
608
+ // require the parent class necessary
609
+ //require_once(WYSIJA_CORE.'module'.DS.'module.php');
610
+ require_once(WYSIJA_CORE . 'module' . DS . 'statistics_model.php');
611
+ require_once(WYSIJA_CORE . 'module' . DS . 'statistics.php');
612
+ require_once(WYSIJA_CORE . 'module' . DS . 'statisticschart.php');
613
+ require_once(WYSIJA_CORE . 'module' . DS . 'statisticstable.php');
614
+
615
+ break;
616
+
617
+ default:
618
+ WYSIJA::setInfo('error','WYSIJA::get does not accept this type of file "'.$type.'" .');
619
+ return false;
620
+ }
621
+
622
+ if(!file_exists($class_path)) {
623
+ WYSIJA::setInfo('error','file has not been recognised '.$class_path);
624
+ WYSIJA::setInfo('error',$class_name);
625
+ WYSIJA::setInfo('error',$type);
626
+ return;
627
+ }
628
+
629
+ // require the file needed once and store & return the object needed
630
+ require_once($class_path);
631
+ return $array_of_objects[$extended_plugin][$type.$name]=new $class_name($extended_plugin_name);
632
+
633
+ }
634
+
635
+ /**
636
+ * log function to spot some strange issues when sending emails for instance
637
+ * @param type $key
638
+ * @param type $data
639
+ * @param type $category
640
+ * @return type
641
+ */
642
+ public static function log($key='default',$data='empty',$category='default'){
643
+ $config=WYSIJA::get('config','model');
644
+
645
+ if((int)$config->getValue('debug_new')>1 && $category && $config->getValue('debug_log_'.$category)){
646
+
647
+ $optionlog=get_option('wysija_log');
648
+
649
+
650
+ $optionlog[$category][(string)microtime(true)][$key]=$data;
651
+
652
+ WYSIJA::update_option('wysija_log' , $optionlog);
653
+ }
654
+ return false;
655
+ }
656
+
657
+ /**
658
+ * the filter to add option to the cron frequency instead of being stuck with hourly, daily and twicedaily...
659
+ * we can add filters but we cannot delete other values such as the default ones, as this might break other plugins crons
660
+ * @param type $param
661
+ * @return type
662
+ */
663
+ public static function filter_cron_schedules( $param ) {
664
+ $frequencies=array(
665
+ 'one_min' => array(
666
+ 'interval' => 60,
667
+ 'display' => __( 'Once every minute',WYSIJA)
668
+ ),
669
+ 'two_min' => array(
670
+ 'interval' => 120,
671
+ 'display' => __( 'Once every two minutes',WYSIJA)
672
+ ),
673
+ 'five_min' => array(
674
+ 'interval' => 300,
675
+ 'display' => __( 'Once every five minutes',WYSIJA)
676
+ ),
677
+ 'ten_min' => array(
678
+ 'interval' => 600,
679
+ 'display' => __( 'Once every ten minutes',WYSIJA)
680
+ ),
681
+ 'fifteen_min' => array(
682
+ 'interval' => 900,
683
+ 'display' => __( 'Once every fifteen minutes',WYSIJA)
684
+ ),
685
+ 'thirty_min' => array(
686
+ 'interval' => 1800,
687
+ 'display' => __( 'Once every thirty minutes',WYSIJA)
688
+ ),
689
+ 'two_hours' => array(
690
+ 'interval' => 7200,
691
+ 'display' => __( 'Once every two hours',WYSIJA)
692
+ ),
693
+ 'eachweek' => array(
694
+ 'interval' => 604800,
695
+ 'display' => __( 'Once a week',WYSIJA)
696
+ ),
697
+ 'each28days' => array(
698
+ 'interval' => 2419200,
699
+ 'display' => __( 'Once every 28 days',WYSIJA)
700
+ ),
701
+ );
702
+
703
+ return array_merge($param, $frequencies);
704
+ }
705
+
706
+ /**
707
+ * scheduled task for sending the emails in the queue, the frequency is set in the settings
708
+ */
709
+ public static function croned_queue( $check_scheduled_newsletter = true) {
710
+
711
+ // check the scheduled tasks only if it's a standard WP scheduled task free only
712
+ if($check_scheduled_newsletter){
713
+ WYSIJA::check_scheduled_newsletters();
714
+ }
715
+
716
+ $model_config = WYSIJA::get('config','model');
717
+ // check that the 2000 limit is not passed and process the queue
718
+
719
+ if((int)$model_config->getValue('total_subscribers') < 2000 ){
720
+ $helper_queue = WYSIJA::get('queue','helper');
721
+ $helper_queue->report=false;
722
+ WYSIJA::log('croned_queue process',true,'cron');
723
+
724
+ $helper_queue->process();
725
+ }
726
+
727
+ }
728
+
729
+ public static function check_scheduled_newsletters(){
730
+ $last_scheduled_check = get_option('wysija_last_scheduled_check');
731
+
732
+ // if the latest post notification check was done more than five minutes ago let's check it again
733
+ if(empty($last_scheduled_check) || ( time() > ($last_scheduled_check + 300) ) ){
734
+ // create the scheduled automatic post notifications email if there are any
735
+ $helper_autonews = WYSIJA::get('autonews','helper');
736
+ $helper_autonews->checkPostNotif();
737
+
738
+ // queue the scheduled newsletter also if there are any
739
+ $helper_autonews->checkScheduled();
740
+ WYSIJA::update_option('wysija_last_scheduled_check', time());
741
+ }
742
+
743
+ // send daily report about emails sent
744
+ $model_config = WYSIJA::get('config','model');
745
+ if($model_config->getValue('emails_notified_when_dailysummary')){
746
+ $helper_notification = WYSIJA::get('notifications','helper');
747
+ $helper_notification->send_daily_report();
748
+ }
749
+
750
+ }
751
+
752
+
753
+ /**
754
+ * everyday we make sure not to leave any trash files
755
+ * remove temporary files
756
+ */
757
+ public static function croned_daily() {
758
+
759
+ @ini_set('max_execution_time',0);
760
+
761
+ /*user refresh count total*/
762
+ $helper_user = WYSIJA::get('user','helper');
763
+ $helper_user->refreshUsers();
764
+
765
+ /*user domain generation*/
766
+ $helper_user->generate_domains();
767
+
768
+ /*clear temporary folders*/
769
+ $helper_file = WYSIJA::get('file','helper');
770
+ $helper_file->clear();
771
+
772
+ /*clear queue from unsubscribed*/
773
+ $helper_queue = WYSIJA::get('queue','helper');
774
+ $helper_queue->clear();
775
+
776
+
777
+ }
778
+
779
+ // Weekly cron
780
+ public static function croned_weekly() {
781
+
782
+ @ini_set('max_execution_time',0);
783
+
784
+ $model_config = WYSIJA::get('config','model');
785
+
786
+ // If enabled, flag MixPanel sending on next page load.
787
+ if ($model_config->getValue('analytics') == 1) {
788
+ $model_config->save(array('send_analytics_now' => 1));
789
+ }
790
+
791
+ }
792
+
793
+ // Monthly cron
794
+ public static function croned_monthly() {
795
+
796
+ @ini_set('max_execution_time',0);
797
+
798
+ $model_config = WYSIJA::get('config','model');
799
+
800
+ /* send daily report about emails sent */
801
+ if ($model_config->getValue('sharedata')) {
802
+ $helper_stats = WYSIJA::get('stats','helper');
803
+ $helper_stats->share();
804
+ }
805
+
806
+ }
807
+
808
+ /**
809
+ * when we deactivate the plugin we clear the WP install from those cron records
810
+ */
811
+ public static function deactivate() {
812
+ wp_clear_scheduled_hook('wysija_cron_queue');
813
+ wp_clear_scheduled_hook('wysija_cron_bounce');
814
+ wp_clear_scheduled_hook('wysija_cron_daily');
815
+ wp_clear_scheduled_hook('wysija_cron_weekly');
816
+ wp_clear_scheduled_hook('wysija_cron_monthly');
817
+ }
818
+
819
+
820
+ /**
821
+ * wysija's redirect allows to save some variables for the next page load such as notices etc..
822
+ * @global type $wysija_msg
823
+ * @global type $wysija_queries
824
+ * @global type $wysija_queries_errors
825
+ * @param type $location
826
+ */
827
+ public static function redirect($location) {
828
+ //save the messages
829
+ global $wysija_msg,$wysija_queries,$wysija_queries_errors;
830
+ WYSIJA::update_option('wysija_msg',$wysija_msg);
831
+ WYSIJA::update_option('wysija_queries',$wysija_queries);
832
+ WYSIJA::update_option('wysija_queries_errors',$wysija_queries_errors);
833
+
834
+ // make sure we encode square brackets as wp_redirect will strip them off
835
+ $location = str_replace(array('[', ']'), array('%5B', '%5D'), $location);
836
+
837
+ // redirect to specified location
838
+ wp_redirect($location);
839
+ exit;
840
+ }
841
+
842
+ /**
843
+ * custom post type for wysija is call wysijap as in wysija's post
844
+ */
845
+ public static function create_post_type() {
846
+
847
+ //by default there is url rewriteing on wysijap custom post, though in one client case I had to deactivate it.
848
+ //as this is rare we just need to set this setting to activate it
849
+ //by default let's deactivate the url rewriting of the wysijap confirmation page because it is breaking in some case.
850
+ $show_interface=false;
851
+ if(defined('WYSIJA_DBG') && WYSIJA_DBG>1) $show_interface=true;
852
+ register_post_type( 'wysijap',
853
+ array(
854
+ 'labels' => array(
855
+ 'name' => __('MailPoet page'),
856
+ 'singular_name' => __('MailPoet page')
857
+ ),
858
+ 'public' => true,
859
+ 'has_archive' => false,
860
+ 'show_ui' =>$show_interface,
861
+ 'show_in_menu' =>$show_interface,
862
+ 'rewrite' => false,
863
+ 'show_in_nav_menus'=>false,
864
+ 'can_export'=>false,
865
+ 'publicly_queryable'=>true,
866
+ 'exclude_from_search'=>true,
867
+ )
868
+ );
869
+
870
+ if(!get_option('wysija_post_type_updated')) {
871
+ $modelPosts=new WYSIJA_model();
872
+ $modelPosts->tableWP=true;
873
+ $modelPosts->table_prefix='';
874
+ $modelPosts->table_name='posts';
875
+ $modelPosts->noCheck=true;
876
+ $modelPosts->pk='ID';
877
+ if($modelPosts->exists(array('post_type'=>'wysijapage'))){
878
+ $modelPosts->update(array('post_type'=>'wysijap'),array('post_type'=>'wysijapage'));
879
+ flush_rewrite_rules( false );
880
+ }
881
+ WYSIJA::update_option('wysija_post_type_updated',time());
882
+ }
883
+
884
+ if(!get_option('wysija_post_type_created')) {
885
+ flush_rewrite_rules( false );
886
+ WYSIJA::update_option('wysija_post_type_created',time());
887
+ }
888
+
889
+ }
890
+
891
+ /**
892
+ * wysija update_option function is very similar to WordPress' one but it
893
+ * can also manage new options not automatically loaded each time
894
+ * @param type $option_name
895
+ * @param type $newvalue
896
+ * @param type $defaultload this parameter is the advantage other Wp's update_option here
897
+ */
898
+ public static function update_option($option_name,$newvalue,$defaultload='no'){
899
+ if ( get_option( $option_name ) != $newvalue ) {
900
+ update_option( $option_name, $newvalue );
901
+ } else {
902
+ add_option( $option_name, $newvalue, '', $defaultload );
903
+ }
904
+ }
905
+
906
+ /**
907
+ * When a WordPress user is added we also need to add it to the subscribers list
908
+ * @param type $user_id
909
+ * @return type
910
+ */
911
+ public static function hook_add_WP_subscriber($user_id) {
912
+ $data=get_userdata($user_id);
913
+
914
+
915
+ //check first if a subscribers exists if it doesn't then let's insert it
916
+ $model_config=WYSIJA::get('config','model');
917
+ $model_user=WYSIJA::get('user','model');
918
+ $model_user->getFormat=ARRAY_A; // there is one case where we were getting an object instead of an array
919
+ $subscriber_exists=$model_user->getOne(array('user_id'),array('email'=>$data->user_email));
920
+
921
+ $first_name=$data->first_name;
922
+ $last_name=$data->last_name;
923
+ if(!$data->first_name && !$data->last_name) $first_name=$data->display_name;
924
+
925
+ $model_user->reset();
926
+ if($subscriber_exists){
927
+ $user_id=$subscriber_exists['user_id'];
928
+ // we need to update the current subscriber using it's id
929
+ $model_user->update(array('wpuser_id'=>$data->ID,'firstname'=>$first_name,'lastname'=>$last_name),array('user_id'=>$user_id));
930
+ }else{
931
+ $model_user->noCheck=true;
932
+ $user_id=$model_user->insert(array('email'=>$data->user_email,'wpuser_id'=>$data->ID,'firstname'=>$first_name,'lastname'=>$last_name,'status'=>$model_config->getValue('confirm_dbleoptin')));
933
+ }
934
+
935
+ $model_user_list=WYSIJA::get('user_list','model');
936
+ $model_user_list->insert(array('user_id'=>$user_id,'list_id'=>$model_config->getValue('importwp_list_id'),'sub_date'=>time()),true);
937
+
938
+ $helper_user=WYSIJA::get('user','helper');
939
+ $helper_user->sendAutoNl($user_id,$data,'new-user');
940
+ return true;
941
+ }
942
+
943
+ /**
944
+ * when a WordPress user is updated we also need to update the corresponding subscriber
945
+ * @param type $user_id
946
+ * @return type
947
+ */
948
+ public static function hook_edit_WP_subscriber($user_id) {
949
+ $data=get_userdata($user_id);
950
+
951
+ //check first if a subscribers exists if it doesn't then let's insert it
952
+ $model_user=WYSIJA::get('user','model');
953
+ $model_config=WYSIJA::get('config','model');
954
+ $model_user_list=WYSIJA::get('user_list','model');
955
+ $model_user->getFormat = ARRAY_A;
956
+ $subscriber_exists=$model_user->getOne(array('user_id'),array('email'=>$data->user_email));
957
+
958
+ $model_user->reset();
959
+
960
+ $first_name=$data->first_name;
961
+ $last_name=$data->last_name;
962
+ if(!$data->first_name && !$data->last_name) $first_name=$data->display_name;
963
+
964
+ if($subscriber_exists){
965
+ $user_id=$subscriber_exists['user_id'];
966
+
967
+ $model_user->update(array('wpuser_id'=>$data->ID, 'email'=>$data->user_email,'firstname'=>$first_name,'lastname'=>$last_name),array('user_id'=>$user_id));
968
+
969
+ $result=$model_user_list->getOne(false,array('user_id'=>$user_id,'list_id'=>$model_config->getValue('importwp_list_id')));
970
+ $model_user_list->reset();
971
+ if(!$result)
972
+ $model_user_list->insert(array('user_id'=>$user_id,'list_id'=>$model_config->getValue('importwp_list_id'),'sub_date'=>time()));
973
+ }else{
974
+ //chck that we didnt update the email
975
+ $subscriber_exists=$model_user->getOne(false,array('wpuser_id'=>$data->ID));
976
+
977
+ if($subscriber_exists){
978
+ $user_id=$subscriber_exists['user_id'];
979
+
980
+ $model_user->update(array('email'=>$data->user_email,'firstname'=>$first_name,'lastname'=>$last_name),array('wpuser_id'=>$data->ID));
981
+
982
+ $result=$model_user_list->getOne(false,array('user_id'=>$user_id,'list_id'=>$model_config->getValue('importwp_list_id')));
983
+ $model_user_list->reset();
984
+ if(!$result)
985
+ $model_user_list->insert(array('user_id'=>$user_id,'list_id'=>$model_config->getValue('importwp_list_id'),'sub_date'=>time()));
986
+ }else{
987
+ $model_user->noCheck=true;
988
+ $user_id=$model_user->insert(array('email'=>$data->user_email,'wpuser_id'=>$data->ID,'firstname'=>$first_name,'lastname'=>$last_name,'status'=>$model_config->getValue('confirm_dbleoptin')));
989
+ $model_user_list->insert(array('user_id'=>$user_id,'list_id'=>$model_config->getValue('importwp_list_id'),'sub_date'=>time()));
990
+ }
991
+ }
992
+ return true;
993
+ }
994
+
995
+ /**
996
+ * when a wp user is deleted we also delete the subscriber corresponding to it
997
+ * @param type $user_id
998
+ */
999
+ public static function hook_del_WP_subscriber($user_id) {
1000
+ $model_config=WYSIJA::get('config','model');
1001
+ $model_user=WYSIJA::get('user','model');
1002
+ $data = $model_user->getOne(array('email','user_id'),array('wpuser_id'=>$user_id));
1003
+ if(isset($data['email'])) {
1004
+ $model_user->delete(array('email'=>$data['email']));
1005
+ }
1006
+ if(isset($data['user_id'])) {
1007
+ $model_user = WYSIJA::get('user_list','model');
1008
+ $model_user->delete(array('user_id'=>$data['user_id'],'list_id'=>$model_config->getValue('importwp_list_id')));
1009
+ }
1010
+ }
1011
+
1012
+
1013
+ public static function hook_auto_newsletter_refresh($post_id) {
1014
+ $helper_autonews = WYSIJA::get('autonews', 'helper');
1015
+ $helper_autonews->refresh_automatic_content();
1016
+
1017
+ return true;
1018
+ }
1019
+
1020
+ /**
1021
+ * post notification transition hook, know when a post really gets published
1022
+ * @param type $new_status
1023
+ * @param type $old_status
1024
+ * @param type $post
1025
+ * @return type
1026
+ */
1027
+ public static function hook_postNotification_transition($new_status, $old_status, $post) {
1028
+ //we run some process only if the status of the post changes from something to publish
1029
+ if($new_status === 'publish' && $old_status !== $new_status) {
1030
+ $model_email = WYSIJA::get('email', 'model');
1031
+ $emails = $model_email->get(false, array('type' => 2, 'status' => array(1, 3, 99)));
1032
+
1033
+ if(!empty($emails)) {
1034
+ //we loop through all of the automatic emails
1035
+ foreach($emails as $key => $email) {
1036
+
1037
+ //we will try to give birth to a child email only if the automatic newsletter is a post notification email and in immediate mode
1038
+ if(is_array($email) && $email['params']['autonl']['event'] === 'new-articles' && $email['params']['autonl']['when-article'] === 'immediate') {
1039
+ // set default include/exclude categories
1040
+ $include_category_ids = array();
1041
+ $exclude_category_ids = array();
1042
+
1043
+ // ALC need to check for post_type on each block of the autoposts
1044
+ $wj_data = maybe_unserialize( base64_decode( $email['wj_data'] ) );
1045
+ $post_types = array();
1046
+ $has_alc_blocks = false;
1047
+
1048
+ foreach ( $wj_data['body'] as $block_key => $block ){
1049
+ if ( $block['type'] !== 'auto-post' ){
1050
+ continue;
1051
+ }
1052
+
1053
+ $has_alc_blocks = true;
1054
+
1055
+ // get post type and post categories from block parameters
1056
+ foreach( $block['params'] as $param_data ) {
1057
+ if(in_array($param_data['key'], array('post_type', 'cpt')) && strlen(trim($param_data['value'])) > 0) {
1058
+ // store post type
1059
+ $post_types[] = trim($param_data['value']);
1060
+ } else if($param_data['key'] === 'category_ids' && strlen(trim($param_data['value'])) > 0) {
1061
+ // store post category ids
1062
+ $include_category_ids = array_map('intval', explode(',', trim($param_data['value'])));
1063
+ }
1064
+ }
1065
+ }
1066
+
1067
+ if ( $has_alc_blocks === true && ! in_array( $post->post_type, $post_types ) ) {
1068
+ continue;
1069
+ }
1070
+
1071
+ // get post categories
1072
+ $helper_wp_tools = WYSIJA::get('wp_tools', 'helper');
1073
+ $taxonomies = $helper_wp_tools->get_post_category_ids($post);
1074
+
1075
+ // assume the post has to be sent
1076
+ $do_send_post = true;
1077
+
1078
+ // post categories have to match at least one of the email's included categories
1079
+ $include_intersection = array_intersect($taxonomies, $include_category_ids);
1080
+ if(!empty($include_category_ids) && empty($include_intersection)) {
1081
+ $do_send_post = false;
1082
+ }
1083
+
1084
+ $exclude_intersection = array_intersect($taxonomies, $exclude_category_ids);
1085
+ // post categories should not match any one of the email's excluded categories
1086
+ if(!empty($exclude_category_ids) && !empty($exclude_intersection)) {
1087
+ $do_send_post = false;
1088
+ }
1089
+
1090
+ if($do_send_post) {
1091
+ WYSIJA::log('post_transition_hook_give_birth', array(
1092
+ 'post_id' => $post->ID,
1093
+ 'post_title' => $post->post_title,
1094
+ 'newsletter' => $email,
1095
+ 'old_status' => $old_status,
1096
+ 'new_status' => $new_status
1097
+ ),'post_notif');
1098
+
1099
+ $model_email->reset();
1100
+ $model_email->give_birth($email, $post->ID);
1101
+ }
1102
+ }
1103
+ }
1104
+ }
1105
+
1106
+ // we check for automatic latest content widget in automatic newsletter
1107
+ $helper_autonews = WYSIJA::get('autonews', 'helper');
1108
+ $helper_autonews->refresh_automatic_content();
1109
+ }
1110
+
1111
+ return true;
1112
+ }
1113
+
1114
+ /**
1115
+ * uninstall process not used
1116
+ */
1117
+ public static function uninstall(){
1118
+ $helperUS=WYSIJA::get('uninstall','helper');
1119
+ $helperUS->uninstall();
1120
+ }
1121
+
1122
+ /**
1123
+ * this function is run when wysija gets activated
1124
+ * there is no installation process here, all is about checking the global status of the app
1125
+ */
1126
+ public static function activate(){
1127
+ $encoded_option=get_option('wysija');
1128
+ $installApp=false;
1129
+ if($encoded_option){
1130
+ $values=unserialize(base64_decode($encoded_option));
1131
+ if(isset($values['installed'])) $installApp=true;
1132
+ }
1133
+
1134
+ //test again for plugins on reactivation
1135
+ if($installApp){
1136
+ $helper_import=WYSIJA::get('plugins_import','helper');
1137
+ $helper_import->testPlugins();
1138
+
1139
+ //resynch wordpress list
1140
+ $helper_user=WYSIJA::get('user','helper');
1141
+ $helper_user->synchList($values['importwp_list_id']);
1142
+ }
1143
+ }
1144
+
1145
+ /**
1146
+ * the is_plugin_active functions from WordPress sometimes are not loaded so here is one that works for single and multisites anywhere in the code
1147
+ * @param type $pluginName
1148
+ * @return type
1149
+ */
1150
+ public static function is_plugin_active($pluginName){
1151
+ $arrayactiveplugins=get_option('active_plugins');
1152
+ //we check in the list of the site options if the plugin is activated
1153
+ if(in_array($pluginName, $arrayactiveplugins)) {
1154
+ //plugin is activated for that site
1155
+ return true;
1156
+ }
1157
+
1158
+ //if this is a multisite it might not be activated in the site option but network activated though
1159
+ if(is_multisite()){
1160
+ $plugins = get_site_option('active_sitewide_plugins');
1161
+ //plugin is activated for that multisite
1162
+ if(isset($plugins[$pluginName])){
1163
+ return true;
1164
+ }
1165
+ }
1166
+ return false;
1167
+ }
1168
+
1169
+ /**
1170
+ * make sure that the current user has the good access rights corresponding to its role
1171
+ * @global type $current_user
1172
+ * @return type
1173
+ */
1174
+ public static function update_user_caps(){
1175
+ global $current_user;
1176
+
1177
+ if(empty($current_user) && function_exists('get_currentuserinfo')) get_currentuserinfo();
1178
+ if(empty($current_user)) return false;
1179
+ $current_user->get_role_caps();
1180
+
1181
+ return true;
1182
+ }
1183
+
1184
+ /**
1185
+ * test whether the plugin is a beta version or not
1186
+ * 2.4.4.4 is a beta
1187
+ * 2.4.4 is a bug fix release
1188
+ * 2.4 is a feature release
1189
+ * @param string $plugin_name
1190
+ */
1191
+ public static function is_beta($plugin_name=false){
1192
+ // exceptions
1193
+ $not_beta_versions = array('2.5.9.1', '2.5.9.2', '2.5.9.3', "2.5.9.4");
1194
+ $mailpoet_version = WYSIJA::get_version($plugin_name);
1195
+ if(in_array($mailpoet_version, $not_beta_versions)) return false;
1196
+
1197
+ // standard way of defining a beta version
1198
+ if(count(explode('.', $mailpoet_version)) > 3 ) return true;
1199
+ return false;
1200
+ }
1201
+
1202
+ /**
1203
+ * depending where it's used the base function from WordPress doesn't work, so this one will work anywhere
1204
+ * @param type $capability
1205
+ * @return type
1206
+ */
1207
+ public static function current_user_can($capability){
1208
+ if(!$capability) return false;
1209
+ WYSIJA::update_user_caps();
1210
+ if(!current_user_can($capability)) return false;
1211
+ return true;
1212
+ }
1213
+
1214
+ /**
1215
+ * this function get and sets the cron schedules when MailPoet's own cron system is active
1216
+ * @staticvar type $cron_schedules
1217
+ * @param type $schedule
1218
+ * @return type
1219
+ */
1220
+ public static function get_cron_schedule($schedule='queue'){
1221
+ static $cron_schedules;
1222
+
1223
+ //if the cron schedules are already loaded statically then we just have to return the right schedule value
1224
+ if(!empty($cron_schedules)){
1225
+ if($schedule=='all') return $cron_schedules;
1226
+ if(isset($cron_schedules[$schedule])) {
1227
+ return $cron_schedules[$schedule];
1228
+ }else{
1229
+ WYSIJA::set_cron_schedule($schedule);
1230
+ return false;
1231
+ }
1232
+ }else{
1233
+ //this is the first time this function is executed so let's get them from the db and store them statically
1234
+ $cron_schedules=get_option('wysija_schedules',array());
1235
+ if(!empty($cron_schedules)){
1236
+ if(isset($cron_schedules[$schedule])) return $cron_schedules[$schedule];
1237
+ else return false;
1238
+ }else{
1239
+ WYSIJA::set_cron_schedule();
1240
+ return false;
1241
+ }
1242
+ }
1243
+ return false;
1244
+ }
1245
+
1246
+ /**
1247
+ * return the frequency for each cron task needed by MailPoet
1248
+ * @return type an array of frequencies
1249
+ */
1250
+ public static function get_cron_frequencies(){
1251
+ $model_config = WYSIJA::get('config','model');
1252
+ $helper_forms = WYSIJA::get('forms','helper');
1253
+
1254
+ if(is_multisite() && $model_config->getValue('sending_method')=='network'){
1255
+ $sending_emails_each = $model_config->getValue('ms_sending_emails_each');
1256
+ }else{
1257
+ $sending_emails_each = $model_config->getValue('sending_emails_each');
1258
+ }
1259
+
1260
+ $queue_frequency = $helper_forms->eachValuesSec[$sending_emails_each];
1261
+ $bounce_frequency = 99999999999999;
1262
+ if(isset($helper_forms->eachValuesSec[$model_config->getValue('bouncing_emails_each')])){
1263
+ $bounce_frequency = $helper_forms->eachValuesSec[$model_config->getValue('bouncing_emails_each')];
1264
+ }
1265
+ return array('queue'=>$queue_frequency,'bounce'=>$bounce_frequency,'daily'=>86400,'weekly'=>604800,'monthly'=>2419200);
1266
+ }
1267
+
1268
+ /**
1269
+ * set the next cron schedule
1270
+ * TODO : needs probably to make the difference of running process for the next schedule, so that there is no delay(this is only problematic on some slow servers)
1271
+ * @param string $schedule
1272
+ * @param int $last_saved
1273
+ * @param boolean $set_running
1274
+ * @return boolean
1275
+ */
1276
+ public static function set_cron_schedule($schedule = false , $last_saved = 0 , $set_running = false){
1277
+ $cron_schedules = array();
1278
+
1279
+ $start_time = $last_saved;
1280
+ if(!$start_time) $start_time = time();
1281
+ $processes = WYSIJA::get_cron_frequencies();
1282
+ if(!$schedule){
1283
+ foreach($processes as $process => $frequency){
1284
+ $next_schedule = $start_time + $frequency;
1285
+ $prev_schedule = 0;
1286
+ if(isset($cron_schedules[$process]['running']) && $cron_schedules[$process]['running']) $prev_schedule=$cron_schedules[$process]['running'];
1287
+ $cron_schedules[$process]=array(
1288
+ 'next_schedule' => $next_schedule,
1289
+ 'prev_schedule' => $prev_schedule,
1290
+ 'running' => false);
1291
+ }
1292
+ }else{
1293
+ $cron_schedules = WYSIJA::get_cron_schedule('all');
1294
+ if($set_running){
1295
+ $cron_schedules[$schedule]['running'] = $set_running;
1296
+ }else{
1297
+ $running = 0;
1298
+ if(isset($cron_schedules[$schedule]['running'])) $running = $cron_schedules[$schedule]['running'];
1299
+ // if the process is not running or has been running for more than 15 minutes then we set the next_schedule date
1300
+ $process_frequency = $processes[$schedule];
1301
+
1302
+ if(!$running || ( time() > ($running + $process_frequency) ) ){
1303
+
1304
+ $next_schedule = $start_time + $process_frequency;
1305
+ // if the next schedule is already behind, we give it 30 seconds before it can triggers again
1306
+ if( $next_schedule < $start_time ){
1307
+ $next_schedule = $start_time + 30;
1308
+ }
1309
+
1310
+ $cron_schedules[$schedule] = array(
1311
+ 'next_schedule' => $next_schedule,
1312
+ 'prev_schedule' => $running,
1313
+ 'running' => false);
1314
+ }
1315
+ }
1316
+ }
1317
+ WYSIJA::update_option( 'wysija_schedules' , $cron_schedules , 'yes' );
1318
+ return true;
1319
+ }
1320
+
1321
+ /**
1322
+ * check that there is no passed schedules that need to be executed now
1323
+ * @return void
1324
+ */
1325
+ public static function cron_check() {
1326
+
1327
+ $cron_schedules = WYSIJA::get_cron_schedule('all');
1328
+ if(empty($cron_schedules)) return;
1329
+ else{
1330
+ $processes = WYSIJA::get_cron_frequencies();
1331
+
1332
+ $updated_sched = false;
1333
+ foreach($cron_schedules as $schedule => &$params){
1334
+ $running = 0;
1335
+ $time_now = time();
1336
+ if(isset($params['running'])) $running = $params['running'];
1337
+ //if the process has timedout we reschedule the next execution
1338
+ if($running && ( $time_now> ($running + $processes[$schedule]) ) ){
1339
+ //WYSIJA::setInfo('error','modifying next schedule for '.$proc);
1340
+ $process_frequency = $processes[$schedule];
1341
+
1342
+ $next_schedule = $running + $process_frequency;
1343
+ // if the next schedule is already behind, we give it 30 seconds before it can trigger again
1344
+ if( $next_schedule < $time_now ){
1345
+ $next_schedule = $time_now + 30;
1346
+ }
1347
+ $params=array(
1348
+ 'next_schedule' => $next_schedule,
1349
+ 'prev_schedule' => $running,
1350
+ 'running' => false);
1351
+ $updated_sched=true;
1352
+ }
1353
+ }
1354
+ if($updated_sched){
1355
+ //WYSIJA::setInfo('error','updating scheds');
1356
+ WYSIJA::update_option( 'wysija_schedules' , $cron_schedules , 'yes' );
1357
+ }
1358
+
1359
+ }
1360
+
1361
+ $time_now = time();
1362
+ $processesToRun = array();
1363
+ foreach($cron_schedules as $schedule => $scheduled_times){
1364
+ if(strpos($schedule, '(bounce handling not activated)')!==false) continue;
1365
+ $process_frequency = $processes[$schedule];
1366
+ if( ( !$scheduled_times['running'] || (int)$scheduled_times['running'] + $process_frequency < $time_now ) && $scheduled_times['next_schedule'] < $time_now){
1367
+ $processesToRun[] = $schedule;
1368
+ }
1369
+ }
1370
+
1371
+ $model_config = WYSIJA::get('config','model');
1372
+ $page_view_trigger = (int)$model_config->getValue('cron_page_hit_trigger');
1373
+ if(!empty($processesToRun) && $page_view_trigger === 1){
1374
+ //call the cron url
1375
+ // do not call that more than once per 5 minutes attempt at reducing the CPU load for some users
1376
+ // http://wordpress.org/support/topic/wysija-newsletters-slowing-down-my-site-1
1377
+ $last_cron_time_plus_5min = (int)get_option('wysija_last_php_cron_call') + (5*60);
1378
+
1379
+ if($last_cron_time_plus_5min < time()){
1380
+ $cron_url = site_url( 'wp-cron.php').'?'.WYSIJA_CRON.'&action=wysija_cron&process='.implode(',',$processesToRun).'&silent=1';
1381
+ $cron_request = apply_filters( 'cron_request', array(
1382
+ 'url' => $cron_url,
1383
+ 'args' => array( 'timeout' => 0.01, 'blocking' => false, 'sslverify' => apply_filters( 'https_local_ssl_verify', true ) )
1384
+ ) );
1385
+
1386
+ wp_remote_post( $cron_url, $cron_request['args'] );
1387
+ WYSIJA::update_option('wysija_last_php_cron_call', time());
1388
+ }
1389
+
1390
+
1391
+ }
1392
+ }
1393
+
1394
+ /**
1395
+ * Function somehow necessary to avoid some conflicts in windows server and WordPress autoload of plugins language file
1396
+ * @param type $boolean
1397
+ * @param type $domain
1398
+ * @param type $mofile
1399
+ * @return boolean
1400
+ */
1401
+ public static function override_load_textdomain($boolean, $domain, $mofile){
1402
+ $extensionloaded=WYSIJA::load_lang('get_all');
1403
+
1404
+ if(isset($extensionloaded[$domain]) && !@file_exists($mofile)){
1405
+ return true;
1406
+ }
1407
+
1408
+ return false;
1409
+ }
1410
+
1411
+ /**
1412
+ * function to rewrite the path of the file if the file doesn't exist
1413
+ * @param type $mofile
1414
+ * @param type $domain
1415
+ * @return type
1416
+ */
1417
+ public static function load_textdomain_mofile($mofile, $domain){
1418
+ $extensionloaded=WYSIJA::load_lang('get_all');
1419
+
1420
+ if(isset($extensionloaded[$domain]) && !file_exists($mofile)){
1421
+ return WYSIJA_PLG_DIR.$domain.DS.'languages'.DS.$extensionloaded[$domain].'-'.get_locale().'.mo';
1422
+ }
1423
+ return $mofile;
1424
+ }
1425
  }
1426
 
1427
  // subscribers/wp-user synch hooks
1432
  add_action('delete_user', array('WYSIJA', 'hook_del_WP_subscriber'), 1);
1433
  // for multisite
1434
  add_action('deleted_user', array('WYSIJA', 'hook_del_WP_subscriber'), 1);
1435
+ add_action('remove_user_from_blog', array('WYSIJA', 'hook_del_WP_subscriber'), 1);
1436
 
1437
+ // Load the Upgrader Class
1438
+ add_action('init', array('WJ_Upgrade', 'hook'), 9);
1439
 
1440
  // post notif trigger
1441
  add_action('transition_post_status', array('WYSIJA', 'hook_postNotification_transition'), 1, 3);
1442
+ // refresh auto newsletter content when a post is modified
1443
+ //add_action('save_post', array('WYSIJA', 'hook_auto_newsletter_refresh'), 1, 1);
1444
+ add_action('delete_post', array('WYSIJA', 'hook_auto_newsletter_refresh'), 1, 1);
1445
 
1446
  // add image size for emails
1447
+ add_image_size('wysija-newsletters-max', 600, 9999);
1448
 
1449
  $modelConf=WYSIJA::get('config','model');
1450
  if($modelConf->getValue('installed_time')){
1451
 
1452
+ // START all that concerns the CRON
1453
+ // make sure we check when is the schedule due with wysija's cron
1454
+ if($modelConf->getValue('cron_manual')){
1455
+ // if WP cron tasks are still set, we clear them
1456
+ if(wp_get_schedule('wysija_cron_queue')) WYSIJA::deactivate();
1457
+
1458
+ // set the crons schedule for each process
1459
+ WYSIJA::get_cron_schedule();
1460
+
1461
+ // check that there is no late cron schedules if we are using wysija's cron option and that the cron option is triggerred by any page view
1462
+ if(!isset($_REQUEST['process'])){
1463
+ WYSIJA::cron_check();
1464
+ }
1465
+
1466
+ // this action is triggerred only by a cron job
1467
+ // if we're entering the wysija's cron part, it should end here
1468
+ if(isset($_REQUEST['action']) && $_REQUEST['action']=='wysija_cron'){
1469
+ // priority is hundred so that the messages such as unsubscribe or view in your browser have time to be translated(they get translated around 96, 97)
1470
+ add_action('init', 'init_wysija_cron',100);
1471
+
1472
+ function init_wysija_cron(){
1473
+ $hCron=WYSIJA::get('cron','helper');
1474
+ $hCron->run();
1475
+ }
1476
+ }
1477
+
1478
+ // make sure the scheduled tasks are recorded when using WordPress' cron
1479
+ }else{
1480
+
1481
+ // filter to add new possible frequencies to the cron
1482
+ add_filter( 'cron_schedules', array( 'WYSIJA', 'filter_cron_schedules' ) );
1483
+
1484
+ // action to handle the scheduled tasks in wysija
1485
+ add_action( 'wysija_cron_queue', array( 'WYSIJA', 'croned_queue' ) );
1486
+ add_action( 'wysija_cron_daily', array( 'WYSIJA', 'croned_daily' ) );
1487
+ add_action( 'wysija_cron_weekly', array( 'WYSIJA', 'croned_weekly' ) );
1488
+ add_action( 'wysija_cron_monthly', array( 'WYSIJA', 'croned_monthly' ) );
1489
+
1490
+ // same with the weekly task
1491
+ if(!wp_next_scheduled('wysija_cron_weekly')){
1492
+ wp_schedule_event( $modelConf->getValue('last_save') , 'eachweek', 'wysija_cron_weekly' );
1493
+ }
1494
+ // the monthly task...
1495
+ if(!wp_next_scheduled('wysija_cron_monthly')){
1496
+ wp_schedule_event( $modelConf->getValue('last_save') , 'each28days', 'wysija_cron_monthly' );
1497
+ }
1498
+
1499
+ // the daily task...
1500
+ if(!wp_next_scheduled('wysija_cron_daily')){
1501
+ wp_schedule_event( $modelConf->getValue('last_save') , 'daily', 'wysija_cron_daily' );
1502
+ }
1503
+
1504
+
1505
+ if(is_multisite()){
1506
+
1507
+ // in the case of multisite and the network's method we schedule with a different frequency
1508
+ // this option contains the list of sites already scheduled
1509
+ $ms_wysija_bounce_cron = get_site_option('ms_wysija_bounce_cron');
1510
+ global $blog_id;
1511
+
1512
+ // if this blog is not recorded in our wysija_sending_cron option then we clear its scheduled so that we can reinitialize it
1513
+ if(!$ms_wysija_bounce_cron || !isset($ms_wysija_bounce_cron[$blog_id])){
1514
+ wp_clear_scheduled_hook('wysija_cron_bounce');
1515
+ WYSIJA::set_cron_schedule('queue');
1516
+ $ms_wysija_bounce_cron[$blog_id] = 1;
1517
+ update_site_option('ms_wysija_bounce_cron',$ms_wysija_bounce_cron);
1518
+ }
1519
+
1520
+ }
1521
+
1522
+ // if the bounce task is not scheduled then we initialize it
1523
+ if(!wp_next_scheduled('wysija_cron_bounce')){
1524
+ wp_schedule_event( $modelConf->getValue('last_save') , $modelConf->getValue('bouncing_emails_each'), 'wysija_cron_bounce' );
1525
+ }
1526
+
1527
+ // and the queue processing task ...
1528
+ // if we are in a multisite case we make sure that the ms frequency hasn't been changed, if it has we reset it
1529
+ if(is_multisite() && $modelConf->getValue('sending_method')=='network'){
1530
+ // in the case of multisite and the network's method we schedule with a different frequency
1531
+ // this option contains the list of sites already scheduled
1532
+ $ms_wysija_sending_cron=get_site_option('ms_wysija_sending_cron');
1533
+ global $blog_id;
1534
+
1535
+ // if this blog is not recorded in our wysija_sending_cron option then we clear its scheduled so that we can reinitialize it
1536
+ if(!$ms_wysija_sending_cron || !isset($ms_wysija_sending_cron[$blog_id])){
1537
+ wp_clear_scheduled_hook('wysija_cron_queue');
1538
+ WYSIJA::set_cron_schedule('queue');
1539
+ $ms_wysija_sending_cron[$blog_id]=1;
1540
+ update_site_option('ms_wysija_sending_cron',$ms_wysija_sending_cron);
1541
+ }
1542
+ }
1543
+
1544
+
1545
+ // simply schedule the queue
1546
+ if(!wp_next_scheduled('wysija_cron_queue')){
1547
+
1548
+ // in the case of multisite and the network's method we schedule with a different frequency
1549
+ if(is_multisite() && $modelConf->getValue('sending_method')=='network'){
1550
+ $sending_emails_each=$modelConf->getValue('ms_sending_emails_each');
1551
+ }else{
1552
+ $sending_emails_each=$modelConf->getValue('sending_emails_each');
1553
+ }
1554
+ wp_schedule_event( $modelConf->getValue('last_save') , $sending_emails_each, 'wysija_cron_queue' );
1555
+ }
1556
+
1557
+ }// END all that concerns the CRON
1558
+
1559
+ // filter fixing a bug with automatic load_text_domain_from WP didn't understand yet why this was necessary...
1560
+ // somehow wp_register_script(which is irrelevant) was triggerring this kind of notice
1561
+ // Warning: is_readable() [function.is-readable]: open_basedir restriction in effect. File(C:\Domains\website.com\wwwroot\web/wp-content/plugins/C:\Domains\website.com\wwwroot\web\wp-content\plugins\wysija-newsletters/languages/wysija-newsletters-en_US.mo) is not within the allowed path(s): (.;C:\Domains\;C:\PHP\;C:\Sites\;C:\SitesData\;/) in C:\Domains\website.com\wwwroot\web\wp-includes\l10n.php on line 339
1562
+ // the only solution is to make sure on our end that the file exists and rewrite it if necessary
1563
+ add_filter( 'override_load_textdomain', array( 'WYSIJA', 'override_load_textdomain' ), 10, 3);
1564
+ add_filter('load_textdomain_mofile', array( 'WYSIJA', 'load_textdomain_mofile' ), 10, 2);
1565
  }
1566
 
1567
  // not yet used but the purpose is to override any notification sent through wp_mail
1568
  if($modelConf->getValue('wp_notifications')){
1569
+ $hWPnotif=WYSIJA::get('wp_notifications','helper');
1570
  }
1571
 
1572
  register_deactivation_hook(WYSIJA_FILE, array( 'WYSIJA', 'deactivate' ));
1575
 
1576
 
1577
  // launch application
1578
+ $helper = WYSIJA::get(WYSIJA_SIDE,'helper');
core/controller.php CHANGED
@@ -3,88 +3,97 @@ defined('WYSIJA') or die('Restricted access');
3
 
4
 
5
  class WYSIJA_control extends WYSIJA_object{
6
- var $model="";
7
- var $view="";
8
- var $action="";
9
- var $list_columns=array();
10
- var $form_columns=array();
11
- var $filters=array();
12
- var $js=array();
13
- var $jsLoc=array();
14
- var $extension="wysija-newsletters";
15
- var $joins=array();
16
- var $title="";
17
 
18
- function WYSIJA_control(){
19
- //setup some required objects for the request
20
- if(!defined('DOING_AJAX')){
21
- if($this->view) $this->viewObj = WYSIJA::get($this->view,"view",false,$this->extension);
22
- if(empty($this->viewObj)) $this->viewObj = new stdClass (); // In some cases, viewObj can not be created
23
- if($this->model){
24
- $this->modelObj=WYSIJA::get($this->model,"model",false,$this->extension);
25
- $this->viewObj->model=WYSIJA::get($this->model,"model",false,$this->extension);
26
- }
27
- }
28
 
29
- //test for security, some actions require security some others don't
30
- if(isset($_REQUEST['_wpnonce'])){
31
- $_REQUEST['wpnonceback']=$_REQUEST['_wpnonce'];
32
 
33
- if($_REQUEST['action']=='wysija_ajax'){
34
- $actionnonce='wysija_ajax';
35
- }else{
36
- //backend case
37
- if(isset($_REQUEST['page'])){
38
- $actionnonce=$_REQUEST['page'].'-action_'.$_REQUEST['action'];
39
- if(isset($_REQUEST['id'])) $actionnonce.='-id_'.$_REQUEST['id'];
40
- //frontend case
41
- }elseif(isset($_REQUEST['controller'])){
42
- $actionnonce=$_REQUEST['controller'].'-action_'.$_REQUEST['action'];
43
- if(isset($_REQUEST['id'])) $actionnonce.='-id_'.$_REQUEST['id'];
44
- }
45
- }
46
 
47
- if(!$_REQUEST['action']) return true;
 
 
 
 
 
 
 
 
 
 
 
 
48
 
49
- //if the wp_nonce has been set up then we test it against the one here if it fails we just die
50
- $nonce=$_REQUEST['_wpnonce'];
51
 
52
- if(!function_exists('wp_verify_nonce')) include(ABSPATH.'wp-includes'.DS.'pluggable.php');
53
- if(!wp_verify_nonce($nonce, $actionnonce) ) die('Security failure during request.');
54
- }
55
- }
56
 
57
- /**
58
- * if a controller calls that page then it needs those global parameters to be set
59
- * @return boolean
60
- */
61
- function requireSecurity(){
 
 
 
62
 
63
- if(!isset($_REQUEST['wpnonceback']) && !isset($_REQUEST['_wpnonce'])) {
64
- die('Your request is not safe.');
65
- }else{
66
- return true;
67
- }
68
- }
69
 
 
 
 
 
 
 
70
 
71
- /**
72
- * prepare an array of condition for a where statement with the pk and its value.
73
- * note: not sure this function should be here though.
74
- * @return array
75
- */
76
- function getPKVal(){
77
 
78
- if(isset($_POST['wysija'][$this->modelObj->table_name][$this->modelObj->pk]) && $_POST['wysija'][$this->modelObj->table_name][$this->modelObj->pk]){
79
- //this is an update
80
- $conditions=array($this->modelObj->pk =>$_POST['wysija'][$this->modelObj->table_name][$this->modelObj->pk]);
81
- unset($_POST['wysija'][$this->modelObj->table_name][$this->modelObj->pk]);
82
- }elseif(isset($_GET['id'])){
83
- $conditions=array($this->modelObj->pk =>$_GET['id']);
84
- }else{
85
- $conditions=array();
86
- }
87
 
88
- return $conditions;
89
- }
 
 
 
 
 
 
 
 
 
 
90
  }
3
 
4
 
5
  class WYSIJA_control extends WYSIJA_object{
6
+ var $model="";
7
+ var $view="";
8
+ var $action="";
9
+ var $list_columns=array();
10
+ var $form_columns=array();
11
+ var $filters=array();
12
+ var $js=array();
13
+ var $jsLoc=array();
14
+ var $extension="wysija-newsletters";
15
+ var $joins=array();
16
+ var $title="";
17
 
18
+ function WYSIJA_control(){
19
+ //setup some required objects for the request
20
+ if(!defined('DOING_AJAX')){
21
+ if($this->view) $this->viewObj = WYSIJA::get($this->view,"view",false,$this->extension);
22
+ if(empty($this->viewObj)) $this->viewObj = new stdClass (); // In some cases, viewObj can not be created
23
+ if($this->model){
24
+ $this->modelObj=WYSIJA::get($this->model,"model",false,$this->extension);
25
+ $this->viewObj->model=WYSIJA::get($this->model,"model",false,$this->extension);
26
+ }
27
+ }
28
 
29
+ // Security test, we should never do anything before WordPress Init; It's just wrong
30
+ add_action('init', array(&$this, 'nonce_verification'));
31
+ }
32
 
33
+ public function nonce_verification(){
34
+ if(!empty($_REQUEST['_wpnonce'])){
35
+ $_REQUEST['wpnonceback']=$_REQUEST['_wpnonce'];
 
 
 
 
 
 
 
 
 
 
36
 
37
+ if($_REQUEST['action']=='wysija_ajax'){
38
+ $actionnonce='wysija_ajax';
39
+ }else{
40
+ //backend case
41
+ if(is_admin() && !empty($_REQUEST['page'])){
42
+ $actionnonce=$_REQUEST['page'].'-action_'.$_REQUEST['action'];
43
+ if(!empty($_REQUEST['id'])) $actionnonce.='-id_'.$_REQUEST['id'];
44
+ //frontend case
45
+ } elseif (!empty($_REQUEST['controller'])) {
46
+ $actionnonce=$_REQUEST['controller'].'-action_'.$_REQUEST['action'];
47
+ if(!empty($_REQUEST['id'])) $actionnonce.='-id_'.$_REQUEST['id'];
48
+ }
49
+ }
50
 
51
+ if(!$_REQUEST['action'])
52
+ return true;
53
 
54
+ //if the wp_nonce has been set up then we test it against the one here if it fails we just die
55
+ $nonce=$_REQUEST['_wpnonce'];
 
 
56
 
57
+ if(!wp_verify_nonce($nonce, $actionnonce) ){
58
+ wp_die("<h2>" . __('Security failure during request') . "</h2>", __("Security Problem"), array(
59
+ 'response' => 403,
60
+ 'back_link' => true
61
+ ));
62
+ }
63
+ }
64
+ }
65
 
66
+ /**
67
+ * if a controller calls that page then it needs those global parameters to be set
68
+ * @return boolean
69
+ */
70
+ function requireSecurity(){
 
71
 
72
+ if(!isset($_REQUEST['wpnonceback']) && !isset($_REQUEST['_wpnonce'])) {
73
+ die('Your request is not safe.');
74
+ }else{
75
+ return true;
76
+ }
77
+ }
78
 
 
 
 
 
 
 
79
 
80
+ /**
81
+ * prepare an array of condition for a where statement with the pk and its value.
82
+ * note: not sure this function should be here though.
83
+ * @return array
84
+ */
85
+ function getPKVal(){
 
 
 
86
 
87
+ if(isset($_POST['wysija'][$this->modelObj->table_name][$this->modelObj->pk]) && $_POST['wysija'][$this->modelObj->table_name][$this->modelObj->pk]){
88
+ //this is an update
89
+ $conditions=array($this->modelObj->pk =>$_POST['wysija'][$this->modelObj->table_name][$this->modelObj->pk]);
90
+ unset($_POST['wysija'][$this->modelObj->table_name][$this->modelObj->pk]);
91
+ }elseif(isset($_GET['id'])){
92
+ $conditions=array($this->modelObj->pk =>$_GET['id']);
93
+ }else{
94
+ $conditions=array();
95
+ }
96
+
97
+ return $conditions;
98
+ }
99
  }
core/model.php CHANGED
@@ -2,964 +2,1033 @@
2
  defined('WYSIJA') or die('Restricted access');
3
  class WYSIJA_model extends WYSIJA_object{
4
 
5
- var $table_prefix='wysija';
6
- var $table_name='';
7
- var $pk='';
8
- var $values=array();
9
- var $conditions=array();
10
- var $orderby=array();
11
- var $groupby=false;
12
- var $noCheck =false;
13
- var $replaceQRY=false;
14
- var $limitON=false;
15
- var $dbg=false;
16
- var $colCheck=true;
17
- var $getFormat=ARRAY_A;
18
- var $getOne=false;
19
- var $fieldValid=true;
20
- var $specialUpdate=false;
21
- var $escapeFields=array();
22
- var $escapingOn=false;
23
- var $tableWP=false;
24
- var $columns=array();
25
- var $joins=array();
26
- var $ignore = false;
27
- var $sql_error=false;
28
- var $comparisonKeys = array('equal', 'notequal', 'like', 'greater', 'less', 'greater_eq', 'less_eq', 'is');
29
-
30
- function WYSIJA_model($extensions=''){
31
- if(defined('WYSIJA_DBG') && WYSIJA_DBG>0) $this->dbg=true;
32
- global $wpdb;
33
- $this->wpprefix=$wpdb->prefix;
34
- if($extensions) $this->table_prefix=$extensions;
35
- //fix for radiokapi
36
- //$this->wpprefix=$wpdb->base_prefix;
37
- }
38
- /**
39
- * since we reuse the same objects accross the whole application
40
- * once in a while for instance between a delete and a select we need to reset the objects to update the conditions
41
- */
42
- function reset(){
43
- $this->values=array();
44
- $this->conditions=array();
45
- $this->orderby=array();
46
- $this->groupby=false;
47
- $this->getFormat=ARRAY_A;
48
- $this->getOne=false;
49
- $this->limitON=false;
50
- $this->sql_error=false;
51
- }
52
-
53
- /**
54
- *
55
- * @param type $columnsOrPKval
56
- * @param type $conditions
57
- * @return type
58
- */
59
- function get($columnsOrPKval=false,$conditions=array()){
60
- /*then columns becomes the pk value*/
61
- if(!$conditions){
62
- $conditions=array('equal'=>array($this->pk=>$columnsOrPKval));
63
- $columnsOrPKval=false;
64
- $this->noCheck=true;
65
- }
66
-
67
- /* if we pass just the id strong in the get conditions then it's the pk*/
68
- if($conditions && !is_array($conditions)){
69
- $conditions=array('equal'=>array($this->pk=>$conditions));
70
- }
71
- if($this->setConditions($conditions)){
72
- if($this->getOne) $results=$this->getRows($columnsOrPKval,0,1);
73
- else $results=$this->getRows($columnsOrPKval);
74
- //$this->escapeQuotesFromRes($results);
75
- if($this->getOne && count($results)==1){
76
- switch($this->getFormat){
77
- case ARRAY_A:
78
- foreach($results as $res)return $res;
79
- break;
80
- case OBJECT:
81
- foreach($results as $res)return $res;
82
- break;
83
- }
84
- }
85
- else return $results;
86
- }
87
-
88
- return false;
89
- }
90
-
91
- function getOne($columnsOrPKval=false,$conditions=array()){
92
- $this->getOne=true;
93
- $this->limitON=true;
94
-
95
- return $this->get($columnsOrPKval,$conditions);
96
- }
97
-
98
- /**
99
- * get a list of result based on a select query
100
- * @global type $wpdb
101
- * @param type $columns
102
- * @param type $page
103
- * @param type $limit
104
- * @return type
105
- */
106
- function getRows($columns=false,$page=0,$limit=false){
107
-
108
- /*set the columns*/
109
- if($columns){
110
- if(is_array($columns)){
111
- $columns=implode(', ',$columns);
112
- }
113
- }else $columns='*';
114
-
115
-
116
- $query='SELECT '.$columns.' FROM `'.$this->getSelectTableName()."`";
117
- $query.=$this->makeJoins();
118
- $query.=$this->makeWhere();
119
- $query.=$this->makeGroupBY();
120
- $query.=$this->makeOrderBY();
121
-
122
- if($this->limitON) $query.=$this->setLimit($page,$limit);
123
- $results=$this->query('get_res',$query,$this->getFormat);
124
-
125
- //$this->escapeQuotesFromRes($results);
126
-
127
- return $results;
128
- }
129
-
130
- function escapeQuotesFromRes(&$results){
131
- if(!$this->escapingOn) return false;
132
- foreach($results as $k =>$r){
133
-
134
- if(in_array($this->getFormat,array(ARRAY_A,ARRAY_N))){
135
- foreach($r as $k1 =>$v1){
136
- if(in_array($k1,$this->escapeFields)){
137
- $results[$k][$k1]= stripslashes($v1);
138
- }
139
- }
140
- }
141
- }
142
- }
143
-
144
- function setLimit($page=0,$limit=false){
145
- /*set the limit of the selection*/
146
-
147
- if(!$this->getOne){
148
- if($page==0){
149
- if(isset($_REQUEST['pagi'])){
150
- $page=(int)$_REQUEST['pagi'];
151
- if($page!=0) $page=$page-1;
152
- }
153
-
154
- }else $page=$page-1;
155
- }
156
-
157
- if(!$limit){
158
- if(isset($this->limit_pp)) $limit=$this->limit_pp;
159
- else{
160
- $config=WYSIJA::get('config','model');
161
- $limit=$config->getValue('limit_listing');
162
- }
163
- }
164
-
165
- $this->limit=(int)$limit;
166
- $this->page=$page;
167
- $this->limit_start=(int)($this->page*$this->limit);
168
- $this->limit_end=(int)($this->limit_start+$this->limit);
169
-
170
- return " LIMIT $this->limit_start , $this->limit";
171
- }
172
-
173
- /**
174
- * to have a custom query through the model and get the result immediately
175
- * @param type $query
176
- * @return type
177
- */
178
- function getResults($query,$type=ARRAY_A){
179
- return $this->query('get_res',$query, $type);
180
- }
181
-
182
-
183
- function getSelectTableName(){
184
- if($this->joins && isset($this->joins['tablestart'])){
185
- if(isset($this->joins['prefstart'])) return $this->wpprefix.$this->joins['prefstart'].'_'.$this->joins['tablestart'];
186
- else return $this->getPrefix().$this->joins['tablestart'];
187
- }else return $this->getPrefix().$this->table_name;
188
- }
189
-
190
- /**
191
- * simple SQL count
192
- * @global type $wpdb
193
- * @return type
194
- */
195
- function count($query=false,$keygetcount=false){
196
- if(!$query){
197
- $groupBy=$this->makeGroupBY();
198
- $columnMore='';
199
- if($groupBy) $columnMore=','.$this->groupby;
200
- $query='SELECT COUNT('.$this->getPk().') as count '.$columnMore.' FROM `'.$this->getSelectTableName().'`';
201
- $query.=$this->makeJoins();
202
-
203
- $query.=$this->makeWhere();
204
- $query.=$groupBy;
205
- }
206
-
207
- if($this->dbg) $this->keepQry($query,'count');
208
-
209
- $results=$this->query('get_res',$query,$this->getFormat);
210
-
211
- if(!$results || count($results)>1) return $results;
212
- else {
213
- if($keygetcount) return $results[0][$keygetcount];
214
- else{
215
- foreach($results[0] as $key => $count) return $count;
216
- }
217
- }
218
-
219
-
220
- return $results;
221
- }
222
-
223
- /**
224
- * make the SQL WHERE condition string
225
- * @return string
226
- */
227
- function makeWhere(){
228
- $query='';
229
- if($this->conditions){
230
- /*set the WHERE clause*/
231
- $conditions=array();
232
- foreach($this->conditions as $type=>$values){
233
- if(!in_array($type, $this->comparisonKeys)){
234
- $conditionsss=$this->conditions;
235
- $this->conditions=array();
236
- $this->conditions['equal']=$conditionsss;
237
-
238
- break;
239
- }
240
- }
241
- foreach($this->conditions as $type=>$values){
242
- if($type=='like' && count($values)>1){
243
- if(is_array($values)){
244
- $total=count($values);
245
- $i=1;
246
- $likeCond='';
247
- foreach($values as $qfield => $qval){
248
- $likeCond.=$qfield." LIKE '%".mysql_real_escape_string(addcslashes($qval, '%_' ))."%'";
249
- if($i<$total){
250
- $likeCond.=' OR ';
251
- }
252
- $i++;
253
- }
254
- $conditions[]='('.$likeCond.')';
255
- }
256
- continue;
257
- }
258
- foreach($values as $condK => $condVal){
259
-
260
- //secure from injections
261
- $this->_secureFieldVal($condK, $condVal);
262
-
263
- switch($type){
264
- case 'equal':
265
- if(is_array($condVal)){
266
- $conditions[]=$condK.' IN ("'.implode('","', $condVal).'")';
267
- }else{
268
- if(is_null($condVal)) {
269
- $conditions[] = $condK.' IS NULL';
270
- } else {
271
- if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
272
- $conditions[] = $condK.'='.$condVal;
273
- }
274
- }
275
- break;
276
- case 'notequal':
277
- if(is_array($condVal)){
278
- $conditions[]=$condK.' NOT IN ("'.implode('","', $condVal).'")';
279
- }else{
280
- //this means that if I delete something with a list of ids and the array happens to be empty array of ids it will just delete everything by
281
- if(is_null($condVal)) {
282
- $conditions[] = $condK.' IS NOT NULL';
283
- } else {
284
- if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
285
- $conditions[] = $condK.' != '.$condVal;
286
- }
287
- }
288
- break;
289
- case 'like':
290
- $conditions[]=$condK." LIKE '%".mysql_real_escape_string(addcslashes($condVal, '%_' ))."%'";
291
- break;
292
- case 'greater':
293
- if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
294
- $conditions[]=$condK.' > '.$condVal;
295
- break;
296
- case 'less':
297
- if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
298
- $conditions[]=$condK.' < '.$condVal;
299
- break;
300
- case 'greater_eq':
301
- if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
302
- $conditions[]=$condK.' >= '.$condVal;
303
- break;
304
- case 'less_eq':
305
- if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
306
- $conditions[]=$condK.' <= '.$condVal;
307
- break;
308
- case 'is':
309
-
310
- $conditions[]=$condK.' '.$condVal;
311
- break;
312
- }
313
- }
314
-
315
- }
316
-
317
- $query.=' WHERE '.implode(' AND ',$conditions);
318
- }
319
-
320
- return $query;
321
- }
322
-
323
- /**
324
- * make the SQL ORDER BY condition string
325
- * @return string
326
- */
327
- function makeOrderBY(){
328
- $query=' ORDER BY ';
329
- if($this->orderby){
330
- /*set the ORDER BY clause*/
331
- $query.=$this->orderby.' '.$this->orderbyt;
332
- }else{
333
- /*by default we order by pk desc*/
334
- if(is_array($this->pk)) return '';
335
- $query.=$this->pk.' DESC';
336
- }
337
- return $query;
338
- }
339
-
340
-
341
- function makeJoins(){
342
-
343
- if($this->joins){
344
- $join=' as A';
345
- $arrayLetters=array('B','C','D','E');
346
- foreach($this->joins['tablejoins'] as $table => $fk){
347
- $letter=array_shift($arrayLetters);
348
- $join.=' JOIN `'.$this->getPrefix().$table.'` AS '.$letter." on $letter.$fk=A.".$this->joins['keystart'].' ';
349
- }
350
- /*set the ORDER BY clause*/
351
- return $join;
352
- }else return '';
353
-
354
- }
355
- /**
356
- * make the SQL ORDER BY condition string
357
- * @return string
358
- */
359
- function makeGroupBY(){
360
-
361
- if($this->groupby){
362
- /*set the ORDER BY clause*/
363
- return ' GROUP BY '.$this->groupby;
364
- }else return '';
365
-
366
- }
367
- function groupBy($name){
368
-
369
- if (!is_string($name) OR preg_match('|[^a-z0-9#_.-]|i',$name) !== 0 ){
370
- $this->groupby=false;
371
- }else $this->groupby=$name;
372
- }
373
- function orderBy($name,$type = 'ASC'){
374
-
375
- if(is_array($name) and count($name) > 0) {
376
- // set order by to empty string
377
- $this->orderby = '';
378
- $this->ordert = '';
379
-
380
- // count number of arguments
381
- $count = count($name);
382
-
383
- // build order by query
384
- for($i = 0; $i < $count; $i++) {
385
-
386
- $value = current($name);
387
-
388
- //security escaping
389
- if(!is_string(key($name)) OR preg_match('|[^a-z0-9#_.-]|i',key($name)) !== 0 ){
390
- $orderByCol="";
391
- }else $orderByCol=key($name);
392
- //security escaping
393
- if(!is_string($value) OR preg_match('|[^a-z0-9#_.-]|i',$value) !== 0 ){
394
- $orderByVal="";
395
- }else $orderByVal=$value;
396
-
397
- if($i === ($count - 1)) {
398
- $this->orderby .= $orderByCol;
399
- $this->ordert = $orderByVal;
400
- } else {
401
- $this->orderby .=$orderByCol.' '.$orderByVal;
402
- $this->orderby .= ', ';
403
- next($name);
404
- }
405
- }
406
- } else if(!is_string($name) OR preg_match('|[^a-z0-9#_.-]|i',$name) !== 0 ){
407
- $this->orderby="";
408
- }else {
409
- $this->orderby=$name;
410
- }
411
-
412
- if(!in_array($type,array('DESC','ASC'))) $type = 'DESC';
413
- $this->orderbyt=$type;
414
- }
415
-
416
-
417
-
418
- /**
419
- * prepare for an insert procedure
420
- * @param type $values
421
- */
422
- function insert($values,$ignore=false){
423
- if($ignore)$this->ignore=true;
424
- if($this->setValues($values)){
425
- return $this->save();
426
- }else{
427
- $this->error(sprintf('missing values in model insert : %1$s.', get_class($this)));
428
- }
429
- }
430
-
431
-
432
- function replace($values=array()){
433
- $this->replaceQRY=true;
434
- $this->insert($values);
435
- $this->replaceQRY=false;
436
- }
437
-
438
- /**
439
- * prepare for an update procedure
440
- * @param type $values
441
- * @param type $conditions
442
- */
443
- function update($values=array(),$conditions=array()){
444
-
445
- if($this->setValues($values)){
446
- /*if no condition is set then we set it mannualy based on the primary key*/
447
- if(!$conditions){
448
- if(!$this->conditions){
449
- if(isset($values[$this->pk]) && $values[$this->pk]){
450
-
451
- $this->setConditions(array($this->pk =>$values[$this->pk]),true);
452
-
453
- unset($values[$this->pk]);
454
-
455
-
456
- return $this->save(true);
457
-
458
- }else{
459
- $this->error(sprintf('missing pk value in model update : %1$s.', get_class($this)));
460
- }
461
- }
462
-
463
- }else{
464
- if($this->setConditions($conditions,true)){
465
- return $this->save(true);
466
- }else{
467
- $this->error(sprintf('missing conditions in model update : %1$s.', get_class($this)));
468
- }
469
- }
470
-
471
- }else{
472
- $this->error(sprintf('missing values in model update : %1$s.', get_class($this)));
473
- }
474
- }
475
-
476
- /**
477
- * UPDATE with a special where condition
478
- * @param type $table
479
- * @param type $data
480
- * @param type $where
481
- * @param type $format
482
- * @param type $where_format
483
- * @return type
484
- */
485
- function specialUpdate( $table, $data, $where, $format = null, $where_format = null ) {
486
- if ( ! is_array( $data ) || ! is_array( $where ) )
487
- return false;
488
-
489
- $formats = $format = (array) $format;
490
- $bits = $wheres = array();
491
-
492
- $i=0;
493
- foreach ( $data as $field => $val) {
494
- $this->_secureFieldVal($field,$val);
495
-
496
- switch($format[$i]){
497
- case "%d":
498
- $bits[] = "`$field` = ".(int)$val;
499
- break;
500
- case '[increment]':
501
- $bits[] = "`$field` = ".$field.'+1';
502
- break;
503
- case '[decrement]':
504
- $bits[] = "`$field` = ".$field.'-1';
505
- break;
506
- default :
507
- $bits[] = "`$field` = '".$val."'";
508
- }
509
- $i++;
510
- }
511
-
512
- $sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . ' ' . $this->makeWhere();
513
- return $this->query( $sql );
514
- }
515
-
516
-
517
- function _secureFieldVal(&$field,&$val){
518
- if (!is_string($field) OR preg_match('|[^a-z0-9#_.-]|i',$field) !== 0 ){
519
- die('field "'.$field .'" not secured');
520
- }
521
- global $wpdb;
522
- if(is_string($val)) $val=mysql_real_escape_string($val,$wpdb->dbh);
523
- else{
524
- if(is_array($val)){
525
- foreach($val as $k=>$v){
526
- if(is_string($v)) $val[$k]=mysql_real_escape_string($v,$wpdb->dbh);
527
- }
528
- }elseif(is_object($val)){
529
- foreach($val as $k=>$v){
530
- if(is_string($v)) $val->$k=mysql_real_escape_string($v,$wpdb->dbh);
531
- }
532
- }
533
- }
534
- }
535
- /**
536
- * save information as an update or an insert
537
- * @global type $wpdb
538
- * @param type $update
539
- * @return type
540
- */
541
- function save($update=false){
542
-
543
- if($update)$updateStr='Update';
544
- else $updateStr='Insert';
545
- $beforeSave='before'.$updateStr;
546
- $afterSave='after'.$updateStr;
547
-
548
-
549
-
550
- if(!$update && isset($this->columns['created_at']))$this->values['created_at']=time();
551
- foreach($this->columns as $key => $params){
552
- /*check for auto columns */
553
- if((isset($params['autoup']) && $update) || (!$update && $key!='sent_at')){
554
- if(isset($params['type']) && !isset($this->values[$key])){
555
- switch($params['type']){
556
- case 'date':
557
- $this->values[$key]=time();
558
- break;
559
- case 'ip':
560
- $userHelper=WYSIJA::get("user","helper");
561
- /*record the ip and save the user*/
562
- $this->values[$key]=$userHelper->getIP();
563
- break;
564
- case 'referer':
565
- /*record the ip and save the user*/
566
- $this->values[$key]=$_SERVER['HTTP_REFERER'];
567
- break;
568
- }
569
- }
570
-
571
- }
572
- }
573
-
574
- if(method_exists($this,$beforeSave)){
575
- if(!$this->$beforeSave()){
576
- //$this->error(sprintf('Problem during validation "%2$s" in model : %1$s.', get_class($this), $beforeSave));
577
- return false;
578
- }
579
- }
580
-
581
- /*prepare a format list for the update and insert function*/
582
- $fieldsFormats=array();
583
- if(!is_array($this->pk) && isset($this->values[$this->pk])) unset($this->values[$this->pk]);
584
- foreach($this->values as $key =>$val){
585
- if(!isset($this->columns[$key]['html'])) $this->values[$key]=strip_tags($val);
586
- /* let's correct the type of the values based on the one defined in the model*/
587
- if(in_array($val, array('[increment]','[decrement]'))){
588
- $fieldsFormats[]=$val;
589
- $this->specialUpdate=true;
590
- }else{
591
- //dbg($this->values);
592
- if(!isset($this->columns[$key]['type'])){
593
- $this->columns[$key]['type']='default';
594
- }
595
- switch($this->columns[$key]['type']){
596
- case 'integer':
597
- case 'boolean':
598
- $fieldsFormats[]="%d";
599
- break;
600
- default:
601
- $fieldsFormats[]="%s";
602
-
603
- }
604
- }
605
-
606
- }
607
-
608
- if($this->fieldValid && !$this->validateFields()) {
609
- $this->error(__('Error Validating the fields',WYSIJA),true);
610
- $this->stay=true;
611
- return false;
612
- }
613
-
614
- global $wpdb;
615
-
616
- if($update){
617
-
618
- if( $this->specialUpdate || isset($this->conditions['equal']) || isset($this->conditions['notequal']) || isset($this->conditions['like'])){
619
-
620
- $resultSave=$this->specialUpdate($this->getPrefix().$this->table_name,$this->values,$this->conditions,$fieldsFormats);
621
- $this->logError();
622
- }else{
623
-
624
- $wpdb->update($this->getPrefix().$this->table_name,$this->values,$this->conditions,$fieldsFormats);
625
- $this->logError();
626
- $resultSave=$wpdb->result;
627
- }
628
-
629
- }else{
630
- if($this->replaceQRY){
631
- $resultSave=$wpdb->replace($this->getPrefix().$this->table_name,$this->values,$fieldsFormats);
632
- $this->logError();
633
- }else{
634
-
635
- if($this->ignore) $resultSave=$wpdb->insert($this->getPrefix().$this->table_name,$this->values,$fieldsFormats);
636
- else $resultSave=$wpdb->insert($this->getPrefix().$this->table_name,$this->values,$fieldsFormats);
637
-
638
- $this->logError();
639
- //dbg('hello');
640
- }
641
-
642
- }
643
- if($this->dbg){
644
- $this->keepQry();
645
- }
646
-
647
- if(!$resultSave){
648
- $wpdb->show_errors();
649
- return false;
650
- }else{
651
- if($update){
652
- if(isset($this->conditions[$this->getPk()])){
653
- $resultSave=$this->conditions[$this->getPk()];
654
- }else{
655
- if(isset($this->conditions[$this->getPk(1)])) $resultSave=$this->conditions[$this->getPk(1)];
656
- }
657
-
658
- }else{
659
- $resultSave=$wpdb->insert_id;
660
- }
661
- }
662
-
663
- $wpdb->flush();
664
-
665
- if(method_exists($this,$afterSave)){
666
- if(!$this->$afterSave($resultSave)){
667
- //$this->error(sprintf('Problem during validation "%2$s" in model : %1$s.', get_class($this), $afterSave));
668
- return false;
669
- }
670
- }
671
- return $resultSave;
672
- }
673
-
674
-
675
- function insertMany($values){
676
- $fields=array_keys($values[0]);
677
-
678
- $query='INSERT INTO `'.$this->getPrefix().$this->table_name.'` (`' . implode( '`,`', $fields ) . '`) VALUES ';
679
-
680
- $total=count($values);
681
- $i=1;
682
- foreach($values as &$vals){
683
- foreach($vals as &$v) $v=mysql_real_escape_string($v);
684
- $query.= "('" . implode( "','", $vals )."')";
685
- if($i<$total) $query.=',';
686
- $i++;
687
- }
688
-
689
- $this->query($query.$myvalues);
690
-
691
- }
692
-
693
- /**
694
- * validate the fields type(defined in each model) in the save procedure
695
- * @return type
696
- */
697
- function validateFields(){
698
- $error=false;
699
- foreach($this->values as $key =>$val){
700
- if(isset($this->columns[$key]['req']) && !$val && $this->columns[$key]['type']!='boolean'){
701
- $this->error(sprintf(__('Field "%1$s" is required in table "%2$s".',WYSIJA), $key,$this->table_name),true);
702
- $error=true;
703
- }
704
- /* let's correct the type of the values based on the one defined in the model*/
705
- switch($this->columns[$key]['type']){
706
- case "email":
707
- $userHelper = WYSIJA::get('user','helper');
708
- if(!$userHelper->validEmail($val)){
709
- $this->error(sprintf(__('Field "%1$s" needs to be a valid Email.',WYSIJA), $key),true);
710
- $error=true;
711
- }
712
- break;
713
- }
714
- }
715
-
716
- if($error) return false;
717
- return true;
718
- }
719
-
720
- /**
721
- * delete procedure
722
- * @global type $wpdb
723
- * @param type $conditions
724
- * @return type
725
- */
726
- function delete($conditions){
727
- $query='DELETE FROM `'.$this->getPrefix().$this->table_name.'`';
728
-
729
- if($this->setConditions($conditions)){
730
- $whereQuery=$this->makeWhere();
731
- if(!$whereQuery){
732
- $this->error('Cannot delete element without conditions in model : '.get_class($this));
733
- }
734
- }else{
735
- $this->error('Cannot delete element without conditions in model : '.get_class($this));
736
- return false;
737
- }
738
- $result=$this->beforeDelete($conditions);
739
- if($result) $result=$this->query($query.$whereQuery);
740
- else return false;
741
- $this->afterDelete();
742
-
743
- return true;
744
- }
745
-
746
- function exists($conditions){
747
-
748
- $query='SELECT '.$this->getPk().' FROM `'.$this->getSelectTableName().'`';
749
-
750
- $query.=$this->makeJoins();
751
- if($this->setConditions($conditions)){
752
- $whereQuery=$this->makeWhere();
753
- if(!$whereQuery){
754
- $this->error('Cannot test element without conditions in model : '.get_class($this));
755
- }
756
- }else{
757
- $this->error('Cannot test element without conditions in model : '.get_class($this));
758
- return false;
759
- }
760
- $res=$this->query('get_res',$query.$whereQuery, ARRAY_A);
761
- if($res) return $res;
762
- else return false;
763
- }
764
-
765
- function getPk($numb=0){
766
- $pk=$this->pk;
767
- if(is_array($pk)) $pk=$pk[$numb];
768
- return $pk;
769
- }
770
-
771
- /**
772
- * set the values after verifying them
773
- * @param type $values
774
- * @return type
775
- */
776
- function setValues($values){
777
- if($this->colCheck && !$this->checkAreColumns($values)) return false;
778
-
779
- $this->values=array();
780
- $this->values=$values;
781
- return true;
782
- }
783
-
784
- /**
785
- *
786
- * @param type $values
787
- * @return type
788
- */
789
- function setJoin($joins){
790
- $this->joins=$joins;
791
- return true;
792
- }
793
-
794
- /**
795
- * set the conditions after verifying them
796
- * @param type $conditions
797
- * @return type
798
- */
799
- function setConditions($conditions,$update=false){
800
- if($conditions && is_array($conditions)){
801
-
802
- $this->conditions=array();
803
- if($update){
804
- foreach($conditions as $key =>$cond){
805
- if($this->colCheck && !$this->checkAreColumns($conditions)) return false;
806
-
807
- if(is_array($cond)){
808
- $this->specialUpdate=true;
809
- $this->conditions=$conditions;
810
-
811
- return true;
812
- }else $this->conditions[$key]=$cond;
813
-
814
- }
815
- } else {
816
- foreach($conditions as $key => $cond) {
817
- if(!in_array($key, $this->comparisonKeys /*array('like','equal','notequal','greater','less','greater_eq','less_eq')*/)){
818
- if($this->colCheck && !$this->checkAreColumns($conditions)) return false;
819
- if(array_key_exists('equal', $this->conditions) === false) $this->conditions['equal'] = array();
820
- $this->conditions['equal'][$key] = $cond;
821
- }else{
822
- if($this->colCheck && !$this->checkAreColumns($cond)) return false;
823
- $this->conditions[$key]=$cond;
824
- }
825
-
826
- }
827
- }
828
-
829
- return true;
830
- }else return false;
831
- }
832
-
833
- /**
834
- * check that the columns corresponds to the columns in the model
835
- * @param type $arrayColumns
836
- * @return type
837
- */
838
- function checkAreColumns($columns){
839
- if($this->noCheck) return true;
840
- foreach($columns as $column => $values) {
841
- // skip when column is a comparison key
842
- if(in_array($column, $this->comparisonKeys)) continue;
843
-
844
- $columnName = $column;
845
- if(!isset($this->columns[$columnName])){
846
- $this->error(sprintf('Column %1$s does not exist in model : %2$s', $columnName, get_class($this)));
847
- return false;
848
- }
849
- }
850
- return true;
851
- }
852
-
853
- function query($query,$arg2="",$arg3=ARRAY_A){
854
- global $wpdb;
855
- $this->sql_error=false;
856
- if(!$arg2) $query=str_replace(array('[wysija]','[wp]'),array($this->getPrefix(),$wpdb->prefix),$query);
857
- else $arg2=str_replace(array('[wysija]','[wp]'),array($this->getPrefix(),$wpdb->prefix),$arg2);
858
-
859
- switch($query){
860
- case 'get_row':
861
- if($this->dbg) $this->keepQry($arg2,'query');
862
-
863
- $resultss=$wpdb->get_row($arg2,$arg3);
864
- $this->logError();
865
- return $resultss;
866
- break;
867
- case 'get_res':
868
- if($this->dbg) $this->keepQry($arg2,'query');
869
- $results=$wpdb->get_results($arg2,$arg3);
870
- //$this->escapeQuotesFromRes($results);
871
- $this->logError();
872
- return $results;
873
- break;
874
- default:
875
- if($this->dbg) $this->keepQry($query,'query');
876
-
877
- $result=$wpdb->query($query);
878
- $this->logError();
879
- if(substr($query, 0, 6)=='INSERT') return $wpdb->insert_id;
880
- else return $result;
881
- }
882
-
883
- }
884
-
885
- function logError(){
886
- if(defined('WYSIJA_DBG') && WYSIJA_DBG>1){
887
- global $wysija_queries_errors, $wpdb;
888
- if(!$wysija_queries_errors) $wysija_queries_errors=array();
889
-
890
- $this->sql_error=mysql_error($wpdb->dbh);
891
-
892
- if($this->sql_error) {
893
- $wysija_queries_errors[]=$this->sql_error;
894
- WYSIJA::log('queries_errors',$this->sql_error,'query_errors');
895
- }
896
-
897
- }
898
-
899
- }
900
-
901
- function keepQry($qry=false,$from='wpdb'){
902
- global $wpdb,$wysija_queries;
903
- if($qry) $wysija_queries[]='[FROM '.$from.']'.$qry;
904
- else $wysija_queries[$from][]='[FROM '.$from.']'.$wpdb->last_query;
905
- }
906
-
907
- function getAffectedRows(){
908
- global $wpdb;
909
- return $wpdb->rows_affected;
910
- //return mysql_affected_rows( $this->dbh );
911
- }
912
-
913
- function getErrorMsg(){
914
- global $wpdb;
915
- return $wpdb->show_errors();
916
- }
917
- /**
918
- * get the full prefix for the table
919
- * @global type $wpdb
920
- * @return type
921
- */
922
- function getPrefix(){
923
- if($this->tableWP) return $this->wpprefix.$this->table_prefix;
924
- else return $this->wpprefix.$this->table_prefix.'_';
925
- }
926
-
927
- /**
928
- * this function allows you to get the prefix from the main site on a multisite
929
- * @return type
930
- */
931
- function get_site_prefix($blog_id=1){
932
-
933
- switch_to_blog( $blog_id );
934
- global $wpdb;
935
- $main_site_prefix=$wpdb->prefix;
936
- restore_current_blog();
937
-
938
- if($this->tableWP) return $main_site_prefix.$this->table_prefix;
939
- else return $main_site_prefix.$this->table_prefix.'_';
940
- }
941
-
942
- function beforeInsert(){
943
- return true;
944
- }
945
-
946
- function afterInsert($resultSaveID){
947
- return true;
948
- }
949
- function beforeDelete($conditions){
950
- return true;
951
- }
952
-
953
- function afterDelete(){
954
- return true;
955
- }
956
-
957
- function beforeUpdate(){
958
- return true;
959
- }
960
-
961
- function afterUpdate($resultSaveID){
962
- return true;
963
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
964
 
965
  }
2
  defined('WYSIJA') or die('Restricted access');
3
  class WYSIJA_model extends WYSIJA_object{
4
 
5
+ var $table_prefix='wysija';
6
+ var $table_name='';
7
+ var $pk='';
8
+ var $values=array();
9
+ var $conditions=array();
10
+ var $orderby=array();
11
+ var $groupby=false;
12
+ var $noCheck =false;
13
+ var $replaceQRY=false;
14
+ var $limitON=false;
15
+ var $dbg=false;
16
+ var $colCheck=true;
17
+ var $getFormat=ARRAY_A;
18
+ var $getOne=false;
19
+ var $fieldValid=true;
20
+ var $specialUpdate=false;
21
+ var $escapeFields=array();
22
+ var $escapingOn=false;
23
+ var $tableWP=false;
24
+ var $columns=array();
25
+ var $joins=array();
26
+ var $ignore = false;
27
+ var $sql_error = false;
28
+ var $last_error = '';
29
+ var $comparisonKeys = array('equal', 'notequal', 'like', 'greater', 'less', 'greater_eq', 'less_eq', 'is');
30
+ var $time_start = 0;
31
+ var $query_duration = 0;
32
+
33
+ function WYSIJA_model($extensions=''){
34
+ if(defined('WYSIJA_DBG') && WYSIJA_DBG>0) $this->dbg=true;
35
+ global $wpdb;
36
+ $this->wpprefix=$wpdb->prefix;
37
+ if($extensions) $this->table_prefix=$extensions;
38
+ //fix for radiokapi
39
+ //$this->wpprefix=$wpdb->base_prefix;
40
+ }
41
+ /**
42
+ * since we reuse the same objects accross the whole application
43
+ * once in a while for instance between a delete and a select we need to reset the objects to update the conditions
44
+ */
45
+ function reset(){
46
+ $this->values = array();
47
+ $this->conditions = array();
48
+ $this->orderby = array();
49
+ $this->groupby = false;
50
+ $this->getFormat = ARRAY_A;
51
+ $this->getOne = false;
52
+ $this->limitON = false;
53
+ $this->sql_error = false;
54
+ $this->last_error = '';
55
+ }
56
+
57
+ /**
58
+ *
59
+ * @param type $columnsOrPKval
60
+ * @param type $conditions
61
+ * @return type
62
+ */
63
+ function get($columnsOrPKval=false,$conditions=array()){
64
+ /*then columns becomes the pk value*/
65
+ if(!$conditions){
66
+ $conditions=array('equal'=>array($this->pk=>$columnsOrPKval));
67
+ $columnsOrPKval=false;
68
+ $this->noCheck=true;
69
+ }
70
+
71
+ /* if we pass just the id strong in the get conditions then it's the pk*/
72
+ if($conditions && !is_array($conditions)){
73
+ $conditions=array('equal'=>array($this->pk=>$conditions));
74
+ }
75
+ if($this->setConditions($conditions)){
76
+ if($this->getOne) $results=$this->getRows($columnsOrPKval,0,1);
77
+ else $results=$this->getRows($columnsOrPKval);
78
+ //$this->escapeQuotesFromRes($results);
79
+ if($this->getOne && count($results)==1){
80
+ switch($this->getFormat){
81
+ case ARRAY_A:
82
+ foreach($results as $res)return $res;
83
+ break;
84
+ case OBJECT:
85
+ foreach($results as $res)return $res;
86
+ break;
87
+ }
88
+ }
89
+ else return $results;
90
+ }
91
+
92
+ return false;
93
+ }
94
+
95
+ function getOne($columnsOrPKval=false,$conditions=array()){
96
+ $this->getOne=true;
97
+ $this->limitON=true;
98
+
99
+ return $this->get($columnsOrPKval,$conditions);
100
+ }
101
+
102
+ /**
103
+ * get a list of result based on a select query
104
+ * @global type $wpdb
105
+ * @param type $columns
106
+ * @param type $page
107
+ * @param type $limit
108
+ * @return type
109
+ */
110
+ function getRows($columns=false,$page=0,$limit=false){
111
+
112
+ /*set the columns*/
113
+ if($columns){
114
+ if(is_array($columns)){
115
+ $columns=implode(', ',$columns);
116
+ }
117
+ }else $columns='*';
118
+
119
+
120
+ $query='SELECT '.$columns.' FROM `'.$this->getSelectTableName()."`";
121
+ $query.=$this->makeJoins();
122
+ $query.=$this->makeWhere();
123
+ $query.=$this->makeGroupBY();
124
+ $query.=$this->makeOrderBY();
125
+
126
+ if($this->limitON) $query.=$this->setLimit($page,$limit);
127
+ $results=$this->query('get_res',$query,$this->getFormat);
128
+
129
+ //$this->escapeQuotesFromRes($results);
130
+
131
+ return $results;
132
+ }
133
+
134
+ function escapeQuotesFromRes(&$results){
135
+ if(!$this->escapingOn) return false;
136
+ foreach($results as $k =>$r){
137
+
138
+ if(in_array($this->getFormat,array(ARRAY_A,ARRAY_N))){
139
+ foreach($r as $k1 =>$v1){
140
+ if(in_array($k1,$this->escapeFields)){
141
+ $results[$k][$k1]= stripslashes($v1);
142
+ }
143
+ }
144
+ }
145
+ }
146
+ }
147
+
148
+ function setLimit($page=0,$limit=false){
149
+ /*set the limit of the selection*/
150
+
151
+ if(!$this->getOne){
152
+ if($page==0){
153
+ if(isset($_REQUEST['pagi'])){
154
+ $page=(int)$_REQUEST['pagi'];
155
+ if($page!=0) $page=$page-1;
156
+ }
157
+
158
+ }else $page=$page-1;
159
+ }
160
+
161
+ if(!$limit){
162
+ if(isset($this->limit_pp)) $limit=$this->limit_pp;
163
+ else{
164
+ $config=WYSIJA::get('config','model');
165
+ $limit=$config->getValue('limit_listing');
166
+ }
167
+ }
168
+
169
+ $this->limit=(int)$limit;
170
+ $this->page=$page;
171
+ $this->limit_start=(int)($this->page*$this->limit);
172
+ $this->limit_end=(int)($this->limit_start+$this->limit);
173
+
174
+ return " LIMIT $this->limit_start , $this->limit";
175
+ }
176
+
177
+ /**
178
+ * DEPRECATED
179
+ * to have a custom query through the model and get the result immediately
180
+ * @param type $query
181
+ * @return type
182
+ */
183
+ function getResults($query,$type=ARRAY_A){
184
+ return $this->query('get_res',$query, $type);
185
+ }
186
+
187
+ /**
188
+ * to have a custom query through the model and get the result immediately
189
+ * @param type $query
190
+ * @return type
191
+ */
192
+ public function get_results($query,$type=ARRAY_A){
193
+ return $this->getResults($query,$type);
194
+ }
195
+
196
+
197
+ function getSelectTableName(){
198
+ if($this->joins && isset($this->joins['tablestart'])){
199
+ if(isset($this->joins['prefstart'])) return $this->wpprefix.$this->joins['prefstart'].'_'.$this->joins['tablestart'];
200
+ else return $this->getPrefix().$this->joins['tablestart'];
201
+ }else return $this->getPrefix().$this->table_name;
202
+ }
203
+
204
+ /**
205
+ * simple SQL count
206
+ * @global type $wpdb
207
+ * @return type
208
+ */
209
+ function count($query=false,$keygetcount=false){
210
+ if(!$query){
211
+ $groupBy=$this->makeGroupBY();
212
+ $columnMore='';
213
+ if($groupBy) $columnMore=','.$this->groupby;
214
+ $query='SELECT COUNT('.$this->getPk().') as count '.$columnMore.' FROM `'.$this->getSelectTableName().'`';
215
+ $query.=$this->makeJoins();
216
+
217
+ $query.=$this->makeWhere();
218
+ $query.=$groupBy;
219
+ }
220
+
221
+
222
+ // if dbg is on we track the duration of the query
223
+ if($this->dbg){
224
+ $this->timer_start();
225
+ }
226
+ $results=$this->query('get_res',$query,$this->getFormat);
227
+
228
+ // if dbg is on we track the duration of the query
229
+ if($this->dbg){
230
+ $this->timer_stop();
231
+ $this->keepQry('count');
232
+ }
233
+
234
+ if(!$results || count($results)>1) return $results;
235
+ else {
236
+ if($keygetcount) return $results[0][$keygetcount];
237
+ else{
238
+ foreach($results[0] as $key => $count) return $count;
239
+ }
240
+ }
241
+
242
+
243
+ return $results;
244
+ }
245
+
246
+ /**
247
+ * make the SQL WHERE condition string
248
+ * @return string
249
+ */
250
+ function makeWhere(){
251
+ $query='';
252
+ if($this->conditions){
253
+ /*set the WHERE clause*/
254
+ $conditions=array();
255
+ foreach($this->conditions as $type=>$values){
256
+ if(!in_array($type, $this->comparisonKeys)){
257
+ $conditionsss=$this->conditions;
258
+ $this->conditions=array();
259
+ $this->conditions['equal']=$conditionsss;
260
+
261
+ break;
262
+ }
263
+ }
264
+ foreach($this->conditions as $type=>$values){
265
+ if($type=='like' && count($values)>1){
266
+ if(is_array($values)){
267
+ $total=count($values);
268
+ $i=1;
269
+ $likeCond='';
270
+ foreach($values as $qfield => $qval){
271
+ $likeCond.=$qfield." LIKE '%".esc_sql(addcslashes($qval, '%_' ))."%'";
272
+ if($i<$total){
273
+ $likeCond.=' OR ';
274
+ }
275
+ $i++;
276
+ }
277
+ $conditions[]='('.$likeCond.')';
278
+ }
279
+ continue;
280
+ }
281
+ foreach($values as $condK => $condVal){
282
+
283
+ //secure from injections
284
+ $this->_secureFieldVal($condK, $condVal);
285
+
286
+ switch($type){
287
+ case 'equal':
288
+ if(is_array($condVal)){
289
+ $conditions[]=$condK.' IN ("'.implode('","', $condVal).'")';
290
+ }else{
291
+ if(is_null($condVal)) {
292
+ $conditions[] = $condK.' IS NULL';
293
+ } else {
294
+ if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
295
+ $conditions[] = $condK.'='.$condVal;
296
+ }
297
+ }
298
+ break;
299
+ case 'notequal':
300
+ if(is_array($condVal)){
301
+ $conditions[]=$condK.' NOT IN ("'.implode('","', $condVal).'")';
302
+ }else{
303
+ //this means that if I delete something with a list of ids and the array happens to be empty array of ids it will just delete everything by
304
+ if(is_null($condVal)) {
305
+ $conditions[] = $condK.' IS NOT NULL';
306
+ } else {
307
+ if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
308
+ $conditions[] = $condK.' != '.$condVal;
309
+ }
310
+ }
311
+ break;
312
+ case 'like':
313
+ $conditions[]=$condK." LIKE '%".esc_sql(addcslashes($condVal, '%_' ))."%'";
314
+ break;
315
+ case 'greater':
316
+ if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
317
+ $conditions[]=$condK.' > '.$condVal;
318
+ break;
319
+ case 'less':
320
+ if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
321
+ $conditions[]=$condK.' < '.$condVal;
322
+ break;
323
+ case 'greater_eq':
324
+ if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
325
+ $conditions[]=$condK.' >= '.$condVal;
326
+ break;
327
+ case 'less_eq':
328
+ if(is_numeric($condVal) === false) $condVal = '"'.$condVal.'"';
329
+ $conditions[]=$condK.' <= '.$condVal;
330
+ break;
331
+ case 'is':
332
+
333
+ $conditions[]=$condK.' '.$condVal;
334
+ break;
335
+ }
336
+ }
337
+
338
+ }
339
+
340
+ $query.=' WHERE '.implode(' AND ',$conditions);
341
+ }
342
+
343
+ return $query;
344
+ }
345
+
346
+ /**
347
+ * make the SQL ORDER BY condition string
348
+ * @return string
349
+ */
350
+ function makeOrderBY(){
351
+ $query=' ORDER BY ';
352
+ if($this->orderby){
353
+ /*set the ORDER BY clause*/
354
+ $query.=$this->orderby.' '.$this->orderbyt;
355
+ }else{
356
+ /*by default we order by pk desc*/
357
+ if(is_array($this->pk)) return '';
358
+ $query.=$this->pk.' DESC';
359
+ }
360
+ return $query;
361
+ }
362
+
363
+
364
+ function makeJoins(){
365
+
366
+ if($this->joins){
367
+ $join=' as A';
368
+ $arrayLetters=array('B','C','D','E');
369
+ foreach($this->joins['tablejoins'] as $table => $fk){
370
+ $letter=array_shift($arrayLetters);
371
+ $join.=' JOIN `'.$this->getPrefix().$table.'` AS '.$letter." on $letter.$fk=A.".$this->joins['keystart'].' ';
372
+ }
373
+ /*set the ORDER BY clause*/
374
+ return $join;
375
+ }else return '';
376
+
377
+ }
378
+ /**
379
+ * make the SQL ORDER BY condition string
380
+ * @return string
381
+ */
382
+ function makeGroupBY(){
383
+
384
+ if($this->groupby){
385
+ /*set the ORDER BY clause*/
386
+ return ' GROUP BY '.$this->groupby;
387
+ }else return '';
388
+
389
+ }
390
+ function groupBy($name){
391
+
392
+ if (!is_string($name) OR preg_match('|[^a-z0-9#_.-]|i',$name) !== 0 ){
393
+ $this->groupby=false;
394
+ }else $this->groupby=$name;
395
+ }
396
+ function orderBy($name,$type = 'ASC'){
397
+
398
+ if(is_array($name) and count($name) > 0) {
399
+ // set order by to empty string
400
+ $this->orderby = '';
401
+ $this->ordert = '';
402
+
403
+ // count number of arguments
404
+ $count = count($name);
405
+
406
+ // build order by query
407
+ for($i = 0; $i < $count; $i++) {
408
+
409
+ $value = current($name);
410
+
411
+ //security escaping
412
+ if(!is_string(key($name)) OR preg_match('|[^a-z0-9#_.-]|i',key($name)) !== 0 ){
413
+ $orderByCol="";
414
+ }else $orderByCol=key($name);
415
+ //security escaping
416
+ if(!is_string($value) OR preg_match('|[^a-z0-9#_.-]|i',$value) !== 0 ){
417
+ $orderByVal="";
418
+ }else $orderByVal=$value;
419
+
420
+ if($i === ($count - 1)) {
421
+ $this->orderby .= $orderByCol;
422
+ $this->ordert = $orderByVal;
423
+ } else {
424
+ $this->orderby .=$orderByCol.' '.$orderByVal;
425
+ $this->orderby .= ', ';
426
+ next($name);
427
+ }
428
+ }
429
+ } else if(!is_string($name) OR preg_match('|[^a-z0-9#_.-]|i',$name) !== 0 ){
430
+ $this->orderby="";
431
+ }else {
432
+ $this->orderby=$name;
433
+ }
434
+
435
+ if(!in_array($type,array('DESC','ASC'))) $type = 'DESC';
436
+ $this->orderbyt=$type;
437
+ }
438
+
439
+
440
+
441
+ /**
442
+ * prepare for an insert procedure
443
+ * @param type $values
444
+ */
445
+ function insert($values,$ignore=false){
446
+ if($ignore)$this->ignore=true;
447
+ if($this->setValues($values)){
448
+ return $this->save();
449
+ }else{
450
+ $this->error(sprintf('missing values in model insert : %1$s.', get_class($this)));
451
+ }
452
+ }
453
+
454
+
455
+ function replace($values=array()){
456
+ $this->replaceQRY=true;
457
+ $this->insert($values);
458
+ $this->replaceQRY=false;
459
+ }
460
+
461
+ /**
462
+ * prepare for an update procedure
463
+ * @param type $values
464
+ * @param type $conditions
465
+ */
466
+ function update($values=array(),$conditions=array()){
467
+
468
+ if($this->setValues($values)){
469
+ /*if no condition is set then we set it mannualy based on the primary key*/
470
+ if(!$conditions){
471
+ if(!$this->conditions){
472
+ if(isset($values[$this->pk]) && $values[$this->pk]){
473
+
474
+ $this->setConditions(array($this->pk => $values[$this->pk]), true);
475
+
476
+ unset($values[$this->pk]);
477
+
478
+ return $this->save(true);
479
+
480
+ }else{
481
+ $this->error(sprintf('missing pk value in model update : %1$s.', get_class($this)));
482
+ }
483
+ }
484
+
485
+ }else{
486
+ if($this->setConditions($conditions,true)){
487
+ return $this->save(true);
488
+ }else{
489
+ $this->error(sprintf('missing conditions in model update : %1$s.', get_class($this)));
490
+ }
491
+ }
492
+
493
+ }else{
494
+ $this->error(sprintf('missing values in model update : %1$s.', get_class($this)));
495
+ }
496
+ }
497
+
498
+ /**
499
+ * UPDATE with a special where condition
500
+ * @param type $table
501
+ * @param type $data
502
+ * @param type $where
503
+ * @param type $format
504
+ * @param type $where_format
505
+ * @return type
506
+ */
507
+ function specialUpdate( $table, $data, $where, $format = null, $where_format = null ) {
508
+ if ( ! is_array( $data ) || ! is_array( $where ) )
509
+ return false;
510
+
511
+ $formats = $format = (array) $format;
512
+ $bits = $wheres = array();
513
+
514
+ $i=0;
515
+ foreach ( $data as $field => $val) {
516
+ $this->_secureFieldVal($field,$val);
517
+
518
+ switch($format[$i]){
519
+ case "%d":
520
+ $bits[] = "`$field` = ".(int)$val;
521
+ break;
522
+ case '[increment]':
523
+ $bits[] = "`$field` = ".$field.'+1';
524
+ break;
525
+ case '[decrement]':
526
+ $bits[] = "`$field` = ".$field.'-1';
527
+ break;
528
+ default :
529
+ $bits[] = "`$field` = '".$val."'";
530
+ }
531
+ $i++;
532
+ }
533
+
534
+ $sql = "UPDATE `$table` SET " . implode( ', ', $bits ) . ' ' . $this->makeWhere();
535
+ return $this->query( $sql );
536
+ }
537
+
538
+
539
+ function _secureFieldVal( &$field, &$mixed ) {
540
+ if ( ! is_string( $field ) || preg_match( '|[^a-z0-9#_.-]|i', $field ) !== 0 ) {
541
+ die('field "'.$field .'" not secured');
542
+ }
543
+ if ( is_string( $mixed ) || is_numeric( $mixed ) || is_bool( $mixed ) ) {
544
+ $mixed = esc_sql( $mixed );
545
+ } else {
546
+ if(!empty($mixed) && is_array($mixed)){
547
+ foreach ( $mixed as $key => &$value ) {
548
+ $this->_secureFieldVal( $field, $value );
549
+ }
550
+ }
551
+ }
552
+ }
553
+ /**
554
+ * save information as an update or an insert
555
+ * @global type $wpdb
556
+ * @param type $update
557
+ * @return type
558
+ */
559
+ function save($update=false){
560
+
561
+ if($update)$updateStr='Update';
562
+ else $updateStr='Insert';
563
+ $beforeSave='before'.$updateStr;
564
+ $afterSave='after'.$updateStr;
565
+
566
+
567
+
568
+ if(!$update && isset($this->columns['created_at']))$this->values['created_at']=time();
569
+ foreach($this->columns as $key => $params){
570
+ /*check for auto columns */
571
+ if((isset($params['autoup']) && $update) || (!$update && $key!='sent_at')){
572
+ if(isset($params['type']) && !isset($this->values[$key])){
573
+ switch($params['type']){
574
+ case 'date':
575
+ $this->values[$key]=time();
576
+ break;
577
+ case 'ip':
578
+ $userHelper=WYSIJA::get("user","helper");
579
+ /*record the ip and save the user*/
580
+ $this->values[$key]=$userHelper->getIP();
581
+ break;
582
+ case 'referer':
583
+ /*record the ip and save the user*/
584
+ $this->values[$key]=$_SERVER['HTTP_REFERER'];
585
+ break;
586
+ }
587
+ }
588
+
589
+ }
590
+ }
591
+
592
+ if(method_exists($this,$beforeSave)){
593
+ if(!$this->$beforeSave()){
594
+ //$this->error(sprintf('Problem during validation "%2$s" in model : %1$s.', get_class($this), $beforeSave));
595
+ return false;
596
+ }
597
+ }
598
+
599
+ /*prepare a format list for the update and insert function*/
600
+ $fieldsFormats=array();
601
+ if(!is_array($this->pk) && isset($this->values[$this->pk])) unset($this->values[$this->pk]);
602
+ foreach($this->values as $key =>$val){
603
+ if(!isset($this->columns[$key]['html'])) $this->values[$key]=strip_tags($val);
604
+ /* let's correct the type of the values based on the one defined in the model*/
605
+ if(in_array($val, array('[increment]','[decrement]'))){
606
+ $fieldsFormats[]=$val;
607
+ $this->specialUpdate=true;
608
+ }else{
609
+ //dbg($this->values);
610
+ if(!isset($this->columns[$key]['type'])){
611
+ $this->columns[$key]['type']='default';
612
+ }
613
+ switch($this->columns[$key]['type']){
614
+ case 'integer':
615
+ case 'boolean':
616
+ $fieldsFormats[]="%d";
617
+ break;
618
+ default:
619
+ $fieldsFormats[]="%s";
620
+
621
+ }
622
+ }
623
+
624
+ }
625
+
626
+ if($this->fieldValid && !$this->validateFields()) {
627
+ $this->error(__('Error Validating the fields',WYSIJA),true);
628
+ $this->stay=true;
629
+ return false;
630
+ }
631
+
632
+ global $wpdb;
633
+
634
+ // if dbg is on we track the duration of the query
635
+ if($this->dbg){
636
+ $this->timer_start();
637
+ }
638
+
639
+ if($update){
640
+
641
+ if( $this->specialUpdate || isset($this->conditions['equal']) || isset($this->conditions['notequal']) || isset($this->conditions['like'])){
642
+
643
+ $resultSave=$this->specialUpdate($this->getPrefix().$this->table_name,$this->values,$this->conditions,$fieldsFormats);
644
+ $this->logError();
645
+ }else{
646
+
647
+ $wpdb->update($this->getPrefix().$this->table_name,$this->values,$this->conditions,$fieldsFormats);
648
+ $this->logError();
649
+ $resultSave=$wpdb->result;
650
+ }
651
+
652
+ }else{
653
+ if($this->replaceQRY){
654
+ $resultSave=$wpdb->replace($this->getPrefix().$this->table_name,$this->values,$fieldsFormats);
655
+ $this->logError();
656
+ }else{
657
+
658
+ if($this->ignore) $resultSave=$wpdb->insert($this->getPrefix().$this->table_name,$this->values,$fieldsFormats);
659
+ else $resultSave=$wpdb->insert($this->getPrefix().$this->table_name,$this->values,$fieldsFormats);
660
+
661
+ $this->logError();
662
+ //dbg('hello');
663
+ }
664
+
665
+ }
666
+
667
+ // if dbg is on we track the duration of the query
668
+ if($this->dbg){
669
+ $this->timer_stop();
670
+ $this->keepQry('save');
671
+ }
672
+
673
+ if(!$resultSave){
674
+ $wpdb->show_errors();
675
+ return false;
676
+ }else{
677
+ if($update){
678
+ if(isset($this->conditions[$this->getPk()])){
679
+ $resultSave=$this->conditions[$this->getPk()];
680
+ }else{
681
+ if(isset($this->conditions[$this->getPk(1)])) $resultSave=$this->conditions[$this->getPk(1)];
682
+ }
683
+
684
+ }else{
685
+ $resultSave=$wpdb->insert_id;
686
+ }
687
+ }
688
+
689
+ $wpdb->flush();
690
+
691
+ if(method_exists($this,$afterSave)){
692
+ if(!$this->$afterSave($resultSave)){
693
+ //$this->error(sprintf('Problem during validation "%2$s" in model : %1$s.', get_class($this), $afterSave));
694
+ return false;
695
+ }
696
+ }
697
+ return $resultSave;
698
+ }
699
+
700
+
701
+ function insertMany($values){
702
+ $fields=array_keys($values[0]);
703
+
704
+ $query='INSERT INTO `'.$this->getPrefix().$this->table_name.'` (`' . implode( '`,`', $fields ) . '`) VALUES ';
705
+
706
+ $total=count($values);
707
+ $i=1;
708
+ foreach($values as &$vals){
709
+ foreach($vals as &$v) $v=esc_sql($v);
710
+ $query.= "('" . implode( "','", $vals )."')";
711
+ if($i<$total) $query.=',';
712
+ $i++;
713
+ }
714
+
715
+ $this->query($query.$myvalues);
716
+
717
+ }
718
+
719
+ /**
720
+ * validate the fields type(defined in each model) in the save procedure
721
+ * @return type
722
+ */
723
+ function validateFields(){
724
+ $error=false;
725
+ foreach($this->values as $key =>$val){
726
+ if(isset($this->columns[$key]['req']) && !$val && $this->columns[$key]['type']!='boolean'){
727
+ $this->error(sprintf(__('Field "%1$s" is required in table "%2$s".',WYSIJA), $key,$this->table_name),true);
728
+ $error=true;
729
+ }
730
+ /* let's correct the type of the values based on the one defined in the model*/
731
+ switch($this->columns[$key]['type']){
732
+ case "email":
733
+ $userHelper = WYSIJA::get('user','helper');
734
+ if(!$userHelper->validEmail($val)){
735
+ $this->error(sprintf(__('Field "%1$s" needs to be a valid Email.',WYSIJA), $key),true);
736
+ $error=true;
737
+ }
738
+ break;
739
+ }
740
+ }
741
+
742
+ if($error) return false;
743
+ return true;
744
+ }
745
+
746
+ /**
747
+ * delete procedure
748
+ * @global type $wpdb
749
+ * @param type $conditions
750
+ * @return type
751
+ */
752
+ function delete($conditions){
753
+ $query='DELETE FROM `'.$this->getPrefix().$this->table_name.'`';
754
+
755
+ if($this->setConditions($conditions)){
756
+ $whereQuery=$this->makeWhere();
757
+ if(!$whereQuery){
758
+ $this->error('Cannot delete element without conditions in model : '.get_class($this));
759
+ }
760
+ }else{
761
+ $this->error('Cannot delete element without conditions in model : '.get_class($this));
762
+ return false;
763
+ }
764
+ $result=$this->beforeDelete($conditions);
765
+ if($result) $result=$this->query($query.$whereQuery);
766
+ else return false;
767
+ $this->afterDelete();
768
+
769
+ return true;
770
+ }
771
+
772
+ function exists($conditions){
773
+
774
+ $query='SELECT '.$this->getPk().' FROM `'.$this->getSelectTableName().'`';
775
+
776
+ $query.=$this->makeJoins();
777
+ if($this->setConditions($conditions)){
778
+ $whereQuery=$this->makeWhere();
779
+ if(!$whereQuery){
780
+ $this->error('Cannot test element without conditions in model : '.get_class($this));
781
+ }
782
+ }else{
783
+ $this->error('Cannot test element without conditions in model : '.get_class($this));
784
+ return false;
785
+ }
786
+ $res=$this->query('get_res',$query.$whereQuery, ARRAY_A);
787
+ if($res) return $res;
788
+ else return false;
789
+ }
790
+
791
+ function getPk($numb=0){
792
+ $pk=$this->pk;
793
+ if(is_array($pk)) $pk=$pk[$numb];
794
+ return $pk;
795
+ }
796
+
797
+ /**
798
+ * set the values after verifying them
799
+ * @param type $values
800
+ * @return type
801
+ */
802
+ function setValues($values){
803
+ if($this->colCheck && !$this->checkAreColumns($values)) return false;
804
+
805
+ $this->values=array();
806
+ $this->values=$values;
807
+ return true;
808
+ }
809
+
810
+ /**
811
+ *
812
+ * @param type $values
813
+ * @return type
814
+ */
815
+ function setJoin($joins){
816
+ $this->joins=$joins;
817
+ return true;
818
+ }
819
+
820
+ /**
821
+ * set the conditions after verifying them
822
+ * @param type $conditions
823
+ * @return type
824
+ */
825
+ function setConditions($conditions,$update=false){
826
+ if($conditions && is_array($conditions)){
827
+
828
+ $this->conditions=array();
829
+ if($update){
830
+ foreach($conditions as $key =>$cond){
831
+ if($this->colCheck && !$this->checkAreColumns($conditions)) return false;
832
+
833
+ if(is_array($cond)){
834
+ $this->specialUpdate=true;
835
+ $this->conditions=$conditions;
836
+
837
+ return true;
838
+ }else $this->conditions[$key]=$cond;
839
+
840
+ }
841
+ } else {
842
+ foreach($conditions as $key => $cond) {
843
+ if(!in_array($key, $this->comparisonKeys /*array('like','equal','notequal','greater','less','greater_eq','less_eq')*/)){
844
+ if($this->colCheck && !$this->checkAreColumns($conditions)) return false;
845
+ if(array_key_exists('equal', $this->conditions) === false) $this->conditions['equal'] = array();
846
+ $this->conditions['equal'][$key] = $cond;
847
+ }else{
848
+ if($this->colCheck && !$this->checkAreColumns($cond)) return false;
849
+ $this->conditions[$key]=$cond;
850
+ }
851
+
852
+ }
853
+ }
854
+
855
+ return true;
856
+ }else return false;
857
+ }
858
+
859
+ /**
860
+ * check that the columns corresponds to the columns in the model
861
+ * @param type $arrayColumns
862
+ * @return type
863
+ */
864
+ function checkAreColumns($columns){
865
+ if($this->noCheck) return true;
866
+ foreach($columns as $column => $values) {
867
+ // skip when column is a comparison key
868
+ if(in_array($column, $this->comparisonKeys)) continue;
869
+
870
+ $columnName = $column;
871
+ if(!isset($this->columns[$columnName])){
872
+ $this->error(sprintf('Column %1$s does not exist in model : %2$s', $columnName, get_class($this)));
873
+ return false;
874
+ }
875
+ }
876
+ return true;
877
+ }
878
+
879
+ function timer_start() {
880
+ $this->query_duration = 0;
881
+ $this->time_start = microtime( true );
882
+ return true;
883
+ }
884
+
885
+ function timer_stop() {
886
+ $this->query_duration = ( microtime( true ) - $this->time_start );
887
+ }
888
+
889
+ function query($query,$arg2='',$arg3=ARRAY_A){
890
+ global $wpdb;
891
+ $this->sql_error = false;
892
+ if(!$arg2) $query = str_replace(array('[wysija]','[wp]'),array($this->getPrefix(),$wpdb->prefix),$query);
893
+ else $arg2 = str_replace(array('[wysija]','[wp]'),array($this->getPrefix(),$wpdb->prefix),$arg2);
894
+
895
+ // if dbg is on we track the duration of the query
896
+ if($this->dbg){
897
+ $this->timer_start();
898
+ }
899
+
900
+ switch($query){
901
+ case 'get_row':
902
+ $result = $wpdb->get_row($arg2,$arg3);
903
+ $this->logError();
904
+ break;
905
+ case 'get_res':
906
+ $result = $wpdb->get_results($arg2,$arg3);
907
+ //$this->escapeQuotesFromRes($results);
908
+ $this->logError();
909
+ break;
910
+ default:
911
+ $result = $wpdb->query($query);
912
+ $this->logError();
913
+
914
+ // get the last insert id if it's an insert query
915
+ if(substr($query, 0, 6) == 'INSERT') $result = $wpdb->insert_id;
916
+
917
+ }
918
+ // if dbg is on we track the duration of the query
919
+ if($this->dbg){
920
+ $this->timer_stop();
921
+ $this->keepQry('query');
922
+ }
923
+ return $result;
924
+ }
925
+
926
+ function logError(){
927
+ if(defined('WYSIJA_DBG') && WYSIJA_DBG>1){
928
+ global $wysija_queries_errors, $wpdb;
929
+ if(!$wysija_queries_errors) $wysija_queries_errors = array();
930
+
931
+ $this->sql_error = $wpdb->last_error;
932
+
933
+ if( $this->sql_error &&
934
+ ( empty( $this->last_error ) || $this->last_error != $this->sql_error )) {
935
+ $this->last_error = $wysija_queries_errors[] = $this->sql_error;
936
+ $this->sql_error = false;
937
+ WYSIJA::log('queries_errors' , $this->sql_error , 'query_errors');
938
+ }
939
+
940
+ }
941
+
942
+ }
943
+
944
+ function keepQry($from = 'wpdb'){
945
+ global $wpdb,$wysija_queries;
946
+ $wysija_queries[$from][] = array('duration' => $this->query_duration , 'query' => $wpdb->last_query);
947
+ }
948
+
949
+ function getAffectedRows(){
950
+ global $wpdb;
951
+ return $wpdb->rows_affected;
952
+ }
953
+
954
+ function getErrorMsg(){
955
+ global $wpdb;
956
+ return $wpdb->show_errors();
957
+ }
958
+ /**
959
+ * get the full prefix for the table
960
+ * @global type $wpdb
961
+ * @return type
962
+ */
963
+ function getPrefix(){
964
+ if($this->tableWP) return $this->wpprefix.$this->table_prefix;
965
+ else return $this->wpprefix.$this->table_prefix.'_';
966
+ }
967
+
968
+ /**
969
+ * this function allows you to get the prefix from the main site on a multisite
970
+ * @return type
971
+ */
972
+ function get_site_prefix($blog_id=1){
973
+
974
+ switch_to_blog( $blog_id );
975
+ global $wpdb;
976
+ $main_site_prefix=$wpdb->prefix;
977
+ restore_current_blog();
978
+
979
+ if($this->tableWP) return $main_site_prefix.$this->table_prefix;
980
+ else return $main_site_prefix.$this->table_prefix.'_';
981
+ }
982
+
983
+ /**
984
+ *
985
+ * @param type $field_name name of field which will become a key
986
+ * @param array $dataset list of records
987
+ * @param boolean $removing_field_name decide if we should remove field name from output dataset
988
+ * @param string $field_name_as_value a field in which we consider its value as value of $field_name
989
+ * @return array field based indexed dataset
990
+ */
991
+ protected function indexing_dataset_by_field($field_name, Array $dataset, $removing_field_name = false, $field_name_as_value = null){
992
+ if (empty($dataset))
993
+ return array();
994
+ $tmp = array();
995
+ foreach ($dataset as $record){
996
+ if (isset($record[$field_name]))
997
+ {
998
+ if (!empty($field_name_as_value)){
999
+ $tmp[$record[$field_name]] = isset($record[$field_name_as_value]) ? $record[$field_name_as_value] : null;
1000
+ continue;
1001
+ }
1002
+ $tmp[$record[$field_name]] = $record;
1003
+ if ($removing_field_name)
1004
+ unset($tmp[$record[$field_name]][$field_name]);
1005
+ }
1006
+
1007
+ }
1008
+ return $tmp;
1009
+ }
1010
+
1011
+ function beforeInsert(){
1012
+ return true;
1013
+ }
1014
+
1015
+ function afterInsert($resultSaveID){
1016
+ return true;
1017
+ }
1018
+ function beforeDelete($conditions){
1019
+ return true;
1020
+ }
1021
+
1022
+ function afterDelete(){
1023
+ return true;
1024
+ }
1025
+
1026
+ function beforeUpdate($id = null){
1027
+ return true;
1028
+ }
1029
+
1030
+ function afterUpdate($resultSaveID){
1031
+ return true;
1032
+ }
1033
 
1034
  }
core/module/module.php ADDED
@@ -0,0 +1,248 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ defined('WYSIJA') or die('Restricted access');
4
+
5
+ class WYSIJA_module extends WYSIJA_control{
6
+
7
+ /**
8
+ * ID of module
9
+ * @var string
10
+ */
11
+ protected $name;
12
+
13
+ /**
14
+ * view class of module
15
+ * @var string
16
+ */
17
+ public $view;
18
+
19
+ /**
20
+ * instance of view class of module
21
+ * @var string
22
+ */
23
+ protected $view_obj;
24
+
25
+
26
+ /**
27
+ * action/view of a hook
28
+ * @var string
29
+ */
30
+
31
+ protected $view_show;
32
+
33
+ /**
34
+ * data which view class will pull from
35
+ * @var array
36
+ */
37
+ protected $data;
38
+
39
+ protected $extended_plugin='wysija-newsletters';
40
+
41
+
42
+
43
+ /**
44
+ * Define hook name and list of modules of each hook
45
+ * @var Array
46
+ * @todo: implement hook management which allows to manage hooks from admin side
47
+ */
48
+
49
+ protected $is_premium = false;
50
+
51
+ public static $hooks = array(
52
+ 'hook_stats' => array(
53
+ // 'stats_newsletters_in_time',
54
+ 'stats_top_newsletters',
55
+ 'stats_top_subscribers',
56
+ 'stats_top_links',
57
+ 'stats_new_subscribers',
58
+ 'stats_subscriptions',
59
+ 'stats_top_domains'
60
+ ),
61
+
62
+ // the left block in the page "subscriber detail"
63
+ 'hook_subscriber_left' => array(
64
+ ),
65
+
66
+ // the righ block in the page "subscriber detail"
67
+ 'hook_subscriber_right' => array(
68
+ 'stats_subscriber'
69
+ ),
70
+ 'hook_subscriber_bottom' => array(
71
+ 'stats_subscribers_std',
72
+ // 'stats_newsletters_in_time' // not in use
73
+ ),
74
+ // top of newsletter (viewstats) page
75
+ 'hook_newsletter_top' => array(
76
+
77
+ 'stats_newsletter_std',
78
+ 'stats_newsletter',
79
+ // 'stats_reportcards_std'
80
+ ),
81
+
82
+ // Newsletters >> Newsletter detail: bottom block
83
+ 'hook_newsletter_bottom' => array(
84
+ //'stats_newsletter_std',
85
+ // 'stats_newsletters_in_time'
86
+ ),
87
+
88
+ // the block "super advanced" in Settings >> Advanced tab
89
+ 'hook_settings_super_advanced' => array(
90
+ 'archive_std'
91
+ ),
92
+
93
+ // event: before saving settings (Admin)
94
+ 'hook_settings_before_save' => array(
95
+ 'archive_std'
96
+ )
97
+ );
98
+ /**
99
+ * Constructor
100
+ * This is neccessary to override default action of WYSIJA_control::WYSIJA_control(),
101
+ * which always tries to load a default view object
102
+ */
103
+ public function __construct() {
104
+ if (!empty($this->model)){
105
+ $class_name = $this->model;
106
+ $this->model_obj = new $class_name();
107
+ $this->model_obj->limit = 0; // quickfix "Undefined property: WYSIJA_model_statistics::$limit in views\back.php::limitPerPage()"
108
+ }
109
+ $this->get_view_obj($this->extended_plugin);
110
+ if (!empty($this->view_obj) && !empty($this->model_obj)){
111
+ $this->view_obj->model = $this->model_obj;
112
+ }
113
+
114
+ $this->data['module_name'] = $this->name;
115
+
116
+
117
+ $model_config=WYSIJA::get('config','model');
118
+ if($model_config->getValue('premium_key'))
119
+ $this->is_premium = true;
120
+ $this->data['is_premium'] = $this->is_premium;
121
+ }
122
+
123
+ /**
124
+ * get name of module
125
+ * @return string
126
+ */
127
+ public function get_name(){
128
+ return $this->name;
129
+ }
130
+
131
+ /**
132
+ * Get unique link to the module and hook. This link will be displayed as an independent page and actually it renders [wysijap] postype
133
+ * @param string $module_name
134
+ * @param string $hook_name
135
+ * @param array $params (key => value, key => value)
136
+ * @return type
137
+ */
138
+ public static function get_module_link($module_name, $hook_name, $extended_plugin='wysija-newsletters', Array $params = array()) {
139
+ $model_config=WYSIJA::get('config','model');
140
+ $params = array_merge($params, array(
141
+ 'wysija-page' => 1,
142
+ 'controller'=>'module',
143
+ 'action' => 'init',
144
+ 'module' => $module_name,
145
+ 'extension' => $extended_plugin,
146
+ 'hook' => $hook_name
147
+ ));
148
+ return WYSIJA::get_permalink($model_config->getValue('confirm_email_link'),$params);
149
+ }
150
+
151
+ /**
152
+ * Return Hooks List
153
+ * @param string $hook_name name of hook
154
+ * @module_name string $module_name name of a specific module
155
+ * @return Array list of modules
156
+ */
157
+ public static function get_modules_from_hook($hook_name, $module_name = null){
158
+ $module_list = self::get_hook_module_list();
159
+ $modules = !empty($module_list[$hook_name]) ? $module_list[$hook_name] : array();
160
+ if ($module_name)
161
+ return isset($modules[$module_name]) ? array($modules[$module_name]) : array();
162
+ return $modules;
163
+ }
164
+
165
+ /**
166
+ * Get all registered hooks and modules
167
+ * @return Array
168
+ */
169
+ public static function get_hook_module_list(){
170
+ return self::$hooks;
171
+ }
172
+
173
+ /**
174
+ * Execute a hook, module by module, from first one to last one
175
+ * @param string $hook_name
176
+ * @param string $params
177
+ * @param string $extended_plugin
178
+ *
179
+ * @todo Performance factor:
180
+ * We are calling the same method for free / Premium version.
181
+ * Some modules don't exist at free side.
182
+ * Some modules don't exist at Premium side.
183
+ * This fact leads to an other fact: we have to check_exist() in both cases.
184
+ * Solution 1: cache by using a static attribute, within this class
185
+ * Solution 2: populate data to an external file (xml), and load that file into this static attribute (with solution 1)
186
+ */
187
+ public static function execute_hook($hook_name, $params, $extended_plugin='wysija-newsletters'){
188
+ $hook_output = '';
189
+ if (!empty(self::$hooks[$hook_name])){
190
+ foreach (self::$hooks[$hook_name] as $module_name){
191
+ $module = WYSIJA::get($module_name,'module',false,$extended_plugin);
192
+ if(!empty($module) && method_exists($module, $hook_name))
193
+ $hook_output .= $module->$hook_name($params);
194
+ }
195
+ }
196
+ return $hook_output;
197
+ }
198
+
199
+ /**
200
+ * get an instance of a module class
201
+ * @param string $module_name module to be loaded
202
+ * @param type $extended_plugin : used only when calling the url from a different plugin it is used watch those files :
203
+ * -core/controller.php line 21, 23 ,24
204
+ * @return an instance of WYSIJA_module or its derived classes
205
+ */
206
+ public static function get_instance_by_name($module_name,$extended_plugin='wysija-newsletters'){
207
+ return WYSIJA::get($module_name,'module',false, $extended_plugin);
208
+ }
209
+
210
+ /**
211
+ * Render a view/action
212
+ * @return string
213
+ */
214
+ public function render($buffering_output = true){
215
+ if (!empty($this->view))
216
+ {
217
+ if ($buffering_output)
218
+ ob_start();
219
+ if (!$buffering_output)
220
+ return $this->get_view_obj()->render($this->view_show, $this->data, true);
221
+ else{
222
+ $this->get_view_obj()->render($this->view_show, $this->data, true);
223
+ $view = ob_get_contents();
224
+ ob_end_clean();
225
+ return $view;
226
+ }
227
+ }
228
+ }
229
+
230
+ /**
231
+ * initialize WYSIJA_view instance
232
+ * @return WYSIJA_view
233
+ */
234
+ protected function get_view_obj(){
235
+ require_once(WYSIJA_CORE.'view.php');
236
+ require_once(WYSIJA_VIEWS.WYSIJA_SIDE.'.php');
237
+ if (empty($this->view_obj)){
238
+
239
+ $view_dir=WYSIJA_PLG_DIR.$this->extended_plugin.DS.'modules'.DS.$this->name; // quickfix, @todo
240
+ $class_path=$view_dir.DS.$this->view.'.php';// @todo: check exists
241
+ $class_name = strtoupper('wysija').'_module_view_'.$this->view;
242
+ require_once(WYSIJA_CORE.'view.php');
243
+ require_once($class_path);
244
+ $this->view_obj = new $class_name();
245
+ }
246
+ return $this->view_obj;
247
+ }
248
+ }
core/module/statistics.php ADDED
@@ -0,0 +1,33 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
+
4
+ class WYSIJA_module_statistics extends WYSIJA_module{
5
+ const GROUP_BY_YEAR = 1;
6
+ const GROUP_BY_MONTH = 2;
7
+ const GROUP_BY_DATE = 3;
8
+ const GROUP_BY_HOUR = 4;
9
+ const GROUP_BY_MINUTE = 5;
10
+
11
+ const ORDER_BY_SENT = 1;
12
+ const ORDER_BY_OPEN = 2;
13
+ const ORDER_BY_CLICK = 3;
14
+ const ORDER_BY_UNSUBSCRIBE = 4;
15
+
16
+ const ORDER_DIRECTION_ASC = 1;
17
+ const ORDER_DIRECTION_DESC = 2;
18
+
19
+ const SWITCHING_DATE_TO_MONTH_THRESHOLD = 90;// if the days between FROM and TO is greater than this value, we will group data by month instead of by date. Useful for charts.
20
+
21
+ const DEFAULT_TOP_RECORDS = 5; // default number of how many first records we should retrieve
22
+
23
+ public function __construct() {
24
+ parent::__construct();
25
+ $this->data['messages'] = $this->init_messages();
26
+ }
27
+
28
+ protected function init_messages() {
29
+ return array(
30
+ 'data_not_available' => __("There's no stats to load!", WYSIJA)
31
+ );
32
+ }
33
+ }
core/module/statistics_model.php ADDED
@@ -0,0 +1,139 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ defined('WYSIJA') or die('Restricted access');
4
+
5
+ class WYSIJA_module_statistics_model extends WYSIJA_model {
6
+
7
+ const STATS_DATE_OF_CREATION = 'STATS_DATE_OF_CREATION';
8
+ /**
9
+ * Time to live of stats data
10
+ */
11
+ const STATS_DATA_LIFE_TIME = 3600; // 1h * 60mins * 60s
12
+ /**
13
+ * Time to live of stats's table (structure)
14
+ */
15
+ const STATS_TABLE_LIFE_TIME = 86400; // 24h * 60mins * 60s
16
+
17
+ const STATS_PREFIX = 'stats_cache_'; // prefix of stat tables
18
+
19
+ public function __construct() {
20
+ parent::WYSIJA_model();
21
+ $this->clean_up_out_of_date_tables();
22
+ }
23
+
24
+ /**
25
+ *
26
+ * @param array $params array of input params
27
+ */
28
+
29
+ public function get_hash(Array $params) {
30
+ return md5(get_class($this) . json_encode($params));
31
+ }
32
+
33
+ /**
34
+ * set a date of creating temporary tables, useful for caching
35
+ * @return type
36
+ */
37
+ protected function set_date_of_creation() {
38
+ $config = WYSIJA::get('config', 'model');
39
+ return $config->save(array(self::STATS_DATE_OF_CREATION => time()));
40
+ }
41
+
42
+ /**
43
+ * Check if cache life time is out of date
44
+ * @return boolean
45
+ */
46
+ protected function is_data_out_of_date() {
47
+ $config = WYSIJA::get('config', 'model');
48
+ $date_of_creation = $config->getValue(self::STATS_DATE_OF_CREATION);
49
+ return (time() - $date_of_creation >= self::STATS_DATA_LIFE_TIME);
50
+ }
51
+
52
+ /**
53
+ * Get the list of tables which are out of date, based on create_time
54
+ * @return type
55
+ */
56
+ protected function get_out_of_date_tables() {
57
+ $query = '
58
+ SELECT
59
+ TABLE_NAME as table_name
60
+ FROM
61
+ INFORMATION_SCHEMA.TABLES
62
+ WHERE
63
+ TABLE_SCHEMA IN (SELECT DATABASE())
64
+ AND TABLE_NAME LIKE "[wysija]'.self::STATS_PREFIX.'%"
65
+ AND TIMESTAMPDIFF(SECOND,CREATE_TIME, NOW()) >= '.self::STATS_TABLE_LIFE_TIME.';
66
+ ';
67
+ return $this->get_results($query);
68
+ }
69
+
70
+ /**
71
+ * Auto cleanup out-of-date tables
72
+ */
73
+ protected function clean_up_out_of_date_tables() {
74
+ $tables = $this->get_out_of_date_tables();
75
+ if (!empty($tables) && is_array($tables)) {
76
+ $_temp = array();
77
+ foreach ($tables as $table)
78
+ if (!empty($table['table_name']))
79
+ $_temp[] = $table['table_name'];
80
+ }
81
+ if (!empty($_temp)) {
82
+ $query = 'DROP TABLE IF EXISTS `'. implode('`,`', $_temp).'`';
83
+ $this->get_results($query);
84
+ }
85
+ }
86
+
87
+ /**
88
+ * Check if a table exists
89
+ * @param string $table_name table name
90
+ * @return boolean
91
+ */
92
+ protected function does_table_exists($table_name = null) {
93
+ if (empty($table_name) OR !is_string($table_name))
94
+ return false;
95
+ $query = "SHOW TABLES LIKE '$table_name'";
96
+ $result = $this->get_results($query);
97
+ return !empty($result) ? true : false;
98
+ }
99
+
100
+ /**
101
+ * Generate a table name, based on input params
102
+ * @param type $params
103
+ */
104
+ protected function get_table_name($params) {
105
+ $hash = $this->get_hash($params);
106
+ return '[wysija]' . self::STATS_PREFIX . $hash;
107
+ }
108
+
109
+ /**
110
+ * Generate a cached table
111
+ * @param type $table_name
112
+ * @param array $queries_create_table query to create a new cached table
113
+ * @param array $queries_insert_data query to collect and insert data to the newly created/truncated table
114
+ * @return boolean
115
+ */
116
+ protected function generate_table($table_name, Array $queries_create_table, Array $queries_insert_data) {
117
+ $is_out_of_date = $this->is_data_out_of_date();
118
+ $does_table_exists = $this->does_table_exists($table_name);
119
+
120
+ if (!$is_out_of_date && $does_table_exists)
121
+ return true;
122
+ if ($does_table_exists) {
123
+ $this->query('TRUNCATE TABLE `' . $table_name . '`');
124
+ } else {
125
+ foreach ($queries_create_table as $query_create_table)
126
+ $this->query($query_create_table);
127
+ }
128
+
129
+ foreach ($queries_insert_data as $query_insert_data)
130
+ $this->query($query_insert_data);
131
+
132
+ if ($is_out_of_date) {
133
+ $this->set_date_of_creation();
134
+ }
135
+
136
+ return true;
137
+ }
138
+
139
+ }
core/module/statisticschart.php ADDED
@@ -0,0 +1,11 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
+
4
+ abstract class WYSIJA_module_statisticschart extends WYSIJA_module_statistics{
5
+ public function __construct() {
6
+ parent::__construct();
7
+ $this->data['js_date_format'] = 'yy/mm/dd';
8
+ }
9
+ public function init(){
10
+ }
11
+ }
core/module/statisticstable.php ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ <?php
2
+ defined('WYSIJA') or die('Restricted access');
3
+
4
+ abstract class WYSIJA_module_statisticstable extends WYSIJA_module_statistics{
5
+ }
core/view.php CHANGED
@@ -8,14 +8,121 @@ class WYSIJA_view extends WYSIJA_object{
8
  var $search=array();
9
  var $cols_nks=array();//correspondance between user_id and user-id once processed
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  function WYSIJA_view(){
12
 
13
  }
14
 
15
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16
 
17
  function renderErrorInstall(){
18
- $this->title=__("Your server's configuration doesn't allow us to complete Wysija's Installation!",WYSIJA);
19
  $this->header();
20
  $this->footer();
21
  }
@@ -24,14 +131,19 @@ class WYSIJA_view extends WYSIJA_object{
24
  *
25
  * @param type $type
26
  * @param type $data
 
27
  */
28
- function render($type,$data){
29
  $this->action=$type;
30
- $this->header($data);
 
 
31
  if($type !== NULL) {
32
  $this->$type($data);
33
  }
34
- $this->footer();
 
 
35
  }
36
 
37
  /**
@@ -39,7 +151,7 @@ class WYSIJA_view extends WYSIJA_object{
39
  * @global type $wysija_msg
40
  */
41
  function messages($noglobal=false){
42
- $wysija_msg=$this->getMsgs();
43
 
44
  if(isset($wysija_msg['g-updated'])) {
45
  if(!$noglobal) {
@@ -55,18 +167,39 @@ class WYSIJA_view extends WYSIJA_object{
55
  }
56
  unset($wysija_msg['g-error']);
57
  }
58
-
59
  $wpnonce='<input type="hidden" value="'.wp_create_nonce("wysija_ajax").'" id="wysijax" />';
60
  if(!$wysija_msg) return '<div class="wysija-msg ajax"></div>'.$wpnonce;
61
  $html='<div class="wysija-msg">';
62
-
63
  foreach($wysija_msg as $level =>$messages){
64
- $html.='<div class="'.$level.'">';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
65
  $html.='<ul>';
66
 
67
  if(count($messages)>0){
68
  foreach($messages as $msg){
69
- $html.='<li>'.$msg.'</li>';
 
 
 
 
 
 
70
  }
71
  }
72
 
@@ -74,8 +207,8 @@ class WYSIJA_view extends WYSIJA_object{
74
  $html.='</ul>';
75
  $html.='</div>';
76
  }
77
-
78
  $html.='</div><div class="wysija-msg ajax"></div>'.$wpnonce;
 
79
  return $html;
80
  }
81
 
@@ -86,7 +219,7 @@ class WYSIJA_view extends WYSIJA_object{
86
  * @param type $get
87
  * @return type
88
  */
89
- function secure($params=array(),$get=false,$echo=true){
90
  $controller='';
91
  if(!is_array($params)) $action=$params;
92
  else{
@@ -113,23 +246,47 @@ class WYSIJA_view extends WYSIJA_object{
113
  * @return string
114
  */
115
  function getClassValidate($params,$returnAttr=false,$prefixclass=""){
116
- $classValidate="";
117
- $recognisedtypes=array("email","url");
 
118
  if(isset($params['req'])){
119
- $classValidate="required";
120
- if(isset($params['type']) && in_array($params['type'], $recognisedtypes)) {
121
- $classValidate.=",custom[".$params['type']."]";
122
  }
123
  }else{
124
- if(isset($params['type']) && in_array($params['type'],$recognisedtypes )) {
125
- $classValidate.="custom[".$params['type']."]";
126
  }
127
  }
128
 
129
- if($prefixclass) $prefixclass.=" ";
130
- if($classValidate) $classValidate="validate[".$classValidate."]";
131
- if(!$returnAttr && $classValidate) $classValidate= ' class="'.$prefixclass.$classValidate.'" ';
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
132
 
133
- return $classValidate;
 
134
  }
135
  }
8
  var $search=array();
9
  var $cols_nks=array();//correspondance between user_id and user-id once processed
10
 
11
+ static $color_coordinates = array();
12
+
13
+ static $cache_color_schemes = array();
14
+
15
+ /**
16
+ * Color schemes of MailPoet
17
+ * @var array
18
+ */
19
+ var $color_schemes = array(
20
+ array('#21759b', '#6697BF', '#487192', '#284c69', '#000333'),// like blue
21
+ array('#388e71', '#2c6f58','#16523d','#0d3c2c','#092e21'),// like green
22
+ array('#c97575','#a76262', '#854f4f', '#743a3a', '#5a2a2a'),// like red
23
+ array('#00CC00', '#269926', '#008500', '#39E639', '#67E667'), // http://colorschemedesigner.com/#2P11Tw0w0w0w0 // green
24
+ array('#FF0000', '#BF3030', '#A60000', '#FF4040', '#FF7373') // http://colorschemedesigner.com/#0011Tw0w0w0w0 // red
25
+ );
26
+
27
+ /**
28
+ * Default font family
29
+ * @var type
30
+ */
31
+ var $font_family = array('Arial');
32
+
33
+ /**
34
+ * Default font size in pixel
35
+ * @var int
36
+ */
37
+ var $font_size = 12;
38
+
39
+
40
  function WYSIJA_view(){
41
 
42
  }
43
 
44
 
45
+ /**
46
+ * Swap color schemes, to make sure, we don't use 2 colors in a same scheme continously
47
+ * @return array()
48
+ */
49
+ protected function swap_color_schemes() {
50
+ if (empty(self::$cache_color_schemes)) {
51
+ // swap colors from axis X => Y, Y => X
52
+ $x = count($this->color_schemes[0][0]);
53
+ $y = count($this->color_schemes[0]);
54
+ $tmp = array();
55
+ foreach ($this->color_schemes as $y => $colors) {
56
+ foreach ($colors as $x => $color) {
57
+ $tmp[$x][$y] = $color;
58
+ }
59
+ }
60
+ self::$cache_color_schemes = $tmp;
61
+ }
62
+ return self::$cache_color_schemes;
63
+ }
64
+ /**
65
+ * Get one random color from schemes
66
+ * @return type
67
+ *
68
+ * Depreciated
69
+ */
70
+ function get_random_color() {
71
+ return $this->get_next_color();
72
+ }
73
+
74
+ public function get_next_color() {
75
+
76
+ $color_schemes = $this->swap_color_schemes();
77
+
78
+ $class_name = get_class($this);
79
+ if (empty(self::$color_coordinates[$class_name]))
80
+ self::$color_coordinates[$class_name] = array('x'=> 0, 'y' => 0);
81
+
82
+ $current_color = $color_schemes[self::$color_coordinates[$class_name]['x']][self::$color_coordinates[$class_name]['y']];
83
+
84
+ // find out and set a next color
85
+ $flag = false;
86
+ $detected_new_color = false;
87
+ foreach ($color_schemes as $x => $colors) {
88
+ if ($detected_new_color) break;
89
+ foreach ($colors as $y => $color) {
90
+ if ($flag) {
91
+ self::$color_coordinates[$class_name]['x'] = $x;
92
+ self::$color_coordinates[$class_name]['y'] = $y;
93
+ $detected_new_color = true;
94
+ break;
95
+ }
96
+ if ($x == self::$color_coordinates[$class_name]['x'] && $y == self::$color_coordinates[$class_name]['y'])
97
+ $flag = true;
98
+
99
+ }
100
+ }
101
+ if (!$detected_new_color) {
102
+ self::$color_coordinates[$class_name]['x'] = 0;
103
+ self::$color_coordinates[$class_name]['y'] = 0;
104
+ }
105
+ return $current_color;
106
+ }
107
+
108
+ /**
109
+ * Get all colors from schemes
110
+ * @return type
111
+ */
112
+ function get_all_colors() {
113
+ $color_schemes = $this->swap_color_schemes();// this one, to make sure, we don't put same color tone continously
114
+
115
+ $tmp = array();
116
+ foreach ($color_schemes as $colors) {
117
+ $tmp = array_merge($tmp, $colors);
118
+ }
119
+ return $tmp;
120
+ }
121
+
122
+
123
 
124
  function renderErrorInstall(){
125
+ $this->title=__("Your server's configuration doesn't allow us to complete MailPoet's Installation!",WYSIJA);
126
  $this->header();
127
  $this->footer();
128
  }
131
  *
132
  * @param type $type
133
  * @param type $data
134
+ * @param bool $is_module is rendering a module view
135
  */
136
+ function render($type,$data, $is_module = false){
137
  $this->action=$type;
138
+ if (!$is_module){
139
+ $this->header($data);
140
+ }
141
  if($type !== NULL) {
142
  $this->$type($data);
143
  }
144
+ if (!$is_module){
145
+ $this->footer();
146
+ }
147
  }
148
 
149
  /**
151
  * @global type $wysija_msg
152
  */
153
  function messages($noglobal=false){
154
+ $wysija_msg = $this->getMsgs();
155
 
156
  if(isset($wysija_msg['g-updated'])) {
157
  if(!$noglobal) {
167
  }
168
  unset($wysija_msg['g-error']);
169
  }
 
170
  $wpnonce='<input type="hidden" value="'.wp_create_nonce("wysija_ajax").'" id="wysijax" />';
171
  if(!$wysija_msg) return '<div class="wysija-msg ajax"></div>'.$wpnonce;
172
  $html='<div class="wysija-msg">';
 
173
  foreach($wysija_msg as $level =>$messages){
174
+ $msg_class = '';
175
+ switch($level){
176
+ case 'updated':
177
+ $msg_class = 'notice-msg updated';
178
+ break;
179
+ case 'error':
180
+ $msg_class = 'error-msg error';
181
+ break;
182
+ case 'xdetailed-updated':
183
+ $msg_class = 'xdetailed-updated';
184
+ break;
185
+ case 'xdetailed-errors':
186
+ $msg_class = 'xdetailed-errors';
187
+ break;
188
+
189
+ }
190
+
191
+ $html.='<div class="'.$msg_class.'">';
192
  $html.='<ul>';
193
 
194
  if(count($messages)>0){
195
  foreach($messages as $msg){
196
+ // check type of msg variable
197
+ if(is_array($msg)) {
198
+ $msg = var_export($msg, true);
199
+ }
200
+
201
+ // display message
202
+ $html.='<li>'.$msg.'</li>';
203
  }
204
  }
205
 
207
  $html.='</ul>';
208
  $html.='</div>';
209
  }
 
210
  $html.='</div><div class="wysija-msg ajax"></div>'.$wpnonce;
211
+
212
  return $html;
213
  }
214
 
219
  * @param type $get
220
  * @return type
221
  */
222
+ static function secure($params=array(),$get=false,$echo=true){
223
  $controller='';
224
  if(!is_array($params)) $action=$params;
225
  else{
246
  * @return string
247
  */
248
  function getClassValidate($params,$returnAttr=false,$prefixclass=""){
249
+ $class_validate = '';
250
+ $recognised_types = array('email','url');
251
+
252
  if(isset($params['req'])){
253
+ $class_validate='required';
254
+ if(isset($params['type']) && in_array($params['type'], $recognised_types)) {
255
+ $class_validate.=',custom['.$params['type'].']';
256
  }
257
  }else{
258
+ if(isset($params['type']) && in_array($params['type'],$recognised_types )) {
259
+ $class_validate.='custom['.$params['type'].']';
260
  }
261
  }
262
 
263
+ if($prefixclass) $prefixclass.=' ';
264
+ if($class_validate) $class_validate='validate['.$class_validate.']';
265
+ if(!$returnAttr && $class_validate) $class_validate= ' class="'.$prefixclass.$class_validate.'" ';
266
+
267
+ return $class_validate;
268
+ }
269
+
270
+ /**
271
+ * central function to return a translated formated date
272
+ * @param type $val
273
+ * @param type $format
274
+ * @return string
275
+ */
276
+ function fieldListHTML_created_at($val,$format=''){
277
+ if(!$val) return '---';
278
+
279
+ //offset the time to the time of the WP site not the server
280
+ $hToolbox = WYSIJA::get('toolbox','helper');
281
+ // get current time taking timezone into account.
282
+
283
+ $val = $hToolbox->servertime_to_localtime($val);
284
+
285
+ if($format) return date_i18n($format,$val);
286
+ else return date_i18n(get_option('date_format'),$val);
287
+ }
288
 
289
+ function fieldListHTML_created_at_time($val){
290
+ return $this->fieldListHTML_created_at($val,get_option('date_format').', '.get_option('time_format'));
291
  }
292
  }
css/add-ons.css ADDED
@@ -0,0 +1 @@
 
1
+ .module-container{overflow:hidden;width:100%;min-width:676px;margin:20px 0px}.module-container p,.module-container h2,.module-container h3{margin-left:6px}.mailpoet-module{position:relative;float:left;width:320px;min-height:330px;margin:0px 16px 18px 0px;border:1px solid #e5e5e5;background:#fff;padding:0px 0 14px 0px;box-shadow:0 1px 1px rgba(0,0,0,0.04);overflow:hidden}.mailpoet-module.not-ready{border-color:#eee;cursor:pointer}.mailpoet-module .mailpoet-module-image{margin:0px 12px}.mailpoet-module .mailpoet-module-content p{margin:0px 0px 8px 0px}.mailpoet-module .mailpoet-module-content p span.mailpoet-module-badge{background-color:#df1d4f;color:#fff;font-weight:bold;padding:6px 10px;margin-right:4px;border:1px solid #cc1148;border-radius:0px 0px 3px 3px}.mailpoet-module .mailpoet-module-content p span.mailpoet-module-badge a{color:#fff !important;text-decoration:none;border-bottom:1px dotted #fff}.mailpoet-module .mailpoet-module-content p span.mailpoet-module-badge.new{float:right !important;margin-top:-6px;background-color:#054e6e !important;border:1px solid #054e6e !important}.mailpoet-module .mailpoet-module-actions{display:block;position:absolute;bottom:6px;left:10px}.mailpoet-module .mailpoet-module-actions a{position:relative;margin-bottom:4px}.mailpoet-module-content{margin:0 1em}.mailpoet-module h3{line-height:1.1;margin:6px 12px;padding:3px 0px;font-size:14px;font-weight:bold;font-style:normal;color:#000}.mailpoet-module-description p{line-height:150%;font-size:12px;margin-bottom:20px;color:#666}.submit-idea{clear:both;display:block;padding:8px 15px;margin:8px 4px;overflow:hidden;line-height:180%}
css/admin-campaigns-articles.css CHANGED
@@ -1 +1 @@
1
- #search-results li{border:1px solid #eee;height:38px;margin-bottom:8px;padding:5px 10px;background-color:#FFF}#search-results li:hover{background-color:#F2F2F2;border-color:#CCCCCC;cursor:pointer}#search-results .thumbnail{width:60px;height:38px;overflow:hidden;float:left;margin:0 10px 0 0}#search-results h3{margin:0 0 0 0;line-height:38px;height:38px;overflow:hidden}#search-results li:hover h3{color:#3060A8}#search-results{height:430px;width:580px}#get-full-post-label input{margin:0 4px 0 0}#search-advanced span{margin-right:10px;margin-bottom:10px;display:inline-block;width:42%}.searchwrap{position:relative;margin:0 0 10px 0}#search-results li{position:relative}.article-cpt{float:left;width:90%}.cpt-type{background-color:#F1F1F1;border-left:1px solid #CCCCCC;border-top:1px solid #CCCCCC;bottom:0;color:#21759B;font-style:italic;padding:0 5px 2px;position:absolute;right:0}.cpt-type small{color:#888}#search-advanced{display:none}span.statuses{float:right}#show-advanced-controls{position:absolute;right:12px;bottom:2px}
1
+ #results{min-height:430px;padding:0 0 50px 0;width:98%}#results .loading{margin:10px 0 0 0}#results li{border:1px solid #ddd;height:38px;margin:0 0 10px 0;padding:0;background-color:#FFF;position:relative}#results li .checkbox_container{width:38px;height:38px;text-align:center;line-height:35px;float:left;position:relative}#results li .checkbox{cursor:pointer;margin:0 0 0 11px}#results .thumbnail{width:60px;height:38px;overflow:hidden;float:left;margin:0 10px 0 0}#results li label{-webkit-user-select:none;-moz-user-select:none;-ms-user-select:none;-o-user-select:none;user-select:none;margin:0 0 0 0;line-height:38px;height:38px;overflow:hidden;float:left;width:510px}#results li label.with_thumbnail{width:440px}#results li.selected{border-color:#0074A2;cursor:pointer}#results li.selected label{color:#0074A2}#results hr{border:0 none;border-top:1px solid #dbdbdb;height:1px;line-height:1px}#basic .filters-box{float:left;margin:0}.filters-box #post_type{width:120px}.filters-box .post_category{width:160px}.filters-box #post_status{width:140px}#basic .search-box{float:right;margin:0}input#search{width:160px}#search-submit{font-size:13px;margin:0 14px 0 0;padding:1px 10px}#toggle-advanced{position:relative;right:10px;top:0}#advanced{padding:0 0 50px 0;display:none}#advanced div.block{padding:0.8em 0 0.8em 1em;margin:0}#advanced div.block p{margin:0 0 5px 0;padding:0}#advanced label{float:left;width:200px;padding:0}#advanced div.block p label{float:none}#image_width_slider{float:left;width:252px;margin:15px 0 0 5px;height:0px;position:relative;cursor:pointer;border:2px solid #808080;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}#slider_handle{width:16px;height:16px;cursor:pointer;position:absolute;top:-9px;margin:0 0 0 -2px;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;background-color:#fff;box-shadow:inset 0px 0px 2px rgba(0,0,0,0.1);border:1px solid #ccc}#slider_info{float:left;font-weight:bold;margin:7px}#advanced label span.label{float:none;display:block;font-size:10px;font-style:italic;line-height:1.2em;width:120px}#advanced label.radio{float:left;width:auto;margin:0 9px 0 0}#advanced label.radio input{margin:0 2px 0 0}#advanced div.group{float:left}.cpt-type{background-color:#F1F1F1;border-left:1px solid #ccc;bottom:0;color:#21759B;font-style:italic;padding:0 10px;position:absolute;right:0;top:0;line-height:38px}.cpt-type small{color:#888}.modcoder_excolor_clrbox{width:17px;height:17px;margin:4px 0 0 0;color:transparent;padding:0}
css/admin-campaigns-autopost.css CHANGED
@@ -1 +1 @@
1
- p.clearfix{margin:0 0 10px 0}label{width:190px;float:left;padding:5px}label span.label{display:block;font-size:10px;font-style:italic}span.inline{float:left;margin:5px}p.clearfix input,p.clearfix select{float:left;border:1px solid #ccc;padding:5px;background:transparent;height:26px}p.clearfix input.color{height:23px}select{width:200px}select#post_limit{width:50px}label.radio{width:auto !important;margin:0 10px 0 0;height:20px}label.radio input{margin:0 5px 0 0;padding:0;height:20px;border:0 none}ul#category_selection{margin:-6px 0 0 200px}ul#category_selection li span{float:left;margin:0 5px 0 0}.remove-category{float:left}.icon-plus span,.icon-minus span{display:block;height:20px;width:20px}.icon-plus span{background:url(../img/controls/icons.png) no-repeat -200px 0}.icon-plus.active span,.icon-plus:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.icon-minus span{background:url(../img/controls/icons.png) no-repeat -220px 0}.icon-minus.active span,.icon-minus:hover span{background:url(../img/controls/icons.png) no-repeat -220px -20px}
1
+ .autopost{padding:0 10px 10px 0;display:block}.autopost div.block{padding:0.8em 0 0.8em 1em;margin:0}.autopost div.block p{margin:0 0 5px 0;padding:0}.autopost label{float:left;width:200px;padding:0}.autopost div.block p label{float:none}.autopost label span.label{float:none;display:block;font-size:10px;font-style:italic;line-height:1.2em;width:120px}.autopost label.radio{float:left;width:auto;margin:0 9px 0 0}.autopost label.radio input{margin:0 2px 0 0}.autopost div.group{float:left}#image_width_slider{float:left;width:252px;margin:15px 0 0 5px;height:0px;position:relative;cursor:pointer;border:2px solid #808080;-webkit-border-radius:5px;-moz-border-radius:5px;border-radius:5px}#slider_handle{width:16px;height:16px;cursor:pointer;position:absolute;top:-9px;margin:0 0 0 -2px;-webkit-border-radius:10px;-moz-border-radius:10px;border-radius:10px;background-color:#fff;box-shadow:inset 0px 0px 2px rgba(0,0,0,0.1);border:1px solid #ccc}#slider_info{float:left;font-weight:bold;margin:7px}select#category_ids{width:400px}#toggle-advanced{margin:0 0 0 12px}#advanced{display:none}.modcoder_excolor_clrbox{width:17px;height:17px;margin:4px 0 0 0;color:transparent;padding:0}
css/admin-campaigns-bookmarks.css CHANGED
@@ -1 +1 @@
1
- .bookmarks .networks li{margin:0 0 10px 0}.bookmarks .networks label{width:70px;float:left;font-weight:normal}.bookmarks .networks input{width:250px;float:left}.bookmarks .sizes{margin:20px 0 0 0}.bookmarks .sizes a{margin:0 0 0 10px}.bookmarks .sizes a.selected{font-weight:bold}.bookmarks .sizes .small{font-size:12px}.bookmarks .sizes .medium{font-size:14px}.bookmarks .sizes .large{font-size:16px}.bookmarks .icons{height:230px;overflow:auto}.bookmarks .icons li{margin:10px}.bookmarks .icons li a{padding:5px;margin:0;display:-moz-inline-box;display:inline-block;*display:inline;*float:left}.bookmarks .icons li a.selected{border:2px solid #DD561A;padding:3px}.bookmarks .icons img{margin:0 5px;vertical-align:middle}
1
+ .bookmarks .networks li{margin:0 0 10px 0}.bookmarks .networks label{width:70px;float:left;font-weight:normal}.bookmarks .networks input{width:350px;float:left}.bookmarks .sizes{margin:20px 0 0 0}.bookmarks .sizes a{margin:0 0 0 10px}.bookmarks .sizes a.selected{font-weight:bold}.bookmarks .sizes .small{font-size:12px}.bookmarks .sizes .medium{font-size:14px}.bookmarks .sizes .large{font-size:16px}.bookmarks .icons{height:230px;overflow:auto}.bookmarks .icons li{margin:10px}.bookmarks .icons li a{padding:5px;margin:0;display:-moz-inline-box;display:inline-block;*display:inline;*float:left}.bookmarks .icons li a.selected{border:2px solid #DD561A;padding:3px}.bookmarks .icons img{margin:0 5px;vertical-align:middle}
css/admin-campaigns-dividers.css CHANGED
@@ -1 +1 @@
1
- .wysija_popup_content.divider{width:620px}.dividers ul{height:400px;width:620px;overflow:auto;margin:0 0 20px 0}.dividers li{text-align:center;padding:5px 2px}.dividers li a{padding:2px;display:block}.dividers li a.selected{padding:0;border:2px solid #DD561A}.dividers li img{vertical-align:middle}
1
+ .wysija_popup_content.divider{width:620px}.dividers ul{height:350px;width:620px;overflow:auto;margin:0 0 20px 0}.dividers li{text-align:center;padding:5px 2px}.dividers li a{padding:2px;display:block}.dividers li a.selected{padding:0;border:2px solid #DD561A}.dividers li img{vertical-align:middle}
css/admin-campaigns-editDetails.css CHANGED
@@ -1 +1 @@
1
- #datepicker-day{width:74px;margin-left:10px}
1
+ #datepicker-day{margin-left:10px;min-width:90px}
css/admin-campaigns-medias.css CHANGED
@@ -1 +1 @@
1
- .swfupload{vertical-align:middle}ul#sidemenu{bottom:-1px;float:none;font-weight:normal;left:0;margin:0 5px;overflow:hidden}.wysija-thumb{float:left;height:150px;margin:10px;width:150px;position:relative;border:2px dashed transparent;filter:alpha(opacity=60);-moz-opacity:0.6;opacity:0.6;margin:8px}.wysija-thumb:hover,.wysija-thumb.selected:hover{border-color:#000;border-style:dashed}.wysija-thumb.selected{border-color:#4a5b04;border-style:solid;filter:alpha(opacity=100);-moz-opacity:1;opacity:1}.wysija-thumb img{max-height:150px;max-width:150px}.wysija-thumb span.delete{background:url("../img/controls/icons.png") no-repeat scroll -100px 0 transparent;cursor:pointer;height:20px;text-indent:-9999px;display:block;width:20px}.wysija-thumb span.delete-wrap{background-color:#DFDFDF;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);border:1px solid #CCCCCC;border-radius:2px 2px 2px 2px;box-shadow:0 1px 0 rgba(0,0,0,0.15),0 0 2px 1px #fff inset;height:20px;position:absolute;right:2px;top:2px;margin:5px 3px 0 0;width:20px;display:none}.wysija-thumb span.thumb_url,.wysija-thumb span.url,.wysija-thumb span.width,.wysija-thumb span.height,.wysija-thumb span.identifier{display:none}.wysija-thumb:hover span.delete-wrap{display:block}.wysija-thumb span.delete:hover{background-position:-100px -20px}.clear{clear:both}.tablenav{margin-right:20px}#media-items{overflow:auto}.media-wp-upload #media-items{display:none}.media-browse #media-items{width:100%;height:340px;margin:0 0 10px 0}.media-wp-browse #media-items{width:100%;height:340px;margin:0 0 10px 0}#media-items em{margin:0 0 0 20px}#media-items,.ml-submit{float:left}.ml-submit{margin-top:15px;margin-left:15px}#loader{left:50%;position:relative;top:50%}#overlay{background-color:#FFFFFF;height:100%;opacity:0.8;position:absolute;width:100%;z-index:999;display:none}#flash-upload-ui{padding:10px 25px}.after-file-upload{padding:0 25px}.after-file-upload,.upload-flash-bypass,.howto{display:none}.wysija-thumb .slidetoggle,.wysija-thumb .toggle{display:none}.max-upload-size{margin:10px 0;display:block}
1
+ .swfupload{vertical-align:middle}ul#sidemenu{bottom:-1px;float:none !important;font-weight:normal;left:0;margin:0 5px;overflow:hidden;float:none !important}.wysija-thumb{float:left;height:150px;margin:10px;width:150px;position:relative;border:2px dashed transparent;filter:alpha(opacity=60);-moz-opacity:0.6;opacity:0.6;margin:8px}.wysija-thumb:hover,.wysija-thumb.selected:hover{border-color:#000;border-style:dashed}.wysija-thumb.selected{border-color:#4a5b04;border-style:solid;filter:alpha(opacity=100);-moz-opacity:1;opacity:1}.wysija-thumb img{cursor:pointer;max-height:150px;max-width:150px}.wysija-thumb span.delete{background:url("../img/controls/icons.png") no-repeat scroll -100px 0 transparent;cursor:pointer;height:20px;text-indent:-9999px;display:block;width:20px}.wysija-thumb span.delete-wrap{background-color:#DFDFDF;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);border:1px solid #CCCCCC;border-radius:2px 2px 2px 2px;box-shadow:0 1px 0 rgba(0,0,0,0.15),0 0 2px 1px #fff inset;height:20px;position:absolute;right:2px;top:2px;margin:5px 3px 0 0;width:20px;display:none}.wysija-thumb span.thumb_url,.wysija-thumb span.url,.wysija-thumb span.width,.wysija-thumb span.height,.wysija-thumb span.identifier{display:none}.wysija-thumb:hover span.delete-wrap{display:block}.wysija-thumb span.delete:hover{background-position:-100px -20px}.clear{clear:both}.tablenav{margin-right:20px}#media-items{overflow:auto}.media-wp-upload #media-items{display:none}.media-browse #media-items{width:100%;height:340px;margin:0 0 10px 0}.media-wp-browse #media-items{width:100%;height:340px;margin:0 0 10px 0}#media-items em{margin:0 0 0 20px}#media-items,.ml-submit{float:left}.ml-submit{margin-top:15px;margin-left:15px}#loader{left:50%;position:relative;top:50%}#overlay{background-color:#FFFFFF;height:100%;opacity:0.8;position:absolute;width:100%;z-index:999;display:none}#flash-upload-ui{padding:10px 25px}.after-file-upload{padding:0 25px}.after-file-upload,.upload-flash-bypass,.howto{display:none}.wysija-thumb .slidetoggle,.wysija-thumb .toggle{display:none}.max-upload-size{margin:10px 0;display:block}
css/admin-campaigns-themes.css CHANGED
@@ -1 +1 @@
1
- .swfupload{vertical-align:middle}ul#sidemenu{bottom:-1px;float:none;font-weight:normal;left:0;margin:0 5px;overflow:hidden}#loader{left:50%;position:relative;top:50%}#overlay{background-color:#fff;opacity:0.8;width:100%;height:100%;position:fixed;top:0;bottom:0;left:0;right:0;z-index:999;display:none}#flash-upload-ui{padding:10px 25px}.after-file-upload{padding:0 25px}#close-pop-alt{float:right;margin-right:50px;margin-top:10px}.after-file-upload,.upload-flash-bypass,.howto{display:none}#theme-view .preview,#theme-view .infos{float:left}#theme-view .infos{width:300px;margin:0 0 0 20px}#theme-view .preview{background:url(../img/wpspin_light.gif) no-repeat scroll center center transparent}#theme-view .preview img{width:320px;display:block}#theme-view{font-size:14px;height:480px;overflow:auto}#theme-view h2{color:#555555;font-family:Tahoma;font-size:24px;margin:4px 0 0;line-height:1.2em}#theme-view .actions{margin-bottom:10px}div.star{background-color:transparent;border:medium none;height:100%;left:0;letter-spacing:1ex;position:absolute;top:0}.stars{background:url(../img/stars.png) repeat-x scroll left bottom transparent;height:17px;position:relative;width:95px}.stars .star-rating{background:url(../img/stars.png) repeat-x scroll left top transparent;float:left;height:17px;overflow:hidden;text-indent:100%;white-space:nowrap}.my-rating a{height:17px;width:19px;float:left;margin:0;padding:0}.my-rating a.active,.my-rating a:hover,.my-rating a.on{background:url(../img/stars.png) no-repeat left top transparent}.my-rating a.active.off,.my-rating a.off{background:none}div.paragraph{margin:10px 0}.star-holder.my-rate img{cursor:pointer}.star-holder.my-rate div.star:hover{background-color:#DD0000}div.star.select.star-rating{background-color:#FFCC00}#theme-upload{display:none}.avatar{border:2px solid #CCC;float:right;margin:0}#overwrite{margin:0px 10px 0 0}#filter-selection{position:relative;top:3px}.theme-screenshot{padding:0;width:320px;border:1px solid #ccc;position:relative;background-color:#fff;-webkit-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);-moz-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);box-shadow:0 0 5px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1)}.theme-screenshot:before,.theme-screenshot:after{position:absolute;width:40%;height:10px;content:' ';left:12px;bottom:12px;background:transparent;-webkit-transform:skew(-5deg) rotate(-5deg);-moz-transform:skew(-5deg) rotate(-5deg);-ms-transform:skew(-5deg) rotate(-5deg);-o-transform:skew(-5deg) rotate(-5deg);transform:skew(-5deg) rotate(-5deg);-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.3);-moz-box-shadow:0 6px 12px rgba(0,0,0,0.3);box-shadow:0 6px 12px rgba(0,0,0,0.3);z-index:-1}.theme-screenshot:after{left:auto;right:12px;-webkit-transform:skew(5deg) rotate(5deg);-moz-transform:skew(5deg) rotate(5deg);-ms-transform:skew(5deg) rotate(5deg);-o-transform:skew(5deg) rotate(5deg);transform:skew(5deg) rotate(5deg)}.theme-screenshot img{width:320px}#wj_paginator{float:right;margin-right:10px;font-size:14px}#wj_paginator a{margin:0 1px}#wj_paginator span{font-weight:bold;margin:0 1px}#wj_paginator a.selected{color:#000;text-decoration:none;cursor:default}#themes-list{height:405px;margin:0}.theme{float:left;margin:0px;overflow:hidden;width:152px;margin:25px 8px 0 0}.theme.last{margin-right:0}.theme .thumbnail{height:170px;width:150px;position:relative;border:1px solid #999999;background-color:#000000}.theme img{width:150px;height:170px;position:absolute;z-index:1;top:0px;left:0px}.theme .install{display:none}.theme:hover img{filter:alpha(opacity=25);-moz-opacity:0.25;opacity:0.25}.theme:hover .thumbnail{border:1px solid #2a749f}.theme:hover .install{display:block;position:relative;z-index:100;text-align:center;margin:0px auto;margin-top:80px;width:80px !important}.theme .infos{display:block;width:80px;margin:5px 0 0 0;padding:0;text-align:center;font-size:12px;line-height:1em;color:#999999;text-decoration:none}.theme .infos:hover{color:#21759b;text-decoration:underline}
1
+ .swfupload{vertical-align:middle}ul#sidemenu{bottom:-1px;float:none !important;font-weight:normal;left:0;margin:0 5px;overflow:hidden}#loader{left:50%;position:relative;top:50%}.loading{margin:15px 0 0 0}#overlay{background-color:#fff;opacity:0.8;width:100%;height:100%;position:fixed;top:0;bottom:0;left:0;right:0;z-index:999;display:none}#flash-upload-ui{padding:10px 25px}.after-file-upload{padding:0 25px}#close-pop-alt{float:right;margin-right:50px;margin-top:10px}.after-file-upload,.upload-flash-bypass,.howto{display:none}#theme-view .preview,#theme-view .infos{float:left}#theme-view .infos{width:300px;margin:0 0 0 20px}#theme-view .preview{background:url(../img/wpspin_light.gif) no-repeat scroll center center transparent}#theme-view .preview img{width:320px;display:block}#theme-view{font-size:14px;height:480px;overflow:auto}#theme-view h2{color:#555555;font-family:Tahoma;font-size:24px;margin:4px 0 0;line-height:1.2em}#theme-view .actions{margin-bottom:10px}div.star{background-color:transparent;border:medium none;height:100%;left:0;letter-spacing:1ex;position:absolute;top:0}.stars{background:url(../img/stars.png) repeat-x scroll left bottom transparent;height:17px;position:relative;width:95px}.stars .star-rating{background:url(../img/stars.png) repeat-x scroll left top transparent;float:left;height:17px;overflow:hidden;text-indent:100%;white-space:nowrap}.my-rating a{height:17px;width:19px;float:left;margin:0;padding:0}.my-rating a.active,.my-rating a:hover,.my-rating a.on{background:url(../img/stars.png) no-repeat left top transparent}.my-rating a.active.off,.my-rating a.off{background:none}div.paragraph{margin:10px 0}.star-holder.my-rate img{cursor:pointer}.star-holder.my-rate div.star:hover{background-color:#DD0000}div.star.select.star-rating{background-color:#FFCC00}#theme-upload{display:none}.avatar{border:2px solid #CCC;float:right;margin:0}#overwrite{margin:0px 10px 0 0}#filter-selection{position:relative;top:3px}.theme-screenshot{padding:0;width:320px;border:1px solid #ccc;position:relative;background-color:#fff;-webkit-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);-moz-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);box-shadow:0 0 5px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1)}.theme-screenshot:before,.theme-screenshot:after{position:absolute;width:40%;height:10px;content:' ';left:12px;bottom:12px;background:transparent;-webkit-transform:skew(-5deg) rotate(-5deg);-moz-transform:skew(-5deg) rotate(-5deg);-ms-transform:skew(-5deg) rotate(-5deg);-o-transform:skew(-5deg) rotate(-5deg);transform:skew(-5deg) rotate(-5deg);-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.3);-moz-box-shadow:0 6px 12px rgba(0,0,0,0.3);box-shadow:0 6px 12px rgba(0,0,0,0.3);z-index:-1}.theme-screenshot:after{left:auto;right:12px;-webkit-transform:skew(5deg) rotate(5deg);-moz-transform:skew(5deg) rotate(5deg);-ms-transform:skew(5deg) rotate(5deg);-o-transform:skew(5deg) rotate(5deg);transform:skew(5deg) rotate(5deg)}.theme-screenshot img{width:320px}#wj_paginator{float:right;margin-right:10px;font-size:14px}#wj_paginator a{margin:0 1px}#wj_paginator span{font-weight:bold;margin:0 1px}#wj_paginator a.selected{color:#000;text-decoration:none;cursor:default}#themes-list{height:405px;margin:0}.theme{float:left;margin:0px;overflow:hidden;width:152px;margin:25px 8px 0 0}.theme.last{margin-right:0}.theme .thumbnail{height:170px;width:150px;position:relative;border:1px solid #999999;background-color:#000000}.theme img{width:150px;height:170px;position:absolute;z-index:1;top:0px;left:0px}.theme .install{display:none;float:none !important}.theme:hover img{filter:alpha(opacity=25);-moz-opacity:0.25;opacity:0.25}.theme:hover .thumbnail{border:1px solid #2a749f}.theme:hover .install{display:block;position:relative;z-index:100;text-align:center;margin:0px auto;margin-top:80px;width:80px !important}.theme .infos{display:block;width:100%;margin:5px 0 0 0;padding:0;text-align:left;font-size:12px;line-height:1em;color:#999999;text-decoration:none}.theme .infos:hover{color:#21759b;text-decoration:underline}
css/admin-campaigns-viewstats.css ADDED
@@ -0,0 +1 @@
 
1
+ #posts-filter{margin-top:40px}#hook_newsletter_top{margin-top:20px}#hook_newsletter_top .left{float:left;width:50%}#hook_newsletter_top .right{float:right}#hook_newsletter_top .actions{width:45%;margin-bottom:20px;padding-left:10px}.action_buttons a:first-child{margin-left:0}.action_buttons{display:block}table.newsletter-stats-block{margin-top:10px}table.newsletter-stats-block td.label{width:25%;font-weight:bold}.wrap .button-secondary2{top:auto !important}.googletrackingcode .action_buttons{padding-left:0}.googletrackingcode{padding-top:10px}.wrap .button-secondary2:first-child{margin-left:0}
css/admin-campaigns-welcome_new.css ADDED
@@ -0,0 +1 @@
 
1
+ #wysija-app .welcome_poll li{list-style:none outside none;margin:10px 0;font-size:14px;line-height:20px}#wysija-app .welcome_poll li input{margin:0 10px 0 0}#how_did_you_find_us_4_url{width:50%}#poll_result{font-weight:bold;padding-left:5px}#poll_result span.checkmark{background:url("../img/controls/icons.png") no-repeat scroll -260px -20px transparent;display:inline-block;text-indent:-9999px;width:20px}
css/admin-campaigns.css CHANGED
@@ -1 +1 @@
1
- #icon-edit-news{background:url(../img/mail-big.png) no-repeat scroll 0 8px transparent}#TB_window{display:block}.moredetails{display:none}.sending,.scheduled{background-color:#d5f0e6}.autonl.sending{background-color:#D7E6F2}#wysija-campaign .listmissing{background-color:#EFD5D5}#preview-receiver{width:230px;vertical-align:middle;margin:0 5px 0 0}.ml-submit{margin:15px 15px 0 15px}.automatic-nl{display:none}#titlediv .titlebox{font-size:1.7em;background-color:#FFFFFF;border-color:#CCCCCC;line-height:100%;outline:medium none;padding:3px 8px;width:100%}label .description{cursor:auto}.about-wrap .feature-section.three-col div{float:left;margin-right:5%;width:28%}#socials-block div{float:none;margin:5px 5px 2px 0;width:100%}.progress_bar{padding-bottom:10px}.progress_bar .bar{display:block;width:200px;height:22px;float:left;margin-right:10px;background:#eef6fc;border:1px solid #bbbbbb;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;line-height:22px;position:relative}.progress_bar .progress{display:block;background:#69b1e9;height:100%}.progress_bar .percent{height:100%;position:absolute;top:0px;left:10px}#wysija-badge{position:absolute;top:0;right:0;color:#fff;text-shadow:0 1px 0 rgba(0,0,0,0.3);padding-top:91px;height:50px;width:173px;font-weight:bold;font-size:14px;text-align:center;margin:0 -5px;background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/wysija-badge.png") no-repeat}#review-follow{position:relative;height:177px}#review-follow div{float:left;top:0}#review-follow .review-left{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/save-the-kitten.jpg") no-repeat;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef;padding-right:10px}#review-follow h4{margin:0 !important}#review-follow .review-left.small{width:450px}#review-follow .review-left.medium{width:490px}#review-follow .review-left.large{width:540px}#review-follow .small .description{margin-top:24px}#review-follow .medium .description{margin-top:20px}#review-follow .large .description{margin-top:18px}#review-follow .review-left p{margin-left:20px}#review-follow .review-right{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow_middle.jpg") no-repeat;width:62px;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef}#review-follow .socials{margin-left:30px}#review-follow .follow-left{width:300px;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef}#review-follow .follow-right{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow_right.jpg") no-repeat;width:100px;height:175px}#review-follow .review-left .description{margin-left:146px}#review-follow .link-cat-review{height:140px;left:20px;position:absolute;top:21px;width:120px;outline:medium none}a.ctaupdate,span.ctaupdate{font-size:12px}.pds-links,.pds-totalvotes-outer{display:none !important}#polldaddy_embed_0{width:680px;margin-left:-30px}
1
+ #wysija-app{padding-top:10px}.icon32{margin-top:0px !important}#posts-filter{clear:both}#wysija-app h2{display:inline}#icon-edit-news{background:url(../img/mail-big.png) no-repeat scroll 0 5px transparent}#TB_window{display:block}.moredetails{display:none}.sending,.scheduled{background-color:#d5f0e6}.autonl.sending{background-color:#D7E6F2}#wysija-campaign .listmissing{background-color:#EFD5D5}#preview-receiver{width:230px;vertical-align:middle;margin:0 5px 0 0}.ml-submit{margin:15px 15px 0 15px}.automatic-nl{display:none}#titlediv .titlebox{font-size:1.7em;background-color:#FFFFFF;border-color:#CCCCCC;line-height:100%;outline:medium none;padding:3px 8px;width:100%}label .description{cursor:auto}.about-wrap .feature-section.three-col div{float:left;width:28%}#socials-block div{float:none;margin:5px 5px 2px 0;width:100%}.progress_bar{padding-bottom:10px}.progress_bar .bar{display:block;width:100%;height:22px;float:left;margin-right:10px;background:#eef6fc;border:1px solid #bbbbbb;-webkit-border-radius:3px;-moz-border-radius:3px;border-radius:3px;line-height:22px;position:relative}.progress_bar .progress{display:block;background:#69b1e9;height:100%}.progress_bar .percent{height:100%;position:absolute;top:0px;left:10px}#wysija-badge{position:absolute;top:0;right:0;color:#fff;text-shadow:0 1px 0 rgba(0,0,0,0.3);padding-top:91px;height:50px;width:173px;font-weight:bold;font-size:14px;text-align:center;margin:0 -5px;background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/wysija-badge.png") no-repeat}#review-follow{position:relative;height:177px}#review-follow div{float:left;top:0}#review-follow .review-left{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/save-the-kitten.jpg") no-repeat;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef;padding-right:10px}#review-follow h4{margin:0 !important}#review-follow .review-left.small{width:450px}#review-follow .review-left.medium{width:490px}#review-follow .review-left.large{width:540px}#review-follow .small .description{margin-top:24px}#review-follow .medium .description{margin-top:20px}#review-follow .large .description{margin-top:18px}#review-follow .review-left p{margin-left:20px}#review-follow .review-right{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow_middle.jpg") no-repeat scroll -30px 0 #f8f8f8;border-bottom:1px solid #EFEFEF;border-top:1px solid #EFEFEF;height:175px;width:24px}#review-follow #mailpoet-subscribe{margin-left:0px;margin-top:10px}#review-follow .subscribe-middle{width:220px;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef}#review-follow .socials{margin-left:30px}#review-follow .follow-left{width:220px;height:175px;background-color:#f8f8f8;border-top:1px solid #efefef;border-bottom:1px solid #efefef}#review-follow .follow-right{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow_right.jpg") no-repeat;width:100px;height:175px}#review-follow .follow-right38{background:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow-right-38.jpg") no-repeat;width:100px;height:175px}#review-follow .review-left .description{margin-left:146px}#review-follow .link-cat-review{height:140px;left:20px;position:absolute;top:21px;width:120px;outline:medium none}a.ctaupdate,span.ctaupdate{font-size:12px}.pds-links,.pds-totalvotes-outer{display:none !important}#polldaddy_embed_0{width:680px;margin-left:-30px}span.local_time{margin-left:10px}#hook_newsletter_top .hook-column{width:50%}.card-title{font-weight:bold}.report-card{padding-top:10px}.googletrackingcode .action_buttons{padding-left:44px;padding-top:5px}.googletrackingcode span{font-weight:bold}.mpoet-page h1{font-size:34px}.mpoet-page h1,.mpoet-page h2,.mpoet-page h3,.mpoet-page h4{color:#626262;font-weight:bold}.mpoet-page h1 span.version{color:#5e869b}
css/admin-config-form_widget_settings.css CHANGED
@@ -1 +1 @@
1
- #widget-settings-form{margin-right:10px}#widget-settings-error{margin-right:10px;padding:10px;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;color:#000;font-weight:normal;background-color:#ffebe8;border:1px solid #c00}.sortable li{margin:0;padding:5px}.sortable li:hover{background-color:#eee}.icon span{display:block;height:20px;width:20px}.handle span{cursor:move;background:url(../img/controls/icons.png) no-repeat -120px 0}.handle.active span,.handle:hover span{background:url(../img/controls/icons.png) no-repeat -120px -20px;cursor:move}.add span{background:url(../img/controls/icons.png) no-repeat -200px 0}.add.active span,.add:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.remove span{background:url(../img/controls/icons.png) no-repeat -100px 0}.remove.active span,.remove:hover span{background:url(../img/controls/icons.png) no-repeat -100px -20px}.widget_text textarea,.widget_html textarea{height:80px;width:300px;resize:vertical}.widget_html input.checkbox{margin:0px 5px 0 2px}.widget_list #lists-available{float:left;padding:0;width:250px}.widget_list .icon.add{float:left}.widget_list #lists-selection label{float:left;margin:0 0 0 5px}.widget_list #lists-selection input{float:left;margin:3px 5px 0px 0}.widget_list #lists-selection li{height:20px;line-height:20px}.widget_list #lists-selection label{width:200px;height:20px;line-height:20px;overflow:hidden}.widget_list #lists-selection .handle,.widget_list #lists-selection .remove{float:right}.widget_list #list-selection-template{display:none}
1
+ .form_widget_settings p label{float:left;clear:left;width:200px}#widget-settings-error{margin-right:10px;padding:10px;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;color:#000;font-weight:normal;background-color:#ffebe8;border:1px solid #c00}.sortable li{margin:0;padding:5px}.sortable li:hover{background-color:#eee}.icon span{display:block;height:20px;width:20px}.handle span{cursor:move;background:url(../img/controls/icons.png) no-repeat -120px 0}.handle a.active span,.handle:hover span{background:url(../img/controls/icons.png) no-repeat -120px -20px;cursor:move}.add span{background:url(../img/controls/icons.png) no-repeat -200px 0;float:left}.add.active span,.add:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.remove span{background:url(../img/controls/icons.png) no-repeat -100px 0}.remove.active span,.remove:hover span{background:url(../img/controls/icons.png) no-repeat -100px -20px}#widget-field-settings{margin:0 0 0 10px;display:none}.widget_text textarea,.widget_html textarea{height:120px;width:450px;resize:none}.widget_html input.checkbox,label input[type="checkbox"],label input[type="radio"]{margin:0px 5px 0 0px}.widget_list #lists-available{float:left;padding:0;width:250px}.form_widget_settings .icon.add{line-height:20px;outline:0}.form_widget_settings .selection{background-color:#fff;border:1px solid #dfdfdf;width:100%}.form_widget_settings .selection input[name="is_checked"],.form_widget_settings .selection input.is_checked{margin:0px 0px 2px 3px}.form_widget_settings .selection li{padding:5px 3px;margin:0}.form_widget_settings .selection input{margin:0 5px 0px 0}.form_widget_settings .selection .value{margin:0}.form_widget_settings .selection .is_selected{float:left;margin:3px 0 0 6px !important}.form_widget_settings .selection label{float:left;margin:0 0 0 5px;width:220px;height:20px;line-height:20px;overflow:hidden}.form_widget_settings .selection .handle,.form_widget_settings .selection .remove{float:right;margin:3px 3px 0 0}.form_widget_settings #selection-template{display:none}.form_widget_settings .hidden{display:none}.form_widget_settings label.radio{margin:0 10px 0 0}#date-format-value{display:none}
css/admin-config.css CHANGED
@@ -1 +1 @@
1
- #wysija-tabs a{font-size:14px}#wysija-tabs a.tab-premium{background-color:#d7e6f2;font-weight:bold}p.submit{padding:1em 1.4em 1em 0}span.title{font-size:16px;margin:0;color:#000}.choice-under15{float:right;display:block;width:360px}#wysija-settings input[type="checkbox"],#wysija-settings input[type="radio"]{margin-right:6px;vertical-align:baseline}#wysija-settings label input[type="checkbox"],#cron_page_hit_trigger-1{margin-left:0}#wysija-settings .button-secondary{margin-left:6px}#wysija-settings .form-table th{width:300px}#wysija-settings .form-table th.row{border:1px solid #AAAAAA}#warning-msg-frequency{background-color:#FFFFE0;border-color:#E6DB55}#warning-msg-frequency{border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;margin:5px 15px 2px;padding:0 0.6em}#warning-msg-frequency ul{margin:0}#mainmenu .premium{background:url(../img/ui-bg_glass_premium_1x400.png) repeat-x scroll 50% 50% #e6e6e6;border:1px solid #a9abc3}#mainmenu .premium:hover{background:url(../img/ui-bg_glass_premium_hover_1x400.png) repeat-x scroll 50% 50% #e6e6e6;border:1px solid #9c9eb2}#mainmenu .premium a{font-weight:700;color:#5d5e76}#mainmenu .premium a:hover{color:#4b4d69}#mainmenu .ui-state-active{background:white !important;border:1px solid #d8d9e6}#premium-content{margin-bottom:30px}#premium-content h2{font-size:35px;color:#4b4d69;font-family:sans-serif;font-size:2.8em;font-weight:200;line-height:1.2em;margin:0.5em}.wysija-premium-wrapper{margin:0 0 20px 0}.bulletium{font-size:16px;line-height:28px;width:676px}.bulletium a{color:#0b6373}#premium-content .left-part{float:left}#premium-content .bullet-hold{width:600px;margin:15px 30px 15px 5px}#premium-content div.feat-thumb{background:url(../img/rocket-small.png) no-repeat scroll 0 0 transparent;float:left;height:65px;margin-right:10px;width:30px;margin-top:6px}#premium-content .description{float:left;width:550px}#premium-content div.description h3{margin:5px 0 4px 0;font-family:"HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue",sans-serif;font-size:20px;font-weight:normal;color:black}#premium-content div.description p{margin:0}#wysija-settings .form-table th.rolestitle{padding:3px 3px 3px 0;text-align:left;vertical-align:middle;width:220px}#wysija-settings .form-table th.rolestable{padding:3px;text-align:center;vertical-align:middle;width:90px;word-wrap:break-word}#wysija-settings .form-table td.rolestable{padding:6px 0;text-align:center}#wysija-settings .form-table td.title{padding:2px 0 2px 5px;text-align:left;vertical-align:middle}#wysija-settings .form-table tr.alternate{background-color:#ececec}#wysija-settings #bounce .intro{margin:10px 0 20px 10px}#wysija-settings #bounce #bounce-process-auto,#wysija-settings #bounce #bounce-connector{margin-left:0 !important}#wysija-settings #sendingmethod .methods{border-bottom:1px solid #000}#wysija-settings #sendingmethod .choice-sending-method-site{border-top:1px solid #cccccc}#wysija-settings #sendingmethod .choice-sending-method-site th,#wysija-settings #sendingmethod .choice-sending-method-site td{padding-top:18px}label.dkim{margin-right:20px}.cronleft,.cronright{float:left}.cronleft{width:20px;margin-right:10px}#cron_manual_linkname p{margin:0}.labelcheck{float:left;margin-right:15px}.linknamecboxes{float:left;width:500px}#smtp-rest-label{display:none;margin-left:10px}#wysija-settings #multisite #form-ms-config th{width:455px}#wysija-settings .msfromemail{width:180px}#wysija-settings #multisite #ms-sendingmethod th{width:300px}#wysija-settings #multisite .intro{margin:0 0 0 10px}#wysija-settings #sendingmethod .methods input,#wysija-settings #multisite .methods input{margin:0 5px 0 0;float:left}#wysija-settings #sendingmethod .methods h3,#wysija-settings #multisite .methods p.title{float:left;margin:0 !important}#wysija-settings #multisite .choice-one-for-all{display:none}#wysija-settings a.view_all{font-style:italic}#wysija-settings .cronright label{display:block;margin-bottom:10px}#wysija-settings .cronright label span{margin-left:36px}span.icon{display:block;height:20px;width:20px;cursor:pointer}.geeky-option a,.geeky-option span{float:left}.show-more-geeky-options span{background:url(../img/controls/icons.png) no-repeat -200px 0}.show-more-geeky-options:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.hide-geeky-options span{background:url(../img/controls/icons.png) no-repeat -220px 0}.hide-geeky-options:hover span{background:url(../img/controls/icons.png) no-repeat -220px -20px}
1
+ tr.title_row>td{padding-left:0}#wysija-tabs a{font-size:14px}#wysija-tabs a:focus{outline:0 none}#wysija-settings .premium_activated{color:#0074A2;font-size:1.2em;padding:15px 0 20px 0}#wysija-settings .premium_activated i{font-size:1.5em;margin:0 6px 3px 0;vertical-align:bottom}p.submit{padding:1em 1.4em 1em 0}span.title{font-size:16px;margin:0;color:#000}.mailpoet-frequency_inner_texting{padding:0 10px}.mailpoet-frequency_warning{margin-top:10px}#wysija-settings input[type="checkbox"],#wysija-settings input[type="radio"]{margin-right:6px;vertical-align:baseline}#wysija-settings label input[type="checkbox"],#cron_page_hit_trigger-1{margin-left:0}#wysija-settings .button-secondary{margin-left:6px}#wysija-settings .form-table th{width:300px}#wysija-settings .form-table th.row{border:1px solid #AAAAAA}#warning-msg-frequency{background-color:#FFFFE0;border-color:#E6DB55}#warning-msg-frequency{border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;margin:5px 15px 2px;padding:0 0.6em}#warning-msg-frequency ul{margin:0}#wysija-settings .form-table th.rolestitle{padding:10px 0 10px 10px;text-align:left;vertical-align:middle;width:220px}#wysija-settings .form-table th.rolestable{padding:3px;text-align:center;vertical-align:middle;width:110px;word-wrap:break-word}#wysija-settings .form-table td.rolestable{padding:6px 0;text-align:center}#wysija-settings .form-table td.title{padding:10px 0 10px 10px;text-align:left;vertical-align:middle}#wysija-settings .form-table td.title p{margin:0}#wysija-settings .form-table td{vertical-align:top}#wysija-settings #bounce .intro{margin:10px 0 20px 10px}#wysija-settings #bounce #bounce-process-auto,#wysija-settings #bounce #bounce-connector{margin-left:0 !important}#wysija-settings #sendingmethod .methods{border-bottom:1px solid #000}#wysija-settings #sendingmethod .choice-sending-method-site{border-top:1px solid #cccccc}#wysija-settings #sendingmethod .choice-sending-method-site th,#wysija-settings #sendingmethod .choice-sending-method-site td{padding-top:18px}label.dkim{margin-right:20px}.cronleft,.cronright{float:left}.cronleft{width:20px;margin-right:10px}#cron_manual_linkname p{margin:0}.labelcheck{float:left;margin-right:15px}.checkbox_optin_label{margin:6px 6px 0 0;float:left}.checkbox_optin_value{float:left;width:500px}#smtp-rest-label{display:none;margin-left:10px}#wysija-settings #multisite #form-ms-config th{width:455px}#wysija-settings #multisite #ms-sendingmethod th{width:300px}#wysija-settings #multisite .intro{margin:0 0 0 10px}#wysija-settings #sendingmethod .methods input,#wysija-settings #multisite .methods input{margin:0 5px 0 0;float:left}#wysija-settings #sendingmethod .methods h3,#wysija-settings #multisite .methods p.title{float:left;margin:0 !important}#wysija-settings #multisite .choice-one-for-all{display:none}#wysija-settings a.view_all{font-style:italic}#wysija-settings .cronright label{display:block;margin-bottom:10px}#wysija-settings .cronright label span{margin-left:36px}#wysija-settings .capabilities_form{width:400px}span.icon{display:block;height:20px;width:20px;cursor:pointer}.geeky-option a,.geeky-option span{float:left}.show-more-geeky-options span{background:url(../img/controls/icons.png) no-repeat -200px 0}.show-more-geeky-options:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.hide-geeky-options span{background:url(../img/controls/icons.png) no-repeat -220px 0}.hide-geeky-options:hover span{background:url(../img/controls/icons.png) no-repeat -220px -20px}@-webkit-keyframes opacity{0%{opacity:1}100%{opacity:0}}@-moz-keyframes opacity{0%{opacity:1}100%{opacity:0}}.wysija-button-loading{text-align:center;margin:100px 0 0 0}.wysija-button-loading span{-webkit-animation-name:opacity;-webkit-animation-duration:1s;-webkit-animation-iteration-count:infinite;-moz-animation-name:opacity;-moz-animation-duration:1s;-moz-animation-iteration-count:infinite}.wysija-button-loading span:nth-child(2){-webkit-animation-delay:100ms;-moz-animation-delay:100ms}.wysija-button-loading span:nth-child(3){-webkit-animation-delay:300ms;-moz-animation-delay:300ms}.links-page{display:none;margin-left:10px}.new_form{margin:16px 0}.new_form a{font-size:16px !important}
css/admin-dashicons.css ADDED
@@ -0,0 +1 @@
 
1
+ @font-face{font-family:'mailpoet-icon';src:url("../font/icon-email.eot?doyy92");src:url("../font/icon-email.eot?#iefixdoyy92") format("embedded-opentype"),url("../font/icon-email.woff?doyy92") format("woff"),url("../font/icon-email.ttf?doyy92") format("truetype"),url("../font/icon-email.svg?doyy92#mailpoet-icon") format("svg");font-weight:normal;font-style:normal}.mp-menu-icon-bg .menu-top.toplevel_page_wysija_campaigns .wp-menu-image{background:transparent url("../img/mail.png") no-repeat center center}.mp-menu-icon-bg .menu-top.toplevel_page_wysija_campaigns .wp-menu-image:before{content:""}.mp-menu-icon-font .menu-top.toplevel_page_wysija_campaigns .wp-menu-image:before{font:normal 18px/1 "mailpoet-icon" !important;speak:none;color:#999;padding:8px 0;height:36px;width:20px;display:inline-block;-webkit-font-smoothing:antialiased;-moz-osx-font-smoothing:grayscale;-moz-transition:all .1s ease-in-out;-webkit-transition:all .1s ease-in-out;transition:all .1s ease-in-out}.menu-top.toplevel_page_wysija_campaigns .wp-menu-image:before{content:"\f466"}
css/admin-global.css CHANGED
@@ -1 +1 @@
1
- .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}.wysija-footer,.wysija-version{margin:0 20px 0 165px;padding-bottom:45px}.wysija-footer h2{color:#21759B;cursor:pointer}.wysija-footer h2:hover{text-decoration:underline}.wysija-version{font-size:12px;color:#777777;height:65px;border-top:1px solid #DFDFDF}.wysija-version .social-foot div{float:left;margin-right:10px}.social-foot .fb{width:80px}.wysija-version .version{float:left}.wysija-version .help{float:left;margin-left:20px}.wysija-version .social-foot .textsocial{margin-left:8px;margin-top:3px;padding-top:0}.wysija-version .social-foot{clear:both;display:inline-block;float:left;margin-top:2px;padding:6px 13px}.wysija-version .social-foot .socials div{margin-left:20px}.wysija-version .social-foot .socials{margin-left:0px}.wysija-version .social-foot .socials .fb,.wysija-version .social-foot .socials .fb div{margin-left:0px}.wysija-version .version{float:left;margin-bottom:5px}.wysija-version .socials{padding-top:9px}#hidesocials{margin-top:2px;font-size:12px}.social-foot .gplus{width:70px}#upperfoot{display:block;float:none}#wysija-app .form-table td{vertical-align:top}
1
+ .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}.hide{display:none}.wysija-version{margin:0 20px 0 165px;padding-bottom:45px}.wysija-footer h2{color:#21759B;cursor:pointer}.wysija-footer h2:hover{text-decoration:underline}.wysija-version{font-size:12px;color:#777777}.wysija-version .social-foot div{float:left;margin-right:10px}.wysija-version .version{float:left}.wysija-version .help{float:left;margin-left:20px}.wysija-version .social-foot .textsocial{margin-left:8px;margin-top:3px;padding-top:0}.wysija-version .social-foot{clear:both;display:inline-block}.wysija-version .version{float:left;margin-bottom:5px}#upperfoot{display:block;float:none}#submitexport label input[type="checkbox"]{margin-left:0px !important}.clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}.wysija-footer,.wysija-version{margin:0 20px 0 165px;padding-bottom:45px}.wysija-footer h2{color:#21759B;cursor:pointer}.wysija-footer h2:hover{text-decoration:underline}.wysija-version{font-size:12px;color:#777777;height:65px;border-top:1px solid #DFDFDF}.wysija-version .social-foot div{float:left;margin-right:10px}.social-foot .fb{width:80px}.wysija-version .version{float:left}.wysija-version .help{float:left;margin-left:20px}.wysija-version .social-foot .textsocial{margin-left:8px;margin-top:3px;padding-top:0}.wysija-version .social-foot{clear:both;display:inline-block;float:left;margin-top:2px;padding:6px 13px}.wysija-version .social-foot .socials div{margin-left:20px}.wysija-version .social-foot .socials{margin-left:0px}.wysija-version .social-foot .socials .fb,.wysija-version .social-foot .socials .fb div{margin-left:0px}.wysija-version .version{float:left;margin-bottom:5px}.wysija-version .socials{padding-top:9px}#hidesocials{margin-top:2px;font-size:12px}.social-foot .gplus{width:70px}#upperfoot{display:block;float:none}#wysija-app .form-table td{vertical-align:top}#submitexport label input[type="checkbox"]{margin-left:0px !important}.hook-column{float:left;display:block}#wysija-app div.warning{margin:5px 0 15px;background-color:#FFFFE0;border-color:#E6DB55;border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;padding:10px}.submit-box{border-top:1px solid #dbdbdb;background-color:#FFFFFF;bottom:0;height:50px;left:0;margin:0;padding:0;position:fixed;text-align:right;width:100%}#loading-icon{width:20px;height:20px;position:absolute;left:16px;top:16px}.loading #loading-icon{background:url(../img/wpspin_light.gif) no-repeat 0 0 #fff}.counting #loading-icon{background:url(../img/controls/icons.png) no-repeat -140px -20px #fff}.submit-box #loading-message{font-family:"Trebuchet MS";font-size:14px;left:39px;position:absolute;top:17px}.submit-box #insert-selection,.submit-box #back-selection{margin:10px 10px 0 0}.submit-box #back-selection{display:none}#icon-stats{background:url("../img/stats-icon.png") no-repeat scroll 0 0 transparent}
css/admin-premium.css ADDED
@@ -0,0 +1 @@
 
1
+ #mainmenu .premium{background:url(../img/ui-bg_glass_premium_1x400.png) repeat-x scroll 50% 50% #e6e6e6;border:1px solid #a9abc3}#mainmenu .premium:hover{background:url(../img/ui-bg_glass_premium_hover_1x400.png) repeat-x scroll 50% 50% #e6e6e6;border:1px solid #9c9eb2}#mainmenu .premium a{font-weight:700;color:#5d5e76}#mainmenu .premium a:hover{color:#4b4d69}#mainmenu .ui-state-active{background:white !important;border:1px solid #d8d9e6}.mpoet-page h2{color:#4b4d69;font-size:1.8em;font-weight:200;line-height:1.2em;margin:0}.wysija-premium-wrapper{margin:0 0 20px 0}.wysija-premium-actions{position:fixed;width:1028px;bottom:0;background-color:#eee;border-top:1px solid #ccc;border-left:1px solid #ccc;border-right:1px solid #ccc;-webkit-border-top-left-radius:7px;-webkit-border-top-right-radius:7px;-moz-border-radius-topleft:7px;-moz-border-radius-topright:7px;border-top-left-radius:7px;border-top-right-radius:7px;z-index:999;padding:10px 10px 0}.wysija-premium-actions .licence{margin-right:15px}.wysija-premium-actions p{margin:0px 0px 10px 0;text-align:center}.wysija-premium-actions span.conditions{font-size:12px;margin-right:15px}.wysija-premium-actions .button-primary.wysija-premium-activate{float:none}.wysija-premium-actions-kim{position:fixed;width:1066px;bottom:0;background-color:#eee;border-top:1px solid #ccc;border-left:1px solid #ccc;border-right:1px solid #ccc;z-index:999;margin-left:-30px;padding:10px 10px;text-align:center}.mpoet-page .feature-section.three-col>div{width:29%}.mpoet-page .three-col img{margin:0.5em 0;max-width:100%}a.wysija-premium-purchase{background-color:#FFB30D !important;background:-webkit-gradient(linear, left top, left bottom, from(#fecb19), to(#ff9c00)) !important;background:-webkit-linear-gradient(#fecb19, #ff9c00) !important;background:-moz-linear-gradient(center top, #fecb19 0%, #ff9c00 100%) !important;background:-moz-gradient(center top, #fecb19 0%, #ff9c00 100%) !important;border:1px solid #ff9c00 !important;color:#ffffff;font-family:"Amaranth", Arial, sans-serif;font-style:italic;font-size:15px !important;font-weight:normal;letter-spacing:1px;text-decoration:none;text-shadow:0 1px 0 #434343;padding:10px 30px;border-radius:7px;-moz-border-radius:7px;-webkit-border-radius:7px;box-shadow:none !important;text-shadow:0px 2px 1px rgba(0,0,0,0.3) !important;display:inline-block;text-align:center;width:auto}a.wysija-premium-purchase:hover{box-shadow:none !important}a.wysija-premium-purchase:hover,a.wysija-premium-purchase:active{text-decoration:none !important;background:#ffd547;background:-webkit-gradient(linear, left top, left bottom, from(#ffd648), to(#ffbe38));background:-webkit-linear-gradient(#ffd648, #ffbe38);background:-moz-linear-gradient(center top, #ffd648 20%, #ffbe38 100%);background:-moz-gradient(center top, #ffd648 20%, #ffbe38 100%)}a.wysija-premium-purchase,a.wysija-premium-activate{margin:10px 0}.mpoet-page .bullet-hold{width:600px;margin:15px 30px 15px 5px}.mpoet-page div.description h3{margin:5px 0 4px 0;font-family:"HelveticaNeue-Light","Helvetica Neue Light","Helvetica Neue",sans-serif;font-size:20px;font-weight:normal;color:black}.mpoet-page div.description p{margin:0}#prices_table{margin-top:55px}#prices_table .one-third{display:block;float:left;width:284px}#prices_table #prices_names{height:63px}#prices_table #prices_names .one-third{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;background:none repeat-x scroll left top rgba(0,0,0,0);border-color:#414141 -moz-use-text-color #414141 #414141;border-image:none;border-style:solid none solid solid;border-width:1px 0 1px 1px;height:61px;text-align:center}#prices_table #prices_names{display:block}#prices_table #prices_names h3{color:#FFF !important;line-height:1em !important}#prices_table #prices_names .blogger{background-color:#0074A2}#prices_table #prices_names .freelance{background-color:#026187}#prices_table #prices_names .agency{background-color:#014661;border-right:1px solid #414141}#prices_table #prices_cost{height:177px}#prices_table #prices_cost p{margin:0}#prices_table #prices_cost .one-third{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;border-color:-moz-use-text-color -moz-use-text-color #849A97 #849A97;border-image:none;border-style:none none solid solid;border-width:0 0 1px 1px;font-family:'Amaranth',Arial,sans-serif;height:176px}#prices_table #prices_cost .agency{border-right:1px solid #849A97}#prices_table #prices_cost span{display:block}#prices_table #prices_cost .dollars{font-size:80px;height:80px;line-height:normal;padding:20px 55px 0;text-align:center}#prices_table #prices_cost .per_year{font-size:18px;padding:0 60px;text-align:right}#prices_table #prices_cost .blogger .dollars{padding:20px 75px 0}#prices_table #prices_cost .blogger .per_year{padding:0 80px}#prices_table #prices_description{height:62px}#prices_table #prices_description .one-third{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;border-color:-moz-use-text-color -moz-use-text-color #849A97 #849A97;border-image:none;border-style:none none solid solid;border-width:0 0 1px 1px;font-size:22px;height:61px}#prices_table #prices_description .agency{border-right:1px solid #849A97}#prices_table #prices_description .agency p{display:block;margin:-15px 62px 0 0;text-align:right;font-size:.5em}#prices_table #prices_description span{display:block;padding:17px 0;text-align:center}#prices_table #prices_content{height:158px}#prices_table #prices_content .prices_content{-moz-border-bottom-colors:none;-moz-border-left-colors:none;-moz-border-right-colors:none;-moz-border-top-colors:none;border-color:-moz-use-text-color #849A97 #849A97;border-image:none;border-right:1px solid #849A97;border-style:none solid solid;border-width:0 1px 1px;color:#414141;font-size:17px;padding:16px 0}#prices_table #prices_content .prices_content span{display:block;padding:2px 0;text-align:center}a.buy-button{background:none repeat scroll 0 0 #2EA2CC;border-color:#0074A2;box-shadow:0 1px 0 rgba(120,200,230,0.5) inset,0 1px 0 rgba(0,0,0,0.15);color:#FFFFFF;-moz-box-sizing:border-box;border-radius:3px;border-style:solid;border-width:1px;cursor:pointer;display:inline-block;font-size:20px;margin-top:20px;margin-bottom:60px;padding:7px 10px 7px;text-decoration:none;white-space:nowrap}a.buy-button:hover{color:#ecf3fe}.mpoet-page h1{font-size:34px}#wysija-app .mpoet-page h2{font-size:25px}.mpoet-page h1,.mpoet-page h2,.mpoet-page h3,.mpoet-page h4{color:#626262;font-weight:bold}.mpoet-page h3{margin-top:5px;line-height:24px}.mpoet-page .three-col .argument-cta{display:table;margin-top:5px}#premium-content-b .pick-licence{margin-bottom:15px}.mpoet-page hr{margin-bottom:20px}#premium-content-b .price{font-weight:bold}#footer-upgrade,#footer-left,#wpfooter .alignright,.wysija-footer{display:none}.about-wrap div.updated,.about-wrap div.error{display:block !important}#wysija-app .about-wrap .feature-section{margin-top:20px}
css/admin-statistics.css ADDED
@@ -0,0 +1 @@
 
1
+ .stats_date_filter{padding-top:10px}.statistic-title{clear:both;margin-top:5px}.cl{clear:both}#hook_stats .container{clear:both;padding-top:1px;margin-top:20px}#stats-filter .reset{background:none;border:none;cursor:pointer}#stats-filter .reset:hover{text-decoration:underline}.custom_date{margin-right:10px}.spinner{float:left !important}.hook{margin-top:10px;clear:both}.container-top-links .link_column{width:20%}.container-top-links .click_column{width:6%}.container .check-column{width:2.5em}.container-top-subscribers table th.subscriber{width:30%}.container-top-subscribers table th.clicks{width:7%}.container-top-subscribers table th.opens{width:7%}.container-top-subscribers table th.lists{width:41%}.container-top-subscribers table th.date{width:15%}.container-top-links a.newsletter{display:block;padding-top:5px}.container-top-subscribers .username .avatar{padding-left:0px;padding-right:0px}.container-top-subscribers .username .avatar img{margin-right:0px}.container-top-subscribers tbody .check-column{text-align:center}.container-top-newsletters th.newsletter{width:19%}.container-top-newsletters th.sent{width:8%}.container-top-newsletters th.opens{width:8%}.container-top-newsletters th.clicks{width:7%}.container-top-newsletters th.unsubscribes{width:11%}.container-top-newsletters th.rates{width:18%}.container-top-newsletters th.sent_at{width:12%}.container-top-newsletters th.lists{width:14%}.container-top-newsletters td a.stats{display:none}.container-top-newsletters td.newsletter:hover a.stats{display:block}.container-top-subscribers th.desc:hover span.sorting-indicator,.container-top-newsletters th.desc:hover span.sorting-indicator{background-position:-7px 0}.stats_feedback{font-weight:bold;margin-top:20px;clear:both}.tip{font-style:italic}.stats_subscriptions-container .tip{margin-left:70px}.container-top-newsletters th.desc:hover span.sorting-indicator:before,.container-top-subscribers th.desc:hover span.sorting-indicator:before,.container-top-newsletters th.asc span.sorting-indicator:before,.container-top-subscribers th.asc span.sorting-indicator:before{content:'\f140'}#hook_stats td.column-username table tr td{padding-top:0px}
css/admin-subscribers-addlist.css ADDED
@@ -0,0 +1 @@
 
1
+ #wysija-edit .form-table th{width:200px}
css/admin-subscribers-edit.css ADDED
@@ -0,0 +1 @@
 
1
+ #wysija-edit{padding-bottom:20px}#hook_subscriber_left{width:50%}#hook_subscriber_right{width:50%}.hook-column .submit{text-align:center}#hook_subscriber_bottom{clear:both;padding-top:1px}.container{clear:both;margin-top:30px}.form-table th label{float:right;white-space:nowrap}.labelcheck{float:left;margin-right:15px}#wysija-edit input[type="checkbox"]{margin-right:6px;vertical-align:baseline}#wysija-edit .form-table th{width:60px}.container-stats-subscribers_std table th.newsletter{width:60%}.container-stats-subscribers_std table th.link{width:20%}.container-stats-subscribers_std table th.click{width:5%}.container-stats-subscribers_std .widefat .check-column{width:2.4em}.container-stats-subscribers_std .widefat th.date{width:15%}
css/admin-subscribers-export.css ADDED
@@ -0,0 +1 @@
 
1
+ #wysija-app table td label{margin-right:15px}#wysija-app table td input[type="radio"]{margin-right:5px}
css/admin-subscribers-exportlist.css ADDED
@@ -0,0 +1 @@
 
1
+ #wysija-app table td label{margin-right:15px}#wysija-app table td input[type="radio"]{margin-right:5px}
css/admin-subscribers-importmatch.css CHANGED
@@ -1 +1 @@
1
- #wysija-edit .widefat td{min-width:190px}#wysija-edit .widefat{width:auto}#blocknewlist{width:175px}
1
+ #wysija-edit .widefat td{min-width:100px}#wysija-edit .widefat{width:auto}#blocknewlist{width:175px}.import-new-field{display:none;margin-top:4px}.import-new-field label{font-size:12px}.widefat th .import-new-field input{margin:2px 5px 0 4px}.widefat thead{vertical-align:top}#first-row{padding-top:14px}.converted-field-to-date{display:none;margin-left:5px;color:#0e90d2}.converted-field-error{display:none;margin-left:5px;color:#b10000;font-weight:bold}
css/admin-subscribers.css ADDED
@@ -0,0 +1 @@
 
1
+ tr.submit_row>td{padding-left:0}.list .check-column{width:10px}#wysija-app .list .column-date{width:70px}#wysija-app .list .column-list-names{width:100px}
css/admin-widget.css CHANGED
@@ -1 +1 @@
1
- .wysija-widget-form .lists-block input[type="checkbox"],.wysija-widget-form input[type="radio"]{margin:0 4px 0 0}.wysija-widget-form .labelcheck label{margin:0 4px 0 0}.wysija-widget-form .lists-block{margin:0 3px 0 6px;clear:both;max-height:116px;overflow:auto;float:left;margin:0 10px 0 0}.wysija-widget-form .labelcheck{margin:0 0 5px 0;float:left;margin-left:5px}.wysija-widget-form .divblocks{margin:10px 0 0 0}
1
+ .wysija-widget-form .lists-block input[type="checkbox"],.wysija-widget-form input[type="radio"]{margin:0 4px 0 0}.wysija-widget-form .labelcheck label{margin:0 4px 0 0}.wysija-widget-form .lists-block{margin:0 3px 0 6px;clear:both;max-height:116px;overflow:auto;float:left;margin:0 10px 0 0}.wysija-widget-form .labelcheck{margin:0 0 5px 0;float:left;margin-left:5px}.wysija-widget-form .divblocks{margin:10px 0 10px 0}#wpfooter .wrap{display:block;margin:3px 0 3px 0 !important}#wpfooter .wrap .add-new-h2{text-decoration:none}
css/admin.css CHANGED
@@ -1 +1 @@
1
- .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}#wysija-app .column-date{width:125px}#wysija-app .column-clic,#wysija-app .column-opened,#wysija-app .column-emails{width:80px}#wysija-app .column-list-names{width:120px}#wysija-app .menuslinks{margin:20px 0}#statscontainer{height:200px;width:400px}#wysistats1{width:400px}#wysistats1 h3{text-align:center}#wysistats2,#wysistats3{width:200px;padding:30px 0 0 20px}#wysistats3{height:200px;overflow:auto}.left{float:left}#wysistats2 ul li,#wysistats .title{font-weight:bold;font-size:14px;margin-top:0}#wysistats3 ol li{font-style:italic;font-size:10px;color:#444}#wysistats3 ol li em{font-size:11px;font-weight:bold}th.sorted,th.sortable{cursor:pointer}div#wysija-app .xdetailed-updated li,div#wysija-app .xdetailed-errors li,div#wysija-app .updated li,div#wysija-app .error li{margin:6px 0}.xdetailed-errors,.xdetailed-updated{border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;margin:5px 15px 2px;padding:0 0.6em}.xdetailed-updated{background-color:#FFFFE0;border-color:#E6DB55;color:#000;font-weight:bold;display:none}.xdetailed-errors{background-color:#FFEBE8;border-color:#888888;color:#000;display:none}label input[type="checkbox"],label input[type="radio"]{margin:0 5px 0 15px}label:first-child input[type="checkbox"],label:first-child input[type="radio"]{margin-left:0}label.title{font-weight:bold;font-size:14px}.wrap .button-secondary2{background-color:#6697BF;font-family:sans-serif;font-size:12px;color:#FFFFFF;text-decoration:none;text-shadow:0 1px 0 #777777;box-shadow:1px 1px 0 #AAAAAA;margin-left:4px;padding:3px 8px;position:relative;top:-3px;border-radius:3px;-moz-border-radius:3px;-khtml-border-radius:3px;-webkit-border-radius:3px}.wrap .button-secondary2:hover,.wrap .wcurrent{background-color:#1C73B5}.wrap #theme-view .button-secondary2{top:2px}.dots{margin:0 4px}#wysija-pagination{text-align:center}.tablenav .tablenav-pages a,.tablenav-pages span.current{margin:0 2px}.total-pages{padding:0px 3px}input.searchbox{width:225px}.wysija-premium img{display:none}.wysija-footer,.wysija-version{margin:0 20px 0 165px;padding-bottom:45px}.wysija-footer h2{color:#21759B;cursor:pointer}.wysija-footer h2:hover{text-decoration:underline}.wysija-version{font-size:12px;color:#777777}#TB_load,#TB_window,#TB_overlay,.ui-dialog{z-index:100000 !important}.ui-widget-overlay{z-index:9998 !important;background-image:none !important}p.label{font-size:13px}.wysija_popup_content{padding:10px 20px 0 20px}.wysija_popup_content h3{margin:0 0 20px 0}a.linkignore{color:#BC0B0B}a.linkignore:hover,a.submitsynch:hover{color:#FF0000}a.submitsynch{color:#52aa05}body{min-width:0 !important}.warning-msg{background-color:#FFFFE0;border-color:#E6DB55}.warning-msg{border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;margin:5px 15px 2px;padding:0 0.6em}.warning-msg ul{margin:0}span.warning-msg{padding:7px}a.wysija-premium-btns{background-color:#FFB30D;background:-webkit-gradient(linear, left top, left bottom, from(#fecb19), to(#ff9c00));background:-webkit-linear-gradient(#fecb19, #ff9c00);background:-moz-linear-gradient(center top, #fecb19 0%, #ff9c00 100%);background:-moz-gradient(center top, #fecb19 0%, #ff9c00 100%);border:1px solid #ff9c00;color:#ffffff;font-family:"Amaranth", Arial, sans-serif;font-style:italic;font-size:20px;font-weight:normal;letter-spacing:1px;text-decoration:none;text-shadow:0 1px 0 #434343;padding:10px 30px;border-radius:7px;-moz-border-radius:7px;-webkit-border-radius:7px;-moz-box-shadow:0px 2px 3px rgba(0,0,0,0.3);-webkit-box-shadow:0px 2px 3px rgba(0,0,0,0.3);text-shadow:0px 2px 1px rgba(0,0,0,0.3)}a.wysija-premium-btns:hover,a.wysija-premium-btns:active{text-decoration:none !important;background:#ffd547;background:-webkit-gradient(linear, left top, left bottom, from(#ffd648), to(#ffbe38));background:-webkit-linear-gradient(#ffd648, #ffbe38);background:-moz-linear-gradient(center top, #ffd648 20%, #ffbe38 100%);background:-moz-gradient(center top, #ffd648 20%, #ffbe38 100%)}a.wysija-support{display:inline-block;text-align:center;width:auto}.about-wrap h3{padding-top:0px}.about-text{margin-bottom:1em;margin-top:0;min-height:20px}.wysija-unsubscribed-on{color:#bbb}.clear_select_all,.force_to_select_all_link{text-align:center}.clear_select_all a:hover,.force_to_select_all_link a:hover{text-decoration:underline;cursor:pointer !important}
1
+ .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}#wysija-app .column-date{width:70px}#wysija-app .column-clic,#wysija-app .column-opened,#wysija-app .column-emails{width:80px}#wysija-app .column-list-names{width:120px}#wysija-app .menuslinks{margin:20px 0}#statscontainer{height:200px;width:400px}#wysistats1{width:400px}#wysistats1 h3{text-align:center}#wysistats2,#wysistats3{width:200px;padding:30px 0 0 20px}#wysistats3{height:200px;overflow:auto}#wysistats2 ul li,#wysistats .title{font-weight:bold;font-size:14px;margin-top:0}#wysistats3 ol li{font-style:italic;font-size:10px;color:#444}#wysistats3 ol li em{font-size:11px;font-weight:bold}th.sorted,th.sortable{cursor:pointer}div#wysija-app .xdetailed-updated li,div#wysija-app .xdetailed-errors li,div#wysija-app .updated li,div#wysija-app .error li{margin:6px 0}.xdetailed-errors,.xdetailed-updated{border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;margin:5px 15px 2px;padding:0 0.6em}.xdetailed-updated{background-color:#FFFFE0;border-color:#E6DB55;color:#000;display:none}.xdetailed-errors{background-color:#FFEBE8;border-color:#888888;color:#000;display:none}label input[type="checkbox"],label input[type="radio"]{margin:0 5px 0 15px}label:first-child input[type="checkbox"],label:first-child input[type="radio"]{margin-left:0}label.title{font-weight:bold;font-size:14px}.wrap .button-secondary2{background-color:#6697BF;font-family:sans-serif;font-size:12px;color:#FFFFFF;text-decoration:none;text-shadow:0 1px 0 #777777;box-shadow:1px 1px 0 #AAAAAA;margin-left:4px;padding:3px 8px;position:relative;top:-3px;border-radius:3px;-moz-border-radius:3px;-khtml-border-radius:3px;-webkit-border-radius:3px}.wrap .button-secondary2:hover,.wrap .wcurrent{background-color:#1C73B5}.wrap #theme-view .button-secondary2{top:2px}.dots{margin:0 4px}#wysija-pagination{text-align:center}.tablenav .tablenav-pages a,.tablenav-pages span.current{margin:0 2px}.total-pages{padding:0px 3px}input.searchbox{width:225px}.wysija-premium img{display:none}#TB_load,#TB_window,#TB_overlay,.ui-dialog{z-index:100000 !important}.ui-widget-overlay{z-index:9998 !important;background-image:none !important}p.label{font-size:13px}.wysija_popup_content{padding:10px 20px 0 20px}.wysija_popup_content h3{margin:0 0 20px 0}a.linkignore{color:#BC0B0B}a.linkignore:hover,a.submitsynch:hover{color:#FF0000}a.submitsynch{color:#52aa05}body{min-width:0 !important}.warning-msg{background-color:#FFFFE0;border-color:#E6DB55}.warning-msg{border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;margin:5px 15px 2px;padding:0 0.6em}.warning-msg ul{margin:0}span.warning-msg{padding:7px}.about-wrap h3{padding-top:0px}.about-text{margin-bottom:1em;margin-top:0;min-height:20px}.wysija-unsubscribed-on{color:#bbb}.clear_select_all,.force_to_select_all_link{text-align:center}.batch-select{background-color:#E0E0E0;color:#555555;border-bottom:1px solid #e5e5e5}.clear_select_all a:hover,.force_to_select_all_link a:hover{text-decoration:underline;cursor:pointer !important}#wysija-app .notice-msg{background-color:#FFFFE0;border-color:#E6DB55}#wysija-app .error-msg{background-color:#FFEBE8;border-color:#CC0000}#wysija-app .wysija-msg .notice-msg,#wysija-app .wysija-msg .error-msg{border-radius:3px 3px 3px 3px;border-style:solid;border-width:1px;margin:5px 0 15px;padding:0 0.6em}.mpoet-page .changelog .review-follow-kitten{overflow:visible}
css/adminPopup.css CHANGED
@@ -1 +1 @@
1
- html{overflow:hidden;overflow-y:auto;height:auto !important}html.wp-toolbar{padding:0 !important}.popup_content{margin:10px 0 0 10px}.popup_content.addlink{width:300px}.popup_content.articles{width:600px}.popup_content.dividers{width:620px}.popup_content.autopost{width:625px}.popup_content.themes{width:800px}.popup_content.bookmarks{width:620px}.popup_content.media-browse,.popup_content.media-wp-browse,.popup_content.media-wp-upload{width:715px}.popup_content.widget_text,.popup_content.widget_html{width:300px}.popup_content.widget_list{width:310px}p.align-right{text-align:right;margin-bottom:0 !important}div.updated,div.error{margin:10px !important}
1
+ html{overflow:hidden;overflow-y:auto;height:auto !important}html.wp-toolbar{padding:0 !important}#wpadminbar{display:none}body{-webkit-backface-visibility:hidden}.popup_content{margin:10px 10px 0 10px}.popup_content.addlink{width:300px}.popup_content.articles{width:700px}.popup_content.dividers{width:620px}.popup_content.autopost{width:700px;min-height:380px}.popup_content.themes{width:800px}.popup_content.bookmarks{width:620px}.popup_content.media-browse,.popup_content.media-wp-browse,.popup_content.media-wp-upload{width:715px}.popup_content.form_widget_settings{width:405px}.popup_content.widget_text,.popup_content.widget_html{width:450px}.popup_content.widget_list{width:450px}p.align-right{text-align:right;margin-bottom:0 !important}div.updated,div.error{margin:10px !important}.popup_content.inline_form label{line-height:2em;font-weight:bold}.popup_content.inline_form p input,.popup_content.inline_form p select,.popup_content.inline_form p .group{float:left;width:200px}.submit_button{text-align:right;margin:20px 10px 20px 0}.popup_content.inline_form .submit_button{margin:20px 4px 0 0}.popup_content.inline_form p input[type="submit"],.popup_content.inline_form .group label,.popup_content.inline_form .group input,.popup_content.inline_form .group select{float:none;clear:none;width:auto}.popup_content.inline_form label.radio,.popup_content.inline_form .group label{font-weight:normal}.popup_content.inline_form input[type="radio"],.popup_content.inline_form input[type="checkbox"]{width:16px;height:16px;margin:0 3px 0 0;padding:0}.popup_content.inline_form input[type="radio"]{-webkit-appearance:radio}.popup_content.inline_form input[type="radio"]:checked:before,.popup_content.inline_form input[type="checkbox"]:checked:before{background:none;content:''}.popup_content.inline_form input[type="checkbox"]{-webkit-appearance:checkbox}.popup_content.inline_form textarea,.popup_content.inline_form input[type="text"],.popup_content.inline_form input[type="password"],.popup_content.inline_form input[type="email"],.popup_content.inline_form input[type="number"],.popup_content.inline_form input[type="search"],.popup_content.inline_form input[type="tel"],.popup_content.inline_form input[type="url"],.popup_content.inline_form select{font-size:13px;line-height:15px;padding:3px 5px}
css/jquery/ui/themes/base/images/animated-overlay.gif ADDED
Binary file
css/jquery/ui/themes/base/images/ui-bg_flat_0_aaaaaa_40x100.png ADDED
Binary file
css/jquery/ui/themes/base/images/ui-bg_flat_75_ffffff_40x100.png ADDED
Binary file
css/jquery/ui/themes/base/images/ui-bg_glass_55_fbf9ee_1x400.png ADDED
Binary file
css/jquery/ui/themes/base/images/ui-bg_glass_65_ffffff_1x400.png ADDED
Binary file
css/jquery/ui/themes/base/images/ui-bg_glass_75_dadada_1x400.png ADDED
Binary file
css/jquery/ui/themes/base/images/ui-bg_glass_75_e6e6e6_1x400.png ADDED
Binary file
css/jquery/ui/themes/base/images/ui-bg_glass_95_fef1ec_1x400.png ADDED
Binary file
css/jquery/ui/themes/base/images/ui-bg_highlight-soft_75_cccccc_1x100.png ADDED
Binary file
css/jquery/ui/themes/base/images/ui-icons_222222_256x240.png ADDED
Binary file
css/jquery/ui/themes/base/images/ui-icons_2e83ff_256x240.png ADDED
Binary file
css/jquery/ui/themes/base/images/ui-icons_454545_256x240.png ADDED
Binary file
css/jquery/ui/themes/base/images/ui-icons_888888_256x240.png ADDED
Binary file
css/jquery/ui/themes/base/images/ui-icons_cd0a0a_256x240.png ADDED
Binary file
css/jquery/ui/themes/base/jquery.ui.core.min.css ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ /*! jQuery UI - v1.10.3 - 2013-05-03
2
+ * http://jqueryui.com
3
+ * Copyright 2013 jQuery Foundation and other contributors; Licensed MIT */
4
+
5
+ .ui-helper-hidden{display:none}.ui-helper-hidden-accessible{border:0;clip:rect(0 0 0 0);height:1px;margin:-1px;overflow:hidden;padding:0;position:absolute;width:1px}.ui-helper-reset{margin:0;padding:0;border:0;outline:0;line-height:1.3;text-decoration:none;font-size:100%;list-style:none}.ui-helper-clearfix:before,.ui-helper-clearfix:after{content:"";display:table;border-collapse:collapse}.ui-helper-clearfix:after{clear:both}.ui-helper-clearfix{min-height:0}.ui-helper-zfix{width:100%;height:100%;top:0;left:0;position:absolute;opacity:0;filter:Alpha(Opacity=0)}.ui-front{z-index:100}.ui-state-disabled{cursor:default!important}.ui-icon{display:block;text-indent:-99999px;overflow:hidden;background-repeat:no-repeat}.ui-widget-overlay{position:fixed;top:0;left:0;width:100%;height:100%}
css/jquery/ui/themes/base/jquery.ui.datepicker.min.css ADDED
@@ -0,0 +1,5 @@
 
 
 
 
 
1
+ /*! jQuery UI - v1.10.3 - 2013-05-03
2
+ * http://jqueryui.com
3
+ * Copyright 2013 jQuery Foundation and other contributors; Licensed MIT */
4
+
5
+ .ui-datepicker{width:17em;padding:.2em .2em 0;display:none}.ui-datepicker .ui-datepicker-header{position:relative;padding:.2em 0}.ui-datepicker .ui-datepicker-prev,.ui-datepicker .ui-datepicker-next{position:absolute;top:2px;width:1.8em;height:1.8em}.ui-datepicker .ui-datepicker-prev-hover,.ui-datepicker .ui-datepicker-next-hover{top:1px}.ui-datepicker .ui-datepicker-prev{left:2px}.ui-datepicker .ui-datepicker-next{right:2px}.ui-datepicker .ui-datepicker-prev-hover{left:1px}.ui-datepicker .ui-datepicker-next-hover{right:1px}.ui-datepicker .ui-datepicker-prev span,.ui-datepicker .ui-datepicker-next span{display:block;position:absolute;left:50%;margin-left:-8px;top:50%;margin-top:-8px}.ui-datepicker .ui-datepicker-title{margin:0 2.3em;line-height:1.8em;text-align:center}.ui-datepicker .ui-datepicker-title select{font-size:1em;margin:1px 0}.ui-datepicker select.ui-datepicker-month-year{width:100%}.ui-datepicker select.ui-datepicker-month,.ui-datepicker select.ui-datepicker-year{width:49%}.ui-datepicker table{width:100%;font-size:.9em;border-collapse:collapse;margin:0 0 .4em}.ui-datepicker th{padding:.7em .3em;text-align:center;font-weight:700;border:0}.ui-datepicker td{border:0;padding:1px}.ui-datepicker td span,.ui-datepicker td a{display:block;padding:.2em;text-align:right;text-decoration:none}.ui-datepicker .ui-datepicker-buttonpane{background-image:none;margin:.7em 0 0;padding:0 .2em;border-left:0;border-right:0;border-bottom:0}.ui-datepicker .ui-datepicker-buttonpane button{float:right;margin:.5em .2em .4em;cursor:pointer;padding:.2em .6em .3em;width:auto;overflow:visible}.ui-datepicker .ui-datepicker-buttonpane button.ui-datepicker-current{float:left}.ui-datepicker.ui-datepicker-multi{width:auto}.ui-datepicker-multi .ui-datepicker-group{float:left}.ui-datepicker-multi .ui-datepicker-group table{width:95%;margin:0 auto .4em}.ui-datepicker-multi-2 .ui-datepicker-group{width:50%}.ui-datepicker-multi-3 .ui-datepicker-group{width:33.3%}.ui-datepicker-multi-4 .ui-datepicker-group{width:25%}.ui-datepicker-multi .ui-datepicker-group-last .ui-datepicker-header,.ui-datepicker-multi .ui-datepicker-group-middle .ui-datepicker-header{border-left-width:0}.ui-datepicker-multi .ui-datepicker-buttonpane{clear:left}.ui-datepicker-row-break{clear:both;width:100%;font-size:0}.ui-datepicker-rtl{direction:rtl}.ui-datepicker-rtl .ui-datepicker-prev{right:2px;left:auto}.ui-datepicker-rtl .ui-datepicker-next{left:2px;right:auto}.ui-datepicker-rtl .ui-datepicker-prev:hover{right:1px;left:auto}.ui-datepicker-rtl .ui-datepicker-next:hover{left:1px;right:auto}.ui-datepicker-rtl .ui-datepicker-buttonpane{clear:right}.ui-datepicker-rtl .ui-datepicker-buttonpane button{float:left}.ui-datepicker-rtl .ui-datepicker-buttonpane button.ui-datepicker-current,.ui-datepicker-rtl .ui-datepicker-group{float:right}.ui-datepicker-rtl .ui-datepicker-group-last .ui-datepicker-header,.ui-datepicker-rtl .ui-datepicker-group-middle .ui-datepicker-header{border-right-width:0;border-left-width:1px}
css/rtl.css CHANGED
@@ -1 +1 @@
1
- body{direction:rtl;unicode-bidi:embed}input#url{direction:ltr}.wp-core-ui .button,.wp-core-ui .button-primary,.wp-core-ui .button-secondary{float:right;margin-left:6px;padding:0 3px}.xdetailed-errors,.xdetailed-updated{margin:2px 15px 5px}.wysija-footer,.wysija-version{margin:0 165px 0 20px}label input[type="checkbox"],label input[type="radio"]{margin:0 15px 0 5px}#review-follow div{float:right}#wysija-badge{left:0;right:auto}.about-wrap .feature-section.three-col div{float:right}.dividers ul{margin:0 30px 20px 0;overflow-x:auto;overflow-y:auto;width:620px}.cpt-type{left:0;right:auto;border-right:1px solid #CCCCCC;border-left:none}.wysija-footer,.wysija-version{margin:0 165px 0 20px}.wysija-version .social-foot{float:right}body.rtl #wysija_wrapper{right:0 !important}#wysija_popup_title h3{float:right;margin-right:10px}#wysija_popup_close{float:left;margin-left:10px}#wysija_toolbar{right:657px}.wj_images li,.wj_themes li{float:right}.wj_images #wj_images_preview,.wj_themes #wj_themes_preview{left:295px;right:auto}.wj_content a.wysija_item,.wysija_widget{padding:0 10px 0 0}.wj_styles form label{margin:0 3px 0 0}.wj_styles #aUnderlineInput{margin-right:10px !important}.wysija_item_settings{left:15px;right:auto}#wysija_toggle_images{left:5px;right:auto}#review-follow .review-left.large{float:right}#review-follow .review-left{background-position:100% 0}#review-follow div{float:right}#review-follow .review-left .description{margin-right:146px}#review-follow .review-right{background-image:url("../img/arrow_middle_rtl.jpg");background-position:100% 0}#review-follow .follow-right{background-image:url("../img/arrow_right_rtl.jpg");background-position:100% 0}#wysija-settings input[type="checkbox"],#wysija-settings input[type="radio"],#wysija-settings label input[type="checkbox"]{margin-left:6px}label:first-child input[type="checkbox"],label:first-child input[type="radio"],label input[type="checkbox"],label input[type="radio"]{margin:0 15px 0 5px}.linknamecboxes,.labelcheck{float:right}#premium-content div.feat-thumb{background-image:url("../img/rocket-small-rtl.png");background-position:100% 0;float:right}#wysija-settings .form-table th.rolestitle{text-align:right}.cronleft{float:right;margin:0 0 0 10px}.popup_content.autopost{width:auto}.popup_content{margin:10px 20px 0 0}#wysija-settings #sendingmethod .methods h3,#wysija-settings #multisite .methods p.title{float:right}#wysija-settings #sendingmethod .methods input,#wysija-settings #multisite .methods input{float:right;margin:0 0 0 5px}p.clearfix input,p.clearfix select{float:right}label.radio input{margin:0 0 0 5px}h2.title span,h2.title form{float:right;margin-left:5px;margin-right:0px}#wysija_form_toolbar{position:absolute;width:295px;right:670px !important}#wysija_form_toolbar a.wysija_form_item,.wysija_form_widget{padding-right:7px}
1
+ body{direction:rtl;unicode-bidi:embed}input#url{direction:ltr}.xdetailed-errors,.xdetailed-updated{margin:2px 15px 5px}.wysija-footer,.wysija-version{margin:0 165px 0 20px}label input[type="checkbox"],label input[type="radio"]{margin:0 15px 0 5px}input.searchsub.button{float:none}a.button-primary.install{float:none}#review-follow div{float:right}.about-wrap .feature-section.three-col div{float:right}#wysija-badge{left:0;right:auto}.dividers ul{overflow-x:auto;overflow-y:auto}.submit-box{text-align:left}.submit-box #insert-selection,.submit-box #back-selection{margin:10px 0 0 10px}#toggle-advanced{left:10px;top:0;right:auto}.articles #basic .search-box{float:left}.articles #basic .filters-box{float:right}.articles #search-submit{margin:0 0 0 14px}.articles .cpt-type{left:0;right:auto;border-right:1px solid #ccc;border-left:0 none}#advanced div.block{padding:0.8em 1em 0.8em 0}#advanced label{float:right}#image_width_slider{float:right}#slider_info{float:right}#advanced label.radio{float:right;margin:0 0 0 9px}#advanced label.radio input{margin:0 0 0 2px}#advanced div.group{float:right}#results .thumbnail{float:right;margin:0 0 0 10px}#results li .checkbox{cursor:pointer;margin:0 11px 0 0}#results li .checkbox_container{float:right}#results li label{float:right}#loading-icon{left:auto;right:16px;top:16px}.submit-box #loading-message{left:auto;right:39px}.wysija-footer,.wysija-version{margin:0 165px 0 20px}.wysija-version .social-foot{float:right}body.rtl #wysija_wrapper{right:0 !important}#wysija_popup_title h3{float:right;margin-right:10px}#wysija_popup_close{float:left;margin-left:10px}#wysija_toolbar{right:657px}.wj_images li,.wj_themes li{float:right}.wj_images #wj_images_preview,.wj_themes #wj_themes_preview{left:295px;right:auto}.wj_content a.wysija_item,.wysija_widget{padding:0 10px 0 0}.wj_styles form label{margin:0 3px 0 0}.wj_styles #aUnderlineInput{margin-right:10px !important}.wysija_item_settings{left:15px;right:auto}#wysija_toggle_images{left:5px;right:auto}#review-follow .review-left.large{float:right}#review-follow .review-left{background-position:100% 0}#review-follow div{float:right}#review-follow .review-left .description{margin-right:146px;margin-left:0px}#review-follow .review-right{background-image:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow_middle-rtl.jpg");background-position:100% 0}#review-follow .follow-right{background-image:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow_right-rtl.jpg");background-position:100% 0}#review-follow .follow-right38{background-image:url("http://s-plugins.wordpress.org/wysija-newsletters/assets/update_page/arrow-right-38-rtl.jpg");background-position:100% 0}#wysija-settings input[type="checkbox"],#wysija-settings input[type="radio"],#wysija-settings label input[type="checkbox"]{margin-left:6px}label:first-child input[type="checkbox"],label:first-child input[type="radio"],label input[type="checkbox"],label input[type="radio"]{margin:0 15px 0 5px}.linknamecboxes,.labelcheck,.geeky-option a,.geeky-option span{float:right}.checkbox_optin_label{margin:6px 0 0 6px;float:right}.checkbox_optin_value{float:right}#wysija-settings .form-table th.rolestitle{text-align:right}.cronleft{float:right;margin:0 0 0 10px}.popup_content.autopost{width:auto}.popup_content{margin:10px 10px 0 10px}#wysija-settings #sendingmethod .methods h3,#wysija-settings #multisite .methods p.title{float:right}#wysija-settings #sendingmethod .methods input,#wysija-settings #multisite .methods input{float:right;margin:0 0 0 5px}h2.title span,h2.title form{float:right;margin-left:5px;margin-right:0px}#wysija_form_toolbar{right:679px !important;left:auto !important}#wysija_form_toolbar a.wysija_form_item,.wysija_form_widget{padding-right:7px}.form_widget_settings p label{float:right;clear:right;width:200px}.form_widget_settings .selection .is_selected{float:right;margin:3px 6px 0 0 !important}.form_widget_settings .selection label{float:right;margin:0 5px 0 0}.form_widget_settings .selection .handle,.form_widget_settings .selection .remove{float:left;margin:3px 0 0 3px}.popup_content.inline_form p input,.popup_content.inline_form p select,.popup_content.inline_form p .group{float:right}.submit_button{margin:20px 0 20px 10px;text-align:left}.popup_content.inline_form .submit_button{margin:20px 0 0 4px}.popup_content.inline_form label.radio,.popup_content.inline_form .group label{float:right}.popup_content.inline_form input[type="radio"],.popup_content.inline_form input[type="checkbox"]{margin:0 0 0 3px}.wysija_form_item_settings{left:35px;right:auto !important}.wysija_form_item_delete{left:15px;right:auto !important}.bookmarks .networks label,.bookmarks .networks input{float:right}#results li .checkbox{margin-left:10px}.add span{float:right}.themes #wj_paginator{float:left;margin-right:0;margin-left:10px}
css/select2/select2.css ADDED
@@ -0,0 +1,615 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ /*
2
+ Version: 3.4.5 Timestamp: Mon Nov 4 08:22:42 PST 2013
3
+ */
4
+ .select2-container {
5
+ margin: 0;
6
+ position: relative;
7
+ display: inline-block;
8
+ /* inline-block for ie7 */
9
+ zoom: 1;
10
+ *display: inline;
11
+ vertical-align: middle;
12
+ }
13
+
14
+ .select2-container,
15
+ .select2-drop,
16
+ .select2-search,
17
+ .select2-search input {
18
+ /*
19
+ Force border-box so that % widths fit the parent
20
+ container without overlap because of margin/padding.
21
+
22
+ More Info : http://www.quirksmode.org/css/box.html
23
+ */
24
+ -webkit-box-sizing: border-box; /* webkit */
25
+ -moz-box-sizing: border-box; /* firefox */
26
+ box-sizing: border-box; /* css3 */
27
+ }
28
+
29
+ .select2-container .select2-choice {
30
+ display: block;
31
+ height: 26px;
32
+ padding: 0 0 0 8px;
33
+ overflow: hidden;
34
+ position: relative;
35
+
36
+ border: 1px solid #aaa;
37
+ white-space: nowrap;
38
+ line-height: 26px;
39
+ color: #444;
40
+ text-decoration: none;
41
+
42
+ border-radius: 4px;
43
+
44
+ background-clip: padding-box;
45
+
46
+ -webkit-touch-callout: none;
47
+ -webkit-user-select: none;
48
+ -moz-user-select: none;
49
+ -ms-user-select: none;
50
+ user-select: none;
51
+
52
+ background-color: #fff;
53
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.5, #fff));
54
+ background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 50%);
55
+ background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 50%);
56
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#ffffff', endColorstr = '#eeeeee', GradientType = 0);
57
+ background-image: linear-gradient(top, #fff 0%, #eee 50%);
58
+ }
59
+
60
+ .select2-container.select2-drop-above .select2-choice {
61
+ border-bottom-color: #aaa;
62
+
63
+ border-radius: 0 0 4px 4px;
64
+
65
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #eee), color-stop(0.9, #fff));
66
+ background-image: -webkit-linear-gradient(center bottom, #eee 0%, #fff 90%);
67
+ background-image: -moz-linear-gradient(center bottom, #eee 0%, #fff 90%);
68
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#ffffff', endColorstr='#eeeeee', GradientType=0);
69
+ background-image: linear-gradient(top, #eee 0%, #fff 90%);
70
+ }
71
+
72
+ .select2-container.select2-allowclear .select2-choice .select2-chosen {
73
+ margin-right: 42px;
74
+ }
75
+
76
+ .select2-container .select2-choice > .select2-chosen {
77
+ margin-right: 26px;
78
+ display: block;
79
+ overflow: hidden;
80
+
81
+ white-space: nowrap;
82
+
83
+ text-overflow: ellipsis;
84
+ }
85
+
86
+ .select2-container .select2-choice abbr {
87
+ display: none;
88
+ width: 12px;
89
+ height: 12px;
90
+ position: absolute;
91
+ right: 24px;
92
+ top: 8px;
93
+
94
+ font-size: 1px;
95
+ text-decoration: none;
96
+
97
+ border: 0;
98
+ background: url('../../img/select2/select2.png') right top no-repeat;
99
+ cursor: pointer;
100
+ outline: 0;
101
+ }
102
+
103
+ .select2-container.select2-allowclear .select2-choice abbr {
104
+ display: inline-block;
105
+ }
106
+
107
+ .select2-container .select2-choice abbr:hover {
108
+ background-position: right -11px;
109
+ cursor: pointer;
110
+ }
111
+
112
+ .select2-drop-mask {
113
+ border: 0;
114
+ margin: 0;
115
+ padding: 0;
116
+ position: fixed;
117
+ left: 0;
118
+ top: 0;
119
+ min-height: 100%;
120
+ min-width: 100%;
121
+ height: auto;
122
+ width: auto;
123
+ opacity: 0;
124
+ z-index: 9998;
125
+ /* styles required for IE to work */
126
+ background-color: #fff;
127
+ filter: alpha(opacity=0);
128
+ }
129
+
130
+ .select2-drop {
131
+ width: 100%;
132
+ margin-top: -1px;
133
+ position: absolute;
134
+ z-index: 9999;
135
+ top: 100%;
136
+
137
+ background: #fff;
138
+ color: #000;
139
+ border: 1px solid #aaa;
140
+ border-top: 0;
141
+
142
+ border-radius: 0 0 4px 4px;
143
+
144
+ -webkit-box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
145
+ box-shadow: 0 4px 5px rgba(0, 0, 0, .15);
146
+ }
147
+
148
+ .select2-drop-auto-width {
149
+ border-top: 1px solid #aaa;
150
+ width: auto;
151
+ }
152
+
153
+ .select2-drop-auto-width .select2-search {
154
+ padding-top: 4px;
155
+ }
156
+
157
+ .select2-drop.select2-drop-above {
158
+ margin-top: 1px;
159
+ border-top: 1px solid #aaa;
160
+ border-bottom: 0;
161
+
162
+ border-radius: 4px 4px 0 0;
163
+
164
+ -webkit-box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
165
+ box-shadow: 0 -4px 5px rgba(0, 0, 0, .15);
166
+ }
167
+
168
+ .select2-drop-active {
169
+ border: 1px solid #5897fb;
170
+ border-top: none;
171
+ }
172
+
173
+ .select2-drop.select2-drop-above.select2-drop-active {
174
+ border-top: 1px solid #5897fb;
175
+ }
176
+
177
+ .select2-container .select2-choice .select2-arrow {
178
+ display: inline-block;
179
+ width: 18px;
180
+ height: 100%;
181
+ position: absolute;
182
+ right: 0;
183
+ top: 0;
184
+
185
+ border-left: 1px solid #aaa;
186
+ border-radius: 0 4px 4px 0;
187
+
188
+ background-clip: padding-box;
189
+
190
+ background: #ccc;
191
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #ccc), color-stop(0.6, #eee));
192
+ background-image: -webkit-linear-gradient(center bottom, #ccc 0%, #eee 60%);
193
+ background-image: -moz-linear-gradient(center bottom, #ccc 0%, #eee 60%);
194
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr = '#eeeeee', endColorstr = '#cccccc', GradientType = 0);
195
+ background-image: linear-gradient(top, #ccc 0%, #eee 60%);
196
+ }
197
+
198
+ .select2-container .select2-choice .select2-arrow b {
199
+ display: block;
200
+ width: 100%;
201
+ height: 100%;
202
+ background: url('../../img/select2/select2.png') no-repeat 0 1px;
203
+ }
204
+
205
+ .select2-search {
206
+ display: inline-block;
207
+ width: 100%;
208
+ min-height: 26px;
209
+ margin: 0;
210
+ padding-left: 4px;
211
+ padding-right: 4px;
212
+
213
+ position: relative;
214
+ z-index: 10000;
215
+
216
+ white-space: nowrap;
217
+ }
218
+
219
+ .select2-search input {
220
+ width: 100%;
221
+ height: auto !important;
222
+ min-height: 26px;
223
+ padding: 4px 20px 4px 5px;
224
+ margin: 0;
225
+
226
+ outline: 0;
227
+ font-family: sans-serif;
228
+ font-size: 1em;
229
+
230
+ border: 1px solid #aaa;
231
+ border-radius: 0;
232
+
233
+ -webkit-box-shadow: none;
234
+ box-shadow: none;
235
+
236
+ background: #fff url('../../img/select2/select2.png') no-repeat 100% -22px;
237
+ background: url('../../img/select2/select2.png') no-repeat 100% -22px, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
238
+ background: url('../../img/select2/select2.png') no-repeat 100% -22px, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
239
+ background: url('../../img/select2/select2.png') no-repeat 100% -22px, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
240
+ background: url('../../img/select2/select2.png') no-repeat 100% -22px, linear-gradient(top, #fff 85%, #eee 99%);
241
+ }
242
+
243
+ .select2-drop.select2-drop-above .select2-search input {
244
+ margin-top: 4px;
245
+ }
246
+
247
+ .select2-search input.select2-active {
248
+ background: #fff url('../../img/select2/select2-spinner.gif') no-repeat 100%;
249
+ background: url('../../img/select2/select2-spinner.gif') no-repeat 100%, -webkit-gradient(linear, left bottom, left top, color-stop(0.85, #fff), color-stop(0.99, #eee));
250
+ background: url('../../img/select2/select2-spinner.gif') no-repeat 100%, -webkit-linear-gradient(center bottom, #fff 85%, #eee 99%);
251
+ background: url('../../img/select2/select2-spinner.gif') no-repeat 100%, -moz-linear-gradient(center bottom, #fff 85%, #eee 99%);
252
+ background: url('../../img/select2/select2-spinner.gif') no-repeat 100%, linear-gradient(top, #fff 85%, #eee 99%);
253
+ }
254
+
255
+ .select2-container-active .select2-choice,
256
+ .select2-container-active .select2-choices {
257
+ border: 1px solid #5897fb;
258
+ outline: none;
259
+
260
+ -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
261
+ box-shadow: 0 0 5px rgba(0, 0, 0, .3);
262
+ }
263
+
264
+ .select2-dropdown-open .select2-choice {
265
+ border-bottom-color: transparent;
266
+ -webkit-box-shadow: 0 1px 0 #fff inset;
267
+ box-shadow: 0 1px 0 #fff inset;
268
+
269
+ border-bottom-left-radius: 0;
270
+ border-bottom-right-radius: 0;
271
+
272
+ background-color: #eee;
273
+ background-image: -webkit-gradient(linear, left bottom, left top, color-stop(0, #fff), color-stop(0.5, #eee));
274
+ background-image: -webkit-linear-gradient(center bottom, #fff 0%, #eee 50%);
275
+ background-image: -moz-linear-gradient(center bottom, #fff 0%, #eee 50%);
276
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
277
+ background-image: linear-gradient(top, #fff 0%, #eee 50%);
278
+ }
279
+
280
+ .select2-dropdown-open.select2-drop-above .select2-choice,
281
+ .select2-dropdown-open.select2-drop-above .select2-choices {
282
+ border: 1px solid #5897fb;
283
+ border-top-color: transparent;
284
+
285
+ background-image: -webkit-gradient(linear, left top, left bottom, color-stop(0, #fff), color-stop(0.5, #eee));
286
+ background-image: -webkit-linear-gradient(center top, #fff 0%, #eee 50%);
287
+ background-image: -moz-linear-gradient(center top, #fff 0%, #eee 50%);
288
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#ffffff', GradientType=0);
289
+ background-image: linear-gradient(bottom, #fff 0%, #eee 50%);
290
+ }
291
+
292
+ .select2-dropdown-open .select2-choice .select2-arrow {
293
+ background: transparent;
294
+ border-left: none;
295
+ filter: none;
296
+ }
297
+ .select2-dropdown-open .select2-choice .select2-arrow b {
298
+ background-position: -18px 1px;
299
+ }
300
+
301
+ /* results */
302
+ .select2-results {
303
+ max-height: 200px;
304
+ padding: 0 0 0 4px;
305
+ margin: 4px 4px 4px 0;
306
+ position: relative;
307
+ overflow-x: hidden;
308
+ overflow-y: auto;
309
+ -webkit-tap-highlight-color: rgba(0, 0, 0, 0);
310
+ }
311
+
312
+ .select2-results ul.select2-result-sub {
313
+ margin: 0;
314
+ padding-left: 0;
315
+ }
316
+
317
+ .select2-results ul.select2-result-sub > li .select2-result-label { padding-left: 20px }
318
+ .select2-results ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 40px }
319
+ .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 60px }
320
+ .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 80px }
321
+ .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 100px }
322
+ .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 110px }
323
+ .select2-results ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub ul.select2-result-sub > li .select2-result-label { padding-left: 120px }
324
+
325
+ .select2-results li {
326
+ list-style: none;
327
+ display: list-item;
328
+ background-image: none;
329
+ }
330
+
331
+ .select2-results li.select2-result-with-children > .select2-result-label {
332
+ font-weight: bold;
333
+ }
334
+
335
+ .select2-results .select2-result-label {
336
+ padding: 3px 7px 4px;
337
+ margin: 0;
338
+ cursor: pointer;
339
+
340
+ min-height: 1em;
341
+
342
+ -webkit-touch-callout: none;
343
+ -webkit-user-select: none;
344
+ -moz-user-select: none;
345
+ -ms-user-select: none;
346
+ user-select: none;
347
+ }
348
+
349
+ .select2-results .select2-highlighted {
350
+ background: #3875d7;
351
+ color: #fff;
352
+ }
353
+
354
+ .select2-results li em {
355
+ background: #feffde;
356
+ font-style: normal;
357
+ }
358
+
359
+ .select2-results .select2-highlighted em {
360
+ background: transparent;
361
+ }
362
+
363
+ .select2-results .select2-highlighted ul {
364
+ background: #fff;
365
+ color: #000;
366
+ }
367
+
368
+
369
+ .select2-results .select2-no-results,
370
+ .select2-results .select2-searching,
371
+ .select2-results .select2-selection-limit {
372
+ background: #f4f4f4;
373
+ display: list-item;
374
+ }
375
+
376
+ /*
377
+ disabled look for disabled choices in the results dropdown
378
+ */
379
+ .select2-results .select2-disabled.select2-highlighted {
380
+ color: #666;
381
+ background: #f4f4f4;
382
+ display: list-item;
383
+ cursor: default;
384
+ }
385
+ .select2-results .select2-disabled {
386
+ background: #f4f4f4;
387
+ display: list-item;
388
+ cursor: default;
389
+ }
390
+
391
+ .select2-results .select2-selected {
392
+ display: none;
393
+ }
394
+
395
+ .select2-more-results.select2-active {
396
+ background: #f4f4f4 url('../../img/select2/select2-spinner.gif') no-repeat 100%;
397
+ }
398
+
399
+ .select2-more-results {
400
+ background: #f4f4f4;
401
+ display: list-item;
402
+ }
403
+
404
+ /* disabled styles */
405
+
406
+ .select2-container.select2-container-disabled .select2-choice {
407
+ background-color: #f4f4f4;
408
+ background-image: none;
409
+ border: 1px solid #ddd;
410
+ cursor: default;
411
+ }
412
+
413
+ .select2-container.select2-container-disabled .select2-choice .select2-arrow {
414
+ background-color: #f4f4f4;
415
+ background-image: none;
416
+ border-left: 0;
417
+ }
418
+
419
+ .select2-container.select2-container-disabled .select2-choice abbr {
420
+ display: none;
421
+ }
422
+
423
+
424
+ /* multiselect */
425
+
426
+ .select2-container-multi .select2-choices {
427
+ height: auto !important;
428
+ height: 1%;
429
+ margin: 0;
430
+ padding: 0;
431
+ position: relative;
432
+
433
+ border: 1px solid #aaa;
434
+ cursor: text;
435
+ overflow: hidden;
436
+
437
+ background-color: #fff;
438
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(1%, #eee), color-stop(15%, #fff));
439
+ background-image: -webkit-linear-gradient(top, #eee 1%, #fff 15%);
440
+ background-image: -moz-linear-gradient(top, #eee 1%, #fff 15%);
441
+ background-image: linear-gradient(top, #eee 1%, #fff 15%);
442
+ }
443
+
444
+ .select2-locked {
445
+ padding: 3px 5px 3px 5px !important;
446
+ }
447
+
448
+ .select2-container-multi .select2-choices {
449
+ min-height: 26px;
450
+ }
451
+
452
+ .select2-container-multi.select2-container-active .select2-choices {
453
+ border: 1px solid #5897fb;
454
+ outline: none;
455
+
456
+ -webkit-box-shadow: 0 0 5px rgba(0, 0, 0, .3);
457
+ box-shadow: 0 0 5px rgba(0, 0, 0, .3);
458
+ }
459
+ .select2-container-multi .select2-choices li {
460
+ float: left;
461
+ list-style: none;
462
+ }
463
+ .select2-container-multi .select2-choices .select2-search-field {
464
+ margin: 0;
465
+ padding: 0;
466
+ white-space: nowrap;
467
+ }
468
+
469
+ .select2-container-multi .select2-choices .select2-search-field input {
470
+ padding: 5px;
471
+ margin: 1px 0;
472
+
473
+ font-family: sans-serif;
474
+ font-size: 100%;
475
+ color: #666;
476
+ outline: 0;
477
+ border: 0;
478
+ -webkit-box-shadow: none;
479
+ box-shadow: none;
480
+ background: transparent !important;
481
+ }
482
+
483
+ .select2-container-multi .select2-choices .select2-search-field input.select2-active {
484
+ background: #fff url('../../img/select2/select2-spinner.gif') no-repeat 100% !important;
485
+ }
486
+
487
+ .select2-default {
488
+ color: #999 !important;
489
+ }
490
+
491
+ .select2-container-multi .select2-choices .select2-search-choice {
492
+ padding: 3px 5px 3px 18px;
493
+ margin: 3px 0 3px 5px;
494
+ position: relative;
495
+
496
+ line-height: 13px;
497
+ color: #333;
498
+ cursor: default;
499
+ border: 1px solid #aaaaaa;
500
+
501
+ border-radius: 3px;
502
+
503
+ -webkit-box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
504
+ box-shadow: 0 0 2px #fff inset, 0 1px 0 rgba(0, 0, 0, 0.05);
505
+
506
+ background-clip: padding-box;
507
+
508
+ -webkit-touch-callout: none;
509
+ -webkit-user-select: none;
510
+ -moz-user-select: none;
511
+ -ms-user-select: none;
512
+ user-select: none;
513
+
514
+ background-color: #e4e4e4;
515
+ filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#f4f4f4', GradientType=0);
516
+ background-image: -webkit-gradient(linear, 0% 0%, 0% 100%, color-stop(20%, #f4f4f4), color-stop(50%, #f0f0f0), color-stop(52%, #e8e8e8), color-stop(100%, #eee));
517
+ background-image: -webkit-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
518
+ background-image: -moz-linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
519
+ background-image: linear-gradient(top, #f4f4f4 20%, #f0f0f0 50%, #e8e8e8 52%, #eee 100%);
520
+ }
521
+ .select2-container-multi .select2-choices .select2-search-choice .select2-chosen {
522
+ cursor: default;
523
+ }
524
+ .select2-container-multi .select2-choices .select2-search-choice-focus {
525
+ background: #d4d4d4;
526
+ }
527
+
528
+ .select2-search-choice-close {
529
+ display: block;
530
+ width: 12px;
531
+ height: 13px;
532
+ position: absolute;
533
+ right: 3px;
534
+ top: 4px;
535
+
536
+ font-size: 1px;
537
+ outline: none;
538
+ background: url('../../img/select2/select2.png') right top no-repeat;
539
+ }
540
+
541
+ .select2-container-multi .select2-search-choice-close {
542
+ left: 3px;
543
+ }
544
+
545
+ .select2-container-multi .select2-choices .select2-search-choice .select2-search-choice-close:hover {
546
+ background-position: right -11px;
547
+ }
548
+ .select2-container-multi .select2-choices .select2-search-choice-focus .select2-search-choice-close {
549
+ background-position: right -11px;
550
+ }
551
+
552
+ /* disabled styles */
553
+ .select2-container-multi.select2-container-disabled .select2-choices {
554
+ background-color: #f4f4f4;
555
+ background-image: none;
556
+ border: 1px solid #ddd;
557
+ cursor: default;
558
+ }
559
+
560
+ .select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice {
561
+ padding: 3px 5px 3px 5px;
562
+ border: 1px solid #ddd;
563
+ background-image: none;
564
+ background-color: #f4f4f4;
565
+ }
566
+
567
+ .select2-container-multi.select2-container-disabled .select2-choices .select2-search-choice .select2-search-choice-close { display: none;
568
+ background: none;
569
+ }
570
+ /* end multiselect */
571
+
572
+
573
+ .select2-result-selectable .select2-match,
574
+ .select2-result-unselectable .select2-match {
575
+ text-decoration: underline;
576
+ }
577
+
578
+ .select2-offscreen, .select2-offscreen:focus {
579
+ clip: rect(0 0 0 0) !important;
580
+ width: 1px !important;
581
+ height: 1px !important;
582
+ border: 0 !important;
583
+ margin: 0 !important;
584
+ padding: 0 !important;
585
+ overflow: hidden !important;
586
+ position: absolute !important;
587
+ outline: 0 !important;
588
+ left: 0px !important;
589
+ top: 0px !important;
590
+ }
591
+
592
+ .select2-display-none {
593
+ display: none;
594
+ }
595
+
596
+ .select2-measure-scrollbar {
597
+ position: absolute;
598
+ top: -10000px;
599
+ left: -10000px;
600
+ width: 100px;
601
+ height: 100px;
602
+ overflow: scroll;
603
+ }
604
+ /* Retina-ize icons */
605
+
606
+ @media only screen and (-webkit-min-device-pixel-ratio: 1.5), only screen and (min-resolution: 144dpi) {
607
+ .select2-search input, .select2-search-choice-close, .select2-container .select2-choice abbr, .select2-container .select2-choice .select2-arrow b {
608
+ background-image: url('../../img/select2/select2x2.png') !important;
609
+ background-repeat: no-repeat !important;
610
+ background-size: 60px 40px !important;
611
+ }
612
+ .select2-search input {
613
+ background-position: 100% -21px !important;
614
+ }
615
+ }
css/smoothness/jquery-ui-1.8.20.custom.css CHANGED
@@ -35,7 +35,7 @@
35
  ----------------------------------*/
36
 
37
  /* Overlays */
38
- .ui-widget-overlay { position: absolute; top: 0; left: 0; width: 100%; height: 100%; }
39
 
40
 
41
  /*!
@@ -341,7 +341,7 @@
341
  *
342
  * http://docs.jquery.com/UI/Autocomplete#theming
343
  */
344
- .ui-autocomplete { position: absolute; cursor: default; }
345
 
346
  /* workarounds */
347
  * html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */
@@ -397,8 +397,8 @@
397
  .ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; text-decoration: none !important; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */
398
  .ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */
399
  button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */
400
- .ui-button-icons-only { width: 3.4em; }
401
- button.ui-button-icons-only { width: 3.7em; }
402
 
403
  /*button text element */
404
  .ui-button .ui-button-text { display: block; line-height: 1.4; }
@@ -434,9 +434,9 @@ button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra pad
434
  */
435
  .ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; }
436
  .ui-dialog .ui-dialog-titlebar { padding: .4em 1em; position: relative; }
437
- .ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; }
438
  .ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
439
- .ui-dialog .ui-dialog-titlebar-close span { display: block; margin: 1px; }
440
  .ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; }
441
  .ui-dialog .ui-dialog-content { position: relative; border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; }
442
  .ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; }
@@ -506,7 +506,7 @@ button.ui-button::-moz-focus-inner { border: 0; padding: 0; } /* reset extra pad
506
  .ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
507
  .ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
508
  .ui-datepicker select.ui-datepicker-month-year {width: 100%;}
509
- .ui-datepicker select.ui-datepicker-month,
510
  .ui-datepicker select.ui-datepicker-year { width: 49%;}
511
  .ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
512
  .ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; }
35
  ----------------------------------*/
36
 
37
  /* Overlays */
38
+ .ui-widget-overlay { position: fixed; top: 0; left: 0; width: 100%; height: 100%; }
39
 
40
 
41
  /*!
341
  *
342
  * http://docs.jquery.com/UI/Autocomplete#theming
343
  */
344
+ .ui-autocomplete { position: absolute; cursor: default; }
345
 
346
  /* workarounds */
347
  * html .ui-autocomplete { width:1px; } /* without this, the menu expands to 100% in IE6 */
397
  .ui-button { display: inline-block; position: relative; padding: 0; margin-right: .1em; text-decoration: none !important; cursor: pointer; text-align: center; zoom: 1; overflow: visible; } /* the overflow property removes extra width in IE */
398
  .ui-button-icon-only { width: 2.2em; } /* to make room for the icon, a width needs to be set here */
399
  button.ui-button-icon-only { width: 2.4em; } /* button elements seem to need a little more width */
400
+ .ui-button-icons-only { width: 3.4em; }
401
+ button.ui-button-icons-only { width: 3.7em; }
402
 
403
  /*button text element */
404
  .ui-button .ui-button-text { display: block; line-height: 1.4; }
434
  */
435
  .ui-dialog { position: absolute; padding: .2em; width: 300px; overflow: hidden; }
436
  .ui-dialog .ui-dialog-titlebar { padding: .4em 1em; position: relative; }
437
+ .ui-dialog .ui-dialog-title { float: left; margin: .1em 16px .1em 0; }
438
  .ui-dialog .ui-dialog-titlebar-close { position: absolute; right: .3em; top: 50%; width: 19px; margin: -10px 0 0 0; padding: 1px; height: 18px; }
439
+ .ui-dialog .ui-dialog-titlebar-close span { display: block; }
440
  .ui-dialog .ui-dialog-titlebar-close:hover, .ui-dialog .ui-dialog-titlebar-close:focus { padding: 0; }
441
  .ui-dialog .ui-dialog-content { position: relative; border: 0; padding: .5em 1em; background: none; overflow: auto; zoom: 1; }
442
  .ui-dialog .ui-dialog-buttonpane { text-align: left; border-width: 1px 0 0 0; background-image: none; margin: .5em 0 0 0; padding: .3em 1em .5em .4em; }
506
  .ui-datepicker .ui-datepicker-title { margin: 0 2.3em; line-height: 1.8em; text-align: center; }
507
  .ui-datepicker .ui-datepicker-title select { font-size:1em; margin:1px 0; }
508
  .ui-datepicker select.ui-datepicker-month-year {width: 100%;}
509
+ .ui-datepicker select.ui-datepicker-month,
510
  .ui-datepicker select.ui-datepicker-year { width: 49%;}
511
  .ui-datepicker table {width: 100%; font-size: .9em; border-collapse: collapse; margin:0 0 .4em; }
512
  .ui-datepicker th { padding: .7em .3em; text-align: center; font-weight: bold; border: 0; }
css/tmce/editor.css ADDED
@@ -0,0 +1,2317 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+
2
+ /*------------------------------------------------------------------------------
3
+
4
+ TinyMCE and Quicklinks toolbars
5
+ ------------------------------------------------------------------------------*/
6
+
7
+ /* wp_theme/ui.css */
8
+ .wp_themeSkin table,
9
+ .wp_themeSkin tbody,
10
+ .wp_themeSkin a,
11
+ .wp_themeSkin img,
12
+ .wp_themeSkin tr,
13
+ .wp_themeSkin div,
14
+ .wp_themeSkin td,
15
+ .wp_themeSkin iframe,
16
+ .wp_themeSkin span,
17
+ .wp_themeSkin *,
18
+ .wp_themeSkin .mceText {
19
+ border: 0;
20
+ margin: 0;
21
+ padding: 0;
22
+ white-space: nowrap;
23
+ text-decoration: none;
24
+ font-weight: normal;
25
+ cursor: default;
26
+ vertical-align: baseline;
27
+ width: auto;
28
+ border-collapse: separate;
29
+ }
30
+
31
+ .wp_themeSkin a:hover,
32
+ .wp_themeSkin a:link,
33
+ .wp_themeSkin a:visited,
34
+ .wp_themeSkin a:active {
35
+ text-decoration: none;
36
+ font-weight: normal;
37
+ cursor: default;
38
+ }
39
+
40
+ .wp_themeSkin table td {
41
+ vertical-align: middle;
42
+ }
43
+
44
+ .wp_themeSkin *,
45
+ .wp_themeSkin a:hover,
46
+ .wp_themeSkin a:link,
47
+ .wp_themeSkin a:visited,
48
+ .wp_themeSkin a:active {
49
+ color: #555;
50
+ }
51
+
52
+ /* These are part of TinyMCE, used in TinyMCE Advanced, but not WordPress. These are not updated for 3.8's design. */
53
+ .wp_themeSkin span.mce_sup,
54
+ .wp_themeSkin span.mce_sub,
55
+ .wp_themeSkin span.mce_media,
56
+ .wp_themeSkin span.mce_styleprops,
57
+ .wp_themeSkin span.mce_search,
58
+ .wp_themeSkin span.mce_emotions,
59
+ .wp_themeSkin span.mce_print,
60
+ .wp_themeSkin span.mce_attribs,
61
+ .wp_themeSkin span.mce_hr,
62
+ .wp_themeSkin span.mce_cut,
63
+ .wp_themeSkin span.mce_copy,
64
+ .wp_themeSkin span.mce_paste,
65
+ .wp_themeSkin span.mce_cite,
66
+ .wp_themeSkin span.mce_visualchars,
67
+ .wp_themeSkin span.mce_advhr,
68
+ .wp_themeSkin span.mce_insertdate,
69
+ .wp_themeSkin span.mce_anchor,
70
+ .wp_themeSkin span.mce_visualaid,
71
+ .wp_themeSkin span.mce_cleanup,
72
+ .wp_themeSkin span.mce_table,
73
+ .wp_themeSkin span.mce_row_props,
74
+ .wp_themeSkin span.mce_cell_props,
75
+ .wp_themeSkin span.mce_row_before,
76
+ .wp_themeSkin span.mce_row_after,
77
+ .wp_themeSkin span.mce_delete_row,
78
+ .wp_themeSkin span.mce_col_before,
79
+ .wp_themeSkin span.mce_col_after,
80
+ .wp_themeSkin span.mce_delete_col,
81
+ .wp_themeSkin span.mce_split_cells,
82
+ .wp_themeSkin span.mce_merge_cells,
83
+ .wp_themeSkin span.mce_delete_table,
84
+ .wp_themeSkin span.mce_ins,
85
+ .wp_themeSkin span.mce_abbr,
86
+ .wp_themeSkin span.mce_acronym,
87
+ .wp_themeSkin span.mce_del,
88
+ .wp_themeSkin span.mce_replace,
89
+ .wp_themeSkin span.mce_code,
90
+ .wp_themeSkin span.mce_nonbreaking,
91
+ .wp_themeSkin span.mce_inserttime,
92
+ .wp_themeSkin span.mce_insertlayer,
93
+ .wp_themeSkin span.mce_moveforward,
94
+ .wp_themeSkin span.mce_movebackward,
95
+ .wp_themeSkin span.mce_absolute {
96
+ -moz-transition: none;
97
+ -webkit-transition: none;
98
+ transition: none;
99
+ background: url("../js/tinymce/skins/wordpress/images/icons.gif") no-repeat 20px 20px;
100
+ }
101
+
102
+ .wp_themeSkin span.mce_code:after {
103
+ content: '\f475';
104
+ font-family: 'dashicons';
105
+ }
106
+
107
+ /* No @font-face support */
108
+ .no-font-face .wp_themeSkin span.mce_undo,
109
+ .no-font-face .wp_themeSkin span.mce_redo,
110
+ .no-font-face .wp_themeSkin span.mce_bullist,
111
+ .no-font-face .wp_themeSkin span.mce_numlist,
112
+ .no-font-face .wp_themeSkin span.mce_blockquote,
113
+ .no-font-face .wp_themeSkin span.mce_charmap,
114
+ .no-font-face .wp_themeSkin span.mce_bold,
115
+ .no-font-face .wp_themeSkin span.mce_italic,
116
+ .no-font-face .wp_themeSkin span.mce_underline,
117
+ .no-font-face .wp_themeSkin span.mce_justifyleft,
118
+ .no-font-face .wp_themeSkin span.mce_justifyright,
119
+ .no-font-face .wp_themeSkin span.mce_justifycenter,
120
+ .no-font-face .wp_themeSkin span.mce_justifyfull,
121
+ .no-font-face .wp_themeSkin span.mce_indent,
122
+ .no-font-face .wp_themeSkin span.mce_outdent,
123
+ .no-font-face .wp_themeSkin span.mce_link,
124
+ .no-font-face .wp_themeSkin span.mce_unlink,
125
+ .no-font-face .wp_themeSkin span.mce_help,
126
+ .no-font-face .wp_themeSkin span.mce_removeformat,
127
+ .no-font-face .wp_themeSkin span.mce_fullscreen,
128
+ .no-font-face .wp_themeSkin span.mce_wp_fullscreen,
129
+ .no-font-face .wp_themeSkin span.mce_media,
130
+ .no-font-face .wp_themeSkin span.mce_pastetext,
131
+ .no-font-face .wp_themeSkin span.mce_pasteword,
132
+ .no-font-face .wp_themeSkin span.mce_wp_help,
133
+ .no-font-face .wp_themeSkin span.mce_wp_adv,
134
+ .no-font-face .wp_themeSkin span.mce_wp_more,
135
+ .no-font-face .wp_themeSkin span.mce_strikethrough,
136
+ .no-font-face .wp_themeSkin span.mce_spellchecker,
137
+ .no-font-face .wp_themeSkin span.mce_forecolor,
138
+ .no-font-face .wp_themeSkin .mce_forecolorpicker,
139
+ .no-font-face .wp_themeSkin .mceSplitButton .mce_spellchecker span.mce_spellchecker,
140
+ .no-font-face .wp_themeSkin .mceSplitButton .mce_forecolor span.mce_forecolor,
141
+ .no-font-face .wp_themeSkin .mceSplitButton span.mce_numlist,
142
+ .no-font-face .wp_themeSkin .mceSplitButton span.mce_bullist {
143
+ -moz-transition: none;
144
+ -webkit-transition: none;
145
+ transition: none;
146
+ background-image: url('../images/wpicons.png?ver=20120720');
147
+ }
148
+
149
+ /* Theme */
150
+ .no-font-face .wp_themeSkin span.mce_undo {background-position:-500px -20px}
151
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_undo,
152
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_undo {background-position:-500px 0}
153
+
154
+ .no-font-face .wp_themeSkin span.mce_redo {background-position:-480px -20px}
155
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_redo,
156
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_redo {background-position:-480px 0}
157
+
158
+ .no-font-face .wp_themeSkin span.mce_bullist {background-position:-40px -20px}
159
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_bullist,
160
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_bullist,
161
+ .no-font-face .wp_themeSkin .mceSplitButton:hover span.mce_bullist {background-position:-40px 0}
162
+
163
+ .no-font-face .wp_themeSkin span.mce_numlist {background-position:-60px -20px}
164
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_numlist,
165
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_numlist,
166
+ .no-font-face .wp_themeSkin .mceSplitButton:hover span.mce_numlist {background-position:-60px 0}
167
+
168
+ .no-font-face .wp_themeSkin span.mce_blockquote {background-position:-80px -20px}
169
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_blockquote,
170
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_blockquote {background-position:-80px 0}
171
+
172
+ .no-font-face .wp_themeSkin span.mce_charmap {background-position:-420px -20px}
173
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_charmap,
174
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_charmap {background-position:-420px 0}
175
+
176
+ .no-font-face .wp_themeSkin span.mce_bold {background-position:0 -20px}
177
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_bold,
178
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_bold {background-position:0 0}
179
+
180
+ .no-font-face .wp_themeSkin span.mce_italic {background-position:-20px -20px}
181
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_italic,
182
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_italic {background-position:-20px 0}
183
+
184
+ .no-font-face .wp_themeSkin span.mce_underline {background-position:-280px -20px}
185
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_underline,
186
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_underline {background-position:-280px 0}
187
+
188
+ .no-font-face .wp_themeSkin span.mce_justifyleft {background-position:-100px -20px}
189
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_justifyleft,
190
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_justifyleft {background-position:-100px 0}
191
+
192
+ .no-font-face .wp_themeSkin span.mce_justifyright {background-position:-140px -20px}
193
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_justifyright,
194
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_justifyright {background-position:-140px 0}
195
+
196
+ .no-font-face .wp_themeSkin span.mce_justifycenter {background-position:-120px -20px}
197
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_justifycenter,
198
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_justifycenter {background-position:-120px 0}
199
+
200
+ .no-font-face .wp_themeSkin span.mce_justifyfull {background-position:-300px -20px}
201
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_justifyfull,
202
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_justifyfull {background-position:-300px 0}
203
+
204
+ .no-font-face .wp_themeSkin span.mce_indent {background-position:-460px -20px}
205
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_indent,
206
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_indent {background-position:-460px 0}
207
+
208
+ .no-font-face .wp_themeSkin span.mce_outdent {background-position:-440px -20px}
209
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_outdent,
210
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_outdent {background-position:-440px 0}
211
+
212
+ .no-font-face .wp_themeSkin span.mce_link {background-position:-160px -20px}
213
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_link,
214
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_link {background-position:-160px 0}
215
+
216
+ .no-font-face .wp_themeSkin span.mce_unlink {background-position:-180px -20px}
217
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_unlink,
218
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_unlink {background-position:-180px 0}
219
+
220
+ .no-font-face .wp_themeSkin span.mce_help {background-position:-520px -20px}
221
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_help,
222
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_help {background-position:-520px 0}
223
+
224
+ .no-font-face .wp_themeSkin span.mce_removeformat {background-position:-380px -20px}
225
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_removeformat,
226
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_removeformat {background-position:-380px 0}
227
+
228
+ .no-font-face .wp_themeSkin span.mce_strikethrough {background-position:-540px -20px;}
229
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_strikethrough,
230
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_strikethrough {background-position:-540px 0}
231
+
232
+ .no-font-face .wp_themeSkin .mceSplitButton .mce_forecolor span.mce_forecolor {background-position:-320px -20px}
233
+ .no-font-face .wp_themeSkin .mceSplitButtonEnabled:hover span.mce_forecolor,
234
+ .no-font-face .wp_themeSkin .mceSplitButtonSelected span.mce_forecolor {background-position:-320px 0}
235
+
236
+ .no-font-face .wp_themeSkin .mce_forecolorpicker {background-position:-320px -20px}
237
+
238
+ /* Plugins in WP */
239
+ .no-font-face .wp_themeSkin span.mce_fullscreen {background-position:-240px -20px}
240
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_fullscreen,
241
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_fullscreen {background-position:-240px 0}
242
+
243
+ .no-font-face .wp_themeSkin span.mce_wp_fullscreen {background-position:-240px -20px}
244
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_wp_fullscreen,
245
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_wp_fullscreen {background-position:-240px 0}
246
+
247
+ .no-font-face .wp_themeSkin span.mce_media {background-position:-400px -20px}
248
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_media,
249
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_media {background-position:-400px 0}
250
+
251
+ .no-font-face .wp_themeSkin span.mce_pastetext {background-position:-340px -20px}
252
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_pastetext,
253
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_pastetext {background-position:-340px 0}
254
+
255
+ .no-font-face .wp_themeSkin span.mce_pasteword {background-position:-360px -20px}
256
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_pasteword,
257
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_pasteword {background-position:-360px 0}
258
+
259
+ .no-font-face .wp_themeSkin span.mce_spellchecker {background-position:-220px -20px}
260
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_spellchecker,
261
+ .no-font-face .wp_themeSkin .mceSplitButtonEnabled:hover span.mce_spellchecker,
262
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_spellchecker,
263
+ .no-font-face .wp_themeSkin .mceSplitButtonSelected span.mce_spellchecker {background-position:-220px 0}
264
+
265
+ .no-font-face .wp_themeSkin span.mce_wp_help {background-position:-520px -20px}
266
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_wp_help,
267
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_wp_help {background-position:-520px 0}
268
+
269
+ .no-font-face .wp_themeSkin span.mce_wp_adv {background-position:-260px -20px}
270
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_wp_adv,
271
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_wp_adv {background-position:-260px 0}
272
+
273
+ .no-font-face .wp_themeSkin span.mce_wp_more {background-position:-200px -20px}
274
+ .no-font-face .wp_themeSkin .mceButtonEnabled:hover span.mce_wp_more,
275
+ .no-font-face .wp_themeSkin .mceButtonActive span.mce_wp_more {background-position:-200px 0}
276
+
277
+ .no-font-face .mceIcon:before {
278
+ display: none !important;
279
+ }
280
+ /* End no @font-face */
281
+
282
+ /* Containers */
283
+ .wp_themeSkin table {}
284
+
285
+ .wp_themeSkin iframe {
286
+ display: block;
287
+ }
288
+
289
+ .wp_themeSkin #mce_fullscreen_ifr {
290
+ background-color: #fff;
291
+ }
292
+
293
+ .wp_themeSkin .mceToolbar {
294
+ padding: 1px;
295
+ }
296
+
297
+ /* External */
298
+ .wp_themeSkin .mceExternalToolbar {
299
+ position: absolute;
300
+ border-bottom: 0;
301
+ display: none;
302
+ }
303
+
304
+ .wp_themeSkin .mceExternalToolbar td.mceToolbar {
305
+ padding-right: 13px;
306
+ }
307
+
308
+ .wp_themeSkin .mceExternalClose {
309
+ position: absolute;
310
+ top: 3px;
311
+ right: 3px;
312
+ width: 7px;
313
+ height: 7px;
314
+ background: url("../js/tinymce/skins/wordpress/images/icons.gif") -820px 0;
315
+ }
316
+
317
+ /* Layout */
318
+ .wp_themeSkin table.mceToolbar,
319
+ .wp_themeSkin tr.mceFirst .mceToolbar tr td,
320
+ .wp_themeSkin tr.mceLast .mceToolbar tr td {
321
+ border: 0;
322
+ margin: 0;
323
+ padding: 0;
324
+ }
325
+
326
+ .wp_themeSkin table.mceLayout {
327
+ border: 0;
328
+ }
329
+
330
+ .wp_themeSkin .mceStatusbar {
331
+ background: #fff;
332
+ border-top: 1px solid #eee;
333
+ color: #000;
334
+ display: block;
335
+ font-family: sans-serif;
336
+ font-size: 12px;
337
+ height: 20px;
338
+ line-height: 16px;
339
+ padding: 0 0 0 8px;
340
+ overflow: visible;
341
+ }
342
+
343
+ .wp_themeSkin .mceStatusbar * {
344
+ color: #555;
345
+ }
346
+
347
+ .wp_themeSkin .mceStatusbar div {
348
+ float: left;
349
+ padding: 2px;
350
+ }
351
+
352
+ .wp_themeSkin .mceStatusbar a.mceResize {
353
+ display: block;
354
+ float: right;
355
+ background: url("../js/tinymce/skins/wordpress/images/icons.gif") -800px 0;
356
+ width: 20px;
357
+ height: 20px;
358
+ cursor: se-resize;
359
+ }
360
+
361
+ .wp_themeSkin .mceStatusbar a:hover {
362
+ text-decoration: underline;
363
+ }
364
+
365
+ .wp_themeSkin table.mceToolbar {
366
+ margin: 0 6px 2px;
367
+ }
368
+
369
+ .wp_themeSkin table.mceToolbar :active,
370
+ .wp_themeSkin table.mceToolbar :focus,
371
+ .wp_themeSkin table.mceToolbar:focus,
372
+ .wp_themeSkin span.mceSeparator:focus {
373
+ outline: none;
374
+ }
375
+
376
+ .wp_themeSkin #content_toolbar1 {
377
+ margin-top: 2px;
378
+ }
379
+
380
+ .wp_themeSkin .mceToolbar .mceToolbarEndListBox span {
381
+ display: none;
382
+ }
383
+
384
+ .wp_themeSkin span.mceIcon,
385
+ .wp_themeSkin img.mceIcon {
386
+ display: block;
387
+ width: 20px;
388
+ height: 20px;
389
+ }
390
+
391
+ a .mceIcon, .mceAction {
392
+ text-align: center;
393
+ font: normal 20px/1 'dashicons' !important;
394
+ speak: none;
395
+ -webkit-font-smoothing: antialiased;
396
+ -moz-osx-font-smoothing: grayscale;
397
+ }
398
+
399
+ .mceAction {
400
+ line-height:16px;
401
+ }
402
+
403
+ /* Button */
404
+ .wp_themeSkin .mceButton {
405
+ display: block;
406
+ width: 20px;
407
+ height: 20px;
408
+ cursor: default;
409
+ padding: 1px 2px;
410
+ margin: 1px;
411
+ -webkit-border-radius: 2px;
412
+ border-radius: 2px;
413
+ }
414
+
415
+ .wp_themeSkin a.mceButtonEnabled:hover {
416
+ background-image: inherit 0 -10px;
417
+ }
418
+
419
+ .wp_themeSkin .mceOldBoxModel a.mceButton span, .wp_themeSkin .mceOldBoxModel a.mceButton img {
420
+ margin: 0 0 0 1px;
421
+ }
422
+
423
+ .wp_themeSkin .mceButtonDisabled .mceIcon {
424
+ opacity: 0.2;
425
+ filter: alpha(opacity=20);
426
+ }
427
+
428
+ /* Separator */
429
+ .wp_themeSkin .mceSeparator {
430
+ display: none;
431
+ }
432
+
433
+ /* ListBox */
434
+ .wp_themeSkin .mceListBox,
435
+ .wp_themeSkin .mceListBox a {
436
+ display: block;
437
+ }
438
+
439
+ .wp_themeSkin .mceListBox .mceText {
440
+ padding: 1px 4px 1px 5px;
441
+ width: 70px;
442
+ text-align: left;
443
+ text-decoration: none;
444
+ -webkit-border-bottom-left-radius: 2px;
445
+ -webkit-border-top-left-radius: 2px;
446
+ border-bottom-left-radius: 2px;
447
+ border-top-left-radius: 2px;
448
+ font-family: sans-serif;
449
+ font-size: 12px;
450
+ height: 20px;
451
+ line-height: 20px;
452
+ overflow: hidden;
453
+ }
454
+
455
+ .wp_themeSkin .mceListBox {
456
+ margin: 1px;
457
+ direction: ltr;
458
+ background-color: #fff;
459
+ border: 1px solid #ddd;
460
+ -webkit-box-shadow: inset 0 1px 1px -1px rgba(0, 0, 0, .2);
461
+ box-shadow: inset 0 1px 1px -1px rgba(0, 0, 0, .2);
462
+ }
463
+
464
+ .wp_themeSkin .mceListBox .mceOpen {
465
+ width: 12px;
466
+ height: 20px;
467
+ border-collapse: separate;
468
+ padding: 1px;
469
+ -webkit-border-bottom-left-radius: 0;
470
+ -webkit-border-top-left-radius: 0;
471
+ border-bottom-left-radius: 0;
472
+ border-top-left-radius: 0;
473
+ }
474
+
475
+ .wp_themeSkin .mceListBox .mceFirst a {
476
+ border-style: solid;
477
+ border-width: 1px;
478
+ border-bottom-right-radius: 2px;
479
+ border-top-right-radius: 2px;
480
+ }
481
+
482
+ .wp_themeSkin .mceListBoxMenu .mce_formatPreview {
483
+ line-height: normal;
484
+ }
485
+
486
+ .wp_themeSkin .mceListBox .mceOpen,
487
+ .wp_themeSkin .mceListBoxHover .mceOpen,
488
+ .wp_themeSkin .mceListBoxSelected .mceOpen,
489
+ .wp_themeSkin table.mceListBoxEnabled .mceOpen {
490
+ background-image: url("../../../../../wp-includes/images/down_arrow.gif");
491
+ background-position: 3px 1px;
492
+ background-repeat: no-repeat;
493
+ }
494
+
495
+ .wp_themeSkin .mceListBoxDisabled .mceText {
496
+ color: gray;
497
+ }
498
+
499
+ .wp_themeSkin .mceListBoxMenu {
500
+ overflow: auto;
501
+ overflow-x: hidden;
502
+ }
503
+
504
+ .wp_themeSkin .mceOldBoxModel .mceListBox .mceText {
505
+ height: 22px;
506
+ }
507
+
508
+ .wp_themeSkin select.mceListBox {
509
+ font-family: sans-serif;
510
+ font-size: 12px;
511
+ border-color: #b2b2b2;
512
+ background-color: #fff;
513
+ }
514
+
515
+ /* SplitButton */
516
+ .wp_themeSkin .mceSplitButton a,
517
+ .wp_themeSkin .mceSplitButton span {
518
+ display: block;
519
+ height: 20px;
520
+ }
521
+
522
+ .wp_themeSkin .mceSplitButton {
523
+ display: block;
524
+ direction: ltr;
525
+ }
526
+
527
+ .wp_themeSkin table.mceSplitButton td {
528
+ padding: 2px;
529
+ -webkit-border-radius: 2px;
530
+ border-radius: 2px;
531
+ }
532
+
533
+ .wp_themeSkin table.mceSplitButton:hover td {
534
+ background-image: inherit 0 -10px;
535
+ }
536
+
537
+ .wp_themeSkin .mceSplitButton a.mceAction {
538
+ height: 20px;
539
+ width: 20px;
540
+ padding: 1px 2px;
541
+ border-right: 0 none;
542
+ }
543
+
544
+ .wp_themeSkin .mceSplitButton span.mceAction {
545
+ background-image: url("../../../../../wp-includes/js/tinymce/skins/wordpress/images/icons.gif");
546
+ background-repeat: no-repeat;
547
+ background-color: transparent;
548
+ width: 20px;
549
+ }
550
+
551
+ .wp_themeSkin .mceSplitButton span.mceAction.mce_bullist,
552
+ .wp_themeSkin .mceSplitButton span.mceAction.mce_numlist {
553
+ background-image: none;
554
+ }
555
+
556
+ .wp_themeSkin .mceSplitButton a.mceOpen {
557
+ width: 11px;
558
+ height: 20px;
559
+ background-position: 0px 2px;
560
+ background-repeat: no-repeat;
561
+ padding: 1px 0;
562
+ }
563
+
564
+ .wp_themeSkin .mceSplitButton span.mceOpen {
565
+ display: none;
566
+ }
567
+
568
+ .wp_themeSkin .mceSplitButtonDisabled .mceAction {
569
+ opacity: 0.3;
570
+ filter: alpha(opacity=30);
571
+ }
572
+
573
+ .wp_themeSkin .mceListBox a.mceText,
574
+ .wp_themeSkin .mceSplitButton a.mceAction {
575
+ -webkit-border-bottom-left-radius: 2px;
576
+ -webkit-border-top-left-radius: 2px;
577
+ border-bottom-left-radius: 2px;
578
+ border-top-left-radius: 2px;
579
+ }
580
+
581
+ .wp_themeSkin .mceSplitButton a.mceOpen,
582
+ .wp_themeSkin .mceListBox a.mceOpen {
583
+ -webkit-border-bottom-right-radius: 2px;
584
+ -webkit-border-top-right-radius: 2px;
585
+ border-bottom-right-radius: 2px;
586
+ border-top-right-radius: 2px;
587
+ }
588
+
589
+ /* ColorSplitButton */
590
+ .wp_themeSkin div.mceColorSplitMenu table {
591
+ background-color: #ebebeb;
592
+ border-color: #bbb;
593
+ }
594
+
595
+ .wp_themeSkin .mceColorSplitMenu td {
596
+ padding: 2px;
597
+ }
598
+
599
+ .wp_themeSkin .mceColorSplitMenu a {
600
+ display: block;
601
+ width: 9px;
602
+ height: 9px;
603
+ overflow: hidden;
604
+ border-color: #B2B2B2;
605
+ }
606
+
607
+ .wp_themeSkin .mceColorSplitMenu td.mceMoreColors {
608
+ padding: 1px 3px 1px 1px;
609
+ }
610
+
611
+ .wp_themeSkin .mceColorSplitMenu a.mceMoreColors {
612
+ width: 100%;
613
+ height: auto;
614
+ text-align: center;
615
+ font-family: "Open Sans", sans-serif;
616
+ font-size: 11px;
617
+ line-height: 20px;
618
+ border-color: #fff;
619
+ }
620
+
621
+ .wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover {}
622
+ .wp_themeSkin a.mceMoreColors:hover {}
623
+ .wp_themeSkin .mceColorPreview {
624
+ margin: -5px 0 0 2px;
625
+ width: 16px;
626
+ height: 4px;
627
+ overflow: hidden;
628
+ }
629
+
630
+ /* Menu */
631
+ .wp_themeSkin .mceMenu {
632
+ position: absolute;
633
+ left: 0;
634
+ top: 0;
635
+ z-index: 1000;
636
+ border-color: #ddd;
637
+ direction: ltr;
638
+ }
639
+
640
+ .wp_themeSkin .mceNoIcons span.mceIcon {
641
+ width: 0;
642
+ }
643
+
644
+ .wp_themeSkin .mceNoIcons a .mceText {
645
+ padding-left: 10px;
646
+ }
647
+
648
+ .wp_themeSkin .mceMenu table {
649
+ background-color: #ebeaeb;
650
+ }
651
+
652
+ .wp_themeSkin .mceMenu a,
653
+ .wp_themeSkin .mceMenu span,
654
+ .wp_themeSkin .mceMenu {
655
+ display: block;
656
+ }
657
+
658
+ .wp_themeSkin .mceMenu td {
659
+ height: 20px;overflow: hidden;
660
+ }
661
+
662
+ .wp_themeSkin .mceMenu a {
663
+ position: relative;
664
+ padding: 3px 0 4px 0;
665
+ text-decoration: none !important;
666
+ }
667
+
668
+ .wp_themeSkin .mceMenu .mceText {
669
+ position: relative;
670
+ display: block;
671
+ font-family: "Open Sans", sans-serif;
672
+ cursor: default;
673
+ margin: 0;
674
+ padding: 0 25px;
675
+ color: #000;
676
+ }
677
+
678
+ .wp_themeSkin .mceMenu span.mceText, .wp_themeSkin .mceMenu .mcePreview {
679
+ font-size: 12px;
680
+ }
681
+
682
+ .wp_themeSkin .mceMenu pre.mceText {
683
+ font-family: Monospace;
684
+ }
685
+
686
+ .wp_themeSkin .mceMenu .mceIcon {
687
+ position: absolute;
688
+ top: 0;
689
+ left: 0;
690
+ width: 22px;
691
+ }
692
+
693
+ .wp_themeSkin .mceMenu .mceMenuItemEnabled a:hover,
694
+ .wp_themeSkin .mceMenu .mceMenuItemActive {
695
+ background-color: #f5f5f5;
696
+ }
697
+
698
+ .wp_themeSkin td.mceMenuItemSeparator {
699
+ height: 1px;
700
+ background-color: #aaa;
701
+ }
702
+
703
+ .wp_themeSkin .mceMenuItemTitle a {
704
+ border-top: 0;
705
+ border-right: 0;
706
+ border-left: 0;
707
+ border-bottom: 1px solid #aaa;
708
+ text-decoration: none !important;
709
+ background-color: #ccc;
710
+ }
711
+
712
+ .wp_themeSkin .mceMenuItemTitle span.mceText {
713
+ font-weight: bold;
714
+ padding-left: 4px;
715
+ color: #000;
716
+ }
717
+
718
+ .wp_themeSkin .mceMenuItemSelected .mceIcon {
719
+ background: url("/wp-includes/js/tinymce/skins/wordpress/images/menu_check.gif");
720
+ color: #888;
721
+ }
722
+
723
+ .wp_themeSkin .mceNoIcons .mceMenuItemSelected a {
724
+ background: url("/wp-includes/js/tinymce/skins/wordpress/images/menu_arrow.gif") no-repeat -6px center;
725
+ }
726
+
727
+ .wp_themeSkin .mceMenu span.mceMenuLine {
728
+ display: none;
729
+ }
730
+
731
+ .wp_themeSkin .mceMenuItemSub a {
732
+ background: url("/wp-includes/js/tinymce/skins/wordpress/images/menu_arrow.gif") no-repeat top right;
733
+ }
734
+
735
+ /* Progress,Resize */
736
+ .wp_themeSkin .mceBlocker {
737
+ position: absolute;
738
+ left: 0;
739
+ top: 0;
740
+ z-index: 1000;
741
+ opacity: 0.5;
742
+ filter: alpha(opacity=50);
743
+ background: #FFF;
744
+ }
745
+
746
+ .wp_themeSkin .mceProgress {
747
+ position: absolute;
748
+ left: 0;
749
+ top: 0;
750
+ z-index: 1001;
751
+ background: url("/wp-includes/images/spinner.gif") no-repeat;
752
+ width: 32px;
753
+ height: 32px;
754
+ margin: -16px 0 0 -16px;
755
+ }
756
+
757
+ .wp_themeSkin .mcePlaceHolder {
758
+ border: 1px dotted gray;
759
+ }
760
+
761
+ /* Rtl */
762
+ .mceRtl .mceListBox .mceText {
763
+ text-align: right;
764
+ padding: 0 4px 0 0;
765
+ }
766
+
767
+ .mceRtl .mceMenuItem .mceText {
768
+ text-align: right;
769
+ }
770
+
771
+ /* Formats */
772
+ .wp_themeSkin .mce_p span.mceText {}
773
+ .wp_themeSkin .mce_address span.mceText {
774
+ font-style: italic;
775
+ }
776
+
777
+ .wp_themeSkin .mce_pre span.mceText {
778
+ font-family: monospace;
779
+ }
780
+
781
+ .wp_themeSkin .mce_h1 span.mceText {
782
+ font-weight: bolder;
783
+ font-size: 18px;
784
+ }
785
+
786
+ .wp_themeSkin .mce_h2 span.mceText {
787
+ font-weight: bolder;
788
+ font-size: 14px;
789
+ }
790
+
791
+ .wp_themeSkin .mce_h3 span.mceText {
792
+ font-weight: bolder;
793
+ font-size: 12px;
794
+ }
795
+
796
+ .wp_themeSkin .mce_h4 span.mceText {
797
+ font-weight: bolder;
798
+ font-size: 11px;
799
+ }
800
+
801
+ .wp_themeSkin .mce_h5 span.mceText {
802
+ font-weight: bolder;
803
+ font-size: 11px;
804
+ }
805
+
806
+ .wp_themeSkin .mce_h6 span.mceText {
807
+ font-weight: bolder;
808
+ font-size: 10px;
809
+ }
810
+
811
+ span.mce_bold:before {
812
+ content: '\f200';
813
+ }
814
+
815
+ span.mce_italic:before {
816
+ content: '\f201';
817
+ }
818
+
819
+ span.mce_bullist:before {
820
+ content: '\f203';
821
+ }
822
+
823
+ span.mce_numlist:before {
824
+ content: '\f204';
825
+ }
826
+
827
+ span.mce_blockquote:before {
828
+ content: '\f205';
829
+ }
830
+
831
+ span.mce_justifyleft:before {
832
+ content: '\f206';
833
+ }
834
+
835
+ span.mce_justifycenter:before {
836
+ content: '\f207';
837
+ }
838
+
839
+ span.mce_justifyright:before {
840
+ content: '\f208';
841
+ }
842
+
843
+ span.mce_link:before {
844
+ content: '\f103';
845
+ }
846
+
847
+ span.mce_unlink:before {
848
+ content: '\f225';
849
+ }
850
+
851
+ span.mce_wp_more:before {
852
+ content: '\f209';
853
+ }
854
+
855
+ span.mce_strikethrough:before {
856
+ content: '\f224';
857
+ }
858
+
859
+ span.mce_spellchecker {
860
+ font-size: 20px;
861
+ background: none !important;
862
+ margin-top: 2px;
863
+ }
864
+
865
+ span.mce_spellchecker:before {
866
+ content: '\f210';
867
+ }
868
+
869
+ span.mce_fullscreen:before,
870
+ span.mce_wp_fullscreen:before {
871
+ content: '\f211';
872
+ }
873
+
874
+ span.mce_wp_adv:before {
875
+ content: '\f212';
876
+ }
877
+ span.mce_underline:before {
878
+ content: '\f213';
879
+ }
880
+
881
+ span.mce_justifyfull:before {
882
+ content: '\f214';
883
+ }
884
+
885
+ span.mce_forecolor {
886
+ background: none !important;
887
+ }
888
+
889
+ span.mce_forecolor:before {
890
+ content: '\f215';
891
+ }
892
+
893
+ span.mce_pastetext:before {
894
+ content: '\f217';
895
+ }
896
+
897
+ span.mce_pasteword:before {
898
+ content: '\f216';
899
+ }
900
+
901
+ span.mce_removeformat:before {
902
+ content: '\f218';
903
+ }
904
+
905
+ span.mce_charmap:before {
906
+ content: '\f220';
907
+ }
908
+
909
+ span.mce_outdent:before {
910
+ content: '\f221';
911
+ }
912
+
913
+ span.mce_indent:before {
914
+ content: '\f222';
915
+ }
916
+
917
+ span.mce_undo:before {
918
+ content: '\f171';
919
+ }
920
+
921
+ span.mce_redo:before {
922
+ content: '\f172';
923
+ }
924
+
925
+ span.mce_help:before,
926
+ span.mce_wp_help:before {
927
+ content: '\f223';
928
+ }
929
+
930
+ span.mce_image:before {
931
+ content: '\f104';
932
+ }
933
+
934
+ span.mce_ltr:before {
935
+ content: '\f320';
936
+ }
937
+
938
+ /* Default icons */
939
+ .wp_themeSkin span.mce_cleanup {background-position:-380px -20px}
940
+ .wp_themeSkin span.mce_anchor {background-position:-200px 0}
941
+ .wp_themeSkin span.mce_sub {background-position:-600px 0}
942
+ .wp_themeSkin span.mce_sup {background-position:-620px 0}
943
+ .wp_themeSkin span.mce_newdocument {background-position:-520px 0}
944
+ .wp_themeSkin span.mce_image {background-position:-380px 0}
945
+ .wp_themeSkin span.mce_code {background-position:-260px 0}
946
+ .wp_themeSkin span.mce_hr {background-position:-360px 0}
947
+ .wp_themeSkin span.mce_visualaid {background-position:-660px 0}
948
+ .wp_themeSkin span.mce_paste {background-position:-560px 0}
949
+ .wp_themeSkin span.mce_copy {background-position:-700px 0}
950
+ .wp_themeSkin span.mce_cut {background-position:-680px 0}
951
+ .wp_themeSkin .mce_backcolor span.mceAction {background-position:-760px 0}
952
+ .wp_themeSkin .mce_backcolorpicker {background-position:-760px 0}
953
+
954
+ /* Plugins */
955
+ .wp_themeSkin span.mce_advhr {background-position:-0px -20px}
956
+ .wp_themeSkin span.mce_ltr {background-position:-20px -20px}
957
+ .wp_themeSkin span.mce_rtl {background-position:-40px -20px}
958
+ .wp_themeSkin span.mce_emotions {background-position:-60px -20px}
959
+ .wp_themeSkin span.mce_fullpage {background-position:-80px -20px}
960
+ .wp_themeSkin span.mce_iespell {background-position:-120px -20px}
961
+ .wp_themeSkin span.mce_insertdate {background-position:-140px -20px}
962
+ .wp_themeSkin span.mce_inserttime {background-position:-160px -20px}
963
+ .wp_themeSkin span.mce_absolute {background-position:-180px -20px}
964
+ .wp_themeSkin span.mce_backward {background-position:-200px -20px}
965
+ .wp_themeSkin span.mce_forward {background-position:-220px -20px}
966
+ .wp_themeSkin span.mce_insert_layer {background-position:-240px -20px}
967
+ .wp_themeSkin span.mce_insertlayer {background-position:-260px -20px}
968
+ .wp_themeSkin span.mce_movebackward {background-position:-280px -20px}
969
+ .wp_themeSkin span.mce_moveforward {background-position:-300px -20px}
970
+ .wp_themeSkin span.mce_media {background-position:-320px -20px}
971
+ .wp_themeSkin span.mce_nonbreaking {background-position:-340px -20px}
972
+ .wp_themeSkin span.mce_selectall {background-position:-400px -20px}
973
+ .wp_themeSkin span.mce_preview {background-position:-420px -20px}
974
+ .wp_themeSkin span.mce_print {background-position:-440px -20px}
975
+ .wp_themeSkin span.mce_cancel {background-position:-460px -20px}
976
+ .wp_themeSkin span.mce_save {background-position:-480px -20px}
977
+ .wp_themeSkin span.mce_replace {background-position:-500px -20px}
978
+ .wp_themeSkin span.mce_search {background-position:-520px -20px}
979
+ .wp_themeSkin span.mce_styleprops {background-position:-560px -20px}
980
+ .wp_themeSkin span.mce_table {background-position:-580px -20px}
981
+ .wp_themeSkin span.mce_cell_props {background-position:-600px -20px}
982
+ .wp_themeSkin span.mce_delete_table {background-position:-620px -20px}
983
+ .wp_themeSkin span.mce_delete_col {background-position:-640px -20px}
984
+ .wp_themeSkin span.mce_delete_row {background-position:-660px -20px}
985
+ .wp_themeSkin span.mce_col_after {background-position:-680px -20px}
986
+ .wp_themeSkin span.mce_col_before {background-position:-700px -20px}
987
+ .wp_themeSkin span.mce_row_after {background-position:-720px -20px}
988
+ .wp_themeSkin span.mce_row_before {background-position:-740px -20px}
989
+ .wp_themeSkin span.mce_merge_cells {background-position:-760px -20px}
990
+ .wp_themeSkin span.mce_table_props {background-position:-980px -20px}
991
+ .wp_themeSkin span.mce_row_props {background-position:-780px -20px}
992
+ .wp_themeSkin span.mce_split_cells {background-position:-800px -20px}
993
+ .wp_themeSkin span.mce_template {background-position:-820px -20px}
994
+ .wp_themeSkin span.mce_visualchars {background-position:-840px -20px}
995
+ .wp_themeSkin span.mce_abbr {background-position:-860px -20px}
996
+ .wp_themeSkin span.mce_acronym {background-position:-880px -20px}
997
+ .wp_themeSkin span.mce_attribs {background-position:-900px -20px}
998
+ .wp_themeSkin span.mce_cite {background-position:-920px -20px}
999
+ .wp_themeSkin span.mce_del {background-position:-940px -20px}
1000
+ .wp_themeSkin span.mce_ins {background-position:-960px -20px}
1001
+ .wp_themeSkin span.mce_pagebreak {background-position:0 -40px}
1002
+ .wp_themeSkin span.mce_restoredraft {background-position:-20px -40px}
1003
+ .wp_themeSkin span.mce_visualblocks {background-position: -40px -40px}
1004
+
1005
+ /* border */
1006
+ .wp_themeSkin .mceExternalToolbar,
1007
+ .wp_themeSkin .mceButton,
1008
+ .wp_themeSkin a.mceButtonEnabled:hover,
1009
+ .wp_themeSkin a.mceButtonActive,
1010
+ .wp_themeSkin a.mceButtonSelected,
1011
+ .wp_themeSkin .mceListBox .mceText,
1012
+ .wp_themeSkin .mceListBox .mceOpen,
1013
+ .wp_themeSkin select.mceListBox,
1014
+ .wp_themeSkin .mceSplitButton a.mceAction,
1015
+ .wp_themeSkin .mceSplitButton a.mceOpen,
1016
+ .wp_themeSkin .mceSplitButton a.mceOpen:hover,
1017
+ .wp_themeSkin .mceSplitButtonSelected a.mceOpen,
1018
+ .wp_themeSkin table.mceSplitButtonEnabled:hover a.mceAction,
1019
+ .wp_themeSkin .mceSplitButton a.mceAction:hover,
1020
+ .wp_themeSkin div.mceColorSplitMenu table,
1021
+ .wp_themeSkin .mceColorSplitMenu a,
1022
+ .wp_themeSkin .mceColorSplitMenu a.mceMoreColors,
1023
+ .wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover,
1024
+ .wp_themeSkin a.mceMoreColors:hover,
1025
+ .wp_themeSkin .mceMenu {
1026
+ border-style: solid;
1027
+ border-width: 1px;
1028
+ }
1029
+
1030
+ .wp_themeSkin .mceListBox .mceText {
1031
+ border-right: 0 none;
1032
+ }
1033
+
1034
+ .wp_themeSkin iframe {
1035
+ background: transparent;
1036
+ }
1037
+
1038
+ .wp_themeSkin .mceButton {
1039
+ border-color: transparent;
1040
+ }
1041
+
1042
+ .wp_themeSkin .mceListBox .mceText,
1043
+ .wp_themeSkin .mceListBox .mceOpen {
1044
+ border-color: transparent;
1045
+ }
1046
+
1047
+ .wp_themeSkin a.mceButtonEnabled:hover,
1048
+ .wp_themeSkin table.mceSplitButton:hover {
1049
+ border-color: #bbb;
1050
+ background: #eee;
1051
+ background-image: -webkit-gradient(linear, left bottom, left top, from(#e5e5e5), to(#fff));
1052
+ background-image: -webkit-linear-gradient(bottom, #e5e5e5, #fff);
1053
+ background-image: -moz-linear-gradient(bottom, #e5e5e5, #fff);
1054
+ background-image: -o-linear-gradient(bottom, #e5e5e5, #fff);
1055
+ background-image: linear-gradient(to top, #e5e5e5, #fff);
1056
+ }
1057
+
1058
+ .wp_themeSkin a.mceButton:active,
1059
+ .wp_themeSkin a.mceButtonEnabled:active,
1060
+ .wp_themeSkin a.mceButtonSelected:active,
1061
+ .wp_themeSkin a.mceButtonActive,
1062
+ .wp_themeSkin a.mceButtonActive:active,
1063
+ .wp_themeSkin a.mceButtonActive:hover,
1064
+ .wp_themeSkin .mceSplitButtonSelected table,
1065
+ .wp_themeSkin .mceSplitButtonSelected table:hover {
1066
+ outline: none;
1067
+ border-color: #999 #ccc #ccc #999;
1068
+ background: #eee;
1069
+ background-image: -webkit-gradient(linear, left bottom, left top, from(#f6f6f6), to(#e3e3e3));
1070
+ background-image: -webkit-linear-gradient(bottom, #f6f6f6, #e3e3e3);
1071
+ background-image: -moz-linear-gradient(bottom, #f6f6f6, #e3e3e3);
1072
+ background-image: -o-linear-gradient(bottom, #f6f6f6, #e3e3e3);
1073
+ background-image: linear-gradient(to top, #f6f6f6, #e3e3e3);
1074
+ }
1075
+
1076
+ .wp_themeSkin .mceSplitButtonSelected table a.mceOpen,
1077
+ .wp_themeSkin .mceSplitButtonSelected table a.mceAction {
1078
+ border-color: #999 #ccc #ccc #999;
1079
+ }
1080
+
1081
+ .wp_themeSkin .mceButtonDisabled {
1082
+ border-color: transparent;
1083
+ }
1084
+
1085
+ .wp_themeSkin .mceListBox .mceOpen {
1086
+ border-left: 0;
1087
+ }
1088
+
1089
+ .wp_themeSkin .mceListBoxEnabled:hover,
1090
+ .wp_themeSkin .mceListBoxEnabled:active,
1091
+ .wp_themeSkin .mceListBoxHover,
1092
+ .wp_themeSkin .mceListBoxHover:active,
1093
+ .wp_themeSkin .mceListBoxSelected {
1094
+ -webkit-box-shadow: inset 0 1px 1px -1px rgba(0, 0, 0, .3);
1095
+ box-shadow: inset 0 1px 1px -1px rgba(0, 0, 0, .3);
1096
+ border-color: #bbb;
1097
+ }
1098
+
1099
+ /* SplitButton */
1100
+ .wp_themeSkin .mceSplitButton .mceLast span.mceOpen .mceIconOnly {
1101
+ display: block;
1102
+ }
1103
+
1104
+ .wp_themeSkin .mceSplitButton a.mceAction,
1105
+ .wp_themeSkin .mceSplitButton a.mceOpen {
1106
+ border-color: transparent;
1107
+ }
1108
+
1109
+ .wp_themeSkin .mceSplitButton:hover a {
1110
+ border-color: #bbb;
1111
+ }
1112
+
1113
+ .wp_themeSkin .mceSplitButtonEnabled a.mceOpen,
1114
+ .wp_themeSkin .mceSplitButtonSelected a.mceOpen,
1115
+ .wp_themeSkin .mceSplitButtonActive a.mceOpen,
1116
+ .wp_themeSkin .mceSplitButtonEnabled:hover a.mceOpen {
1117
+ background-image: url("../../../../../wp-includes/images/down_arrow.gif");
1118
+ background-position: 1px 2px;
1119
+ background-repeat: no-repeat;
1120
+ border-left: 0;
1121
+ }
1122
+
1123
+ .wp_themeSkin .mceSplitButtonActive td {
1124
+ -webkit-border-radius: 3px;
1125
+ border-radius: 3px;
1126
+ }
1127
+
1128
+ .wp_themeSkin .mceColorSplitMenu a.mceMoreColors:hover {
1129
+ border-color: #0A246A;
1130
+ background-color: #B6BDD2;
1131
+ }
1132
+
1133
+ .wp_themeSkin a.mceMoreColors:hover {
1134
+ border-color: #0A246A;
1135
+ }
1136
+
1137
+ .wp_themeSkin .mceMenuItemDisabled .mceText {
1138
+ color: #888;
1139
+ }
1140
+
1141
+ #mceModalBlocker {
1142
+ background: #000;
1143
+ opacity: 0.7;
1144
+ -ms-filter: "progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";
1145
+ filter: alpha(opacity=70);
1146
+ }
1147
+
1148
+ /* WP specific */
1149
+ .wp-editor-wrap {
1150
+ position: relative;
1151
+ }
1152
+
1153
+ .wp-editor-tools {
1154
+ position: relative;
1155
+ z-index: 1;
1156
+ }
1157
+
1158
+ .wp-editor-container {
1159
+ clear: both;
1160
+ }
1161
+
1162
+ .wp-editor-area {
1163
+ font-family: Consolas, Monaco, monospace;
1164
+ font-size: 13px;
1165
+ padding: 10px;
1166
+ margin: 1px 0 0;
1167
+ line-height: 150%;
1168
+ border: 0 none;
1169
+ outline: none;
1170
+ display: block;
1171
+ resize: vertical;
1172
+ -moz-box-sizing: border-box;
1173
+ -webkit-box-sizing: border-box;
1174
+ box-sizing: border-box;
1175
+ }
1176
+
1177
+ .wp-editor-tools {
1178
+ padding: 0;
1179
+ }
1180
+
1181
+ .wp-editor-container textarea.wp-editor-area {
1182
+ width: 100%;
1183
+ margin: 0;
1184
+ -webkit-box-shadow: none;
1185
+ box-shadow: none;
1186
+ }
1187
+
1188
+ .quicktags-toolbar,
1189
+ .wp_themeSkin tr.mceFirst td.mceToolbar {
1190
+ border-bottom: 1px solid #dedede;
1191
+ background: #f5f5f5;
1192
+ }
1193
+
1194
+ .wp-editor-tabs {
1195
+ float: right;
1196
+ }
1197
+
1198
+ .wp-switch-editor {
1199
+ background: #ebebeb;
1200
+ border: 1px solid #dedede;
1201
+ color: #777;
1202
+ cursor: pointer;
1203
+ float: right;
1204
+ font: 13px/19px "Open Sans", sans-serif;
1205
+ height: 19px;
1206
+ margin: 5px 0 0 5px;
1207
+ padding: 3px 8px 4px;
1208
+ position: relative;
1209
+ top: 1px;
1210
+ }
1211
+
1212
+ .wp-switch-editor:active {
1213
+ background-color: #f1f1f1;
1214
+ }
1215
+
1216
+ .wp-switch-editor:hover {
1217
+ text-decoration: none !important;
1218
+ background: #fff;
1219
+ }
1220
+
1221
+ .js .tmce-active .wp-editor-area {
1222
+ color: white;
1223
+ }
1224
+
1225
+ .tmce-active .quicktags-toolbar {
1226
+ display: none;
1227
+ }
1228
+
1229
+ .tmce-active .switch-tmce,
1230
+ .html-active .switch-html {
1231
+ background: #f5f5f5;
1232
+ color: #555;
1233
+ height: 20px;
1234
+ border-bottom: none;
1235
+ }
1236
+
1237
+ .wp-media-buttons {
1238
+ float: left;
1239
+ }
1240
+
1241
+ .wp-media-buttons .button {
1242
+ margin-right: 5px;
1243
+ margin-bottom: 4px;
1244
+ padding-left: 7px;
1245
+ padding-right: 7px;
1246
+ }
1247
+
1248
+ .wp-media-buttons .button:active {
1249
+ position: relative;
1250
+ top: 1px;
1251
+ margin-top: -1px;
1252
+ margin-bottom: 1px;
1253
+ }
1254
+
1255
+ .wp-media-buttons .insert-media {
1256
+ padding-left: 5px;
1257
+ }
1258
+
1259
+ .wp-media-buttons a {
1260
+ text-decoration: none;
1261
+ color: #464646;
1262
+ font-size: 12px;
1263
+ }
1264
+
1265
+ .wp-media-buttons img {
1266
+ padding: 0 4px;
1267
+ vertical-align: middle;
1268
+ }
1269
+
1270
+ .wp-media-buttons span.wp-media-buttons-icon {
1271
+ display: inline-block;
1272
+ width: 18px;
1273
+ height: 18px;
1274
+ vertical-align: text-top;
1275
+ margin: 0 2px;
1276
+ }
1277
+
1278
+ .wp-media-buttons .add_media span.wp-media-buttons-icon {
1279
+ background: none;
1280
+ }
1281
+
1282
+ .wp-media-buttons .add_media span.wp-media-buttons-icon:before {
1283
+ font: normal 18px/1 'dashicons';
1284
+ speak: none;
1285
+ -webkit-font-smoothing: antialiased;
1286
+ -moz-osx-font-smoothing: grayscale;
1287
+ }
1288
+
1289
+ .wp-media-buttons .add_media span.wp-media-buttons-icon:before {
1290
+ content: '\f104';
1291
+ }
1292
+
1293
+ .quicktags-toolbar {
1294
+ border-bottom-style: solid;
1295
+ border-bottom-width: 1px;
1296
+ -webkit-border-top-right-radius: 3px;
1297
+ -webkit-border-top-left-radius: 3px;
1298
+ border-top-right-radius: 3px;
1299
+ border-top-left-radius: 3px;
1300
+ padding: 2px 8px 0;
1301
+ min-height: 29px;
1302
+ }
1303
+
1304
+ .quicktags-toolbar > div {
1305
+ padding: 2px 4px 0;
1306
+ }
1307
+
1308
+ .quicktags-toolbar input {
1309
+ margin: 2px 1px 4px;
1310
+ line-height: 18px;
1311
+ display: inline-block;
1312
+ min-width: 26px;
1313
+ padding: 2px 4px;
1314
+ font: 12px/18px "Open Sans", sans-serif;
1315
+ color: #464646;
1316
+ border: 1px solid #c3c3c3;
1317
+ -webkit-border-radius: 3px;
1318
+ border-radius: 3px;
1319
+ background: #eee;
1320
+ background-image: -webkit-gradient(linear, left bottom, left top, from(#e3e3e3), to(#fff));
1321
+ background-image: -webkit-linear-gradient(bottom, #e3e3e3, #fff);
1322
+ background-image: -moz-linear-gradient(bottom, #e3e3e3, #fff);
1323
+ background-image: -o-linear-gradient(bottom, #e3e3e3, #fff);
1324
+ background-image: linear-gradient(to top, #e3e3e3, #fff);
1325
+ }
1326
+
1327
+ .quicktags-toolbar input:hover {
1328
+ border-color: #aaa;
1329
+ background: #ddd;
1330
+ }
1331
+
1332
+ .quicktags-toolbar input[value="link"] {
1333
+ text-decoration: underline;
1334
+ }
1335
+
1336
+ .quicktags-toolbar input[value="del"] {
1337
+ text-decoration: line-through;
1338
+ }
1339
+
1340
+ .quicktags-toolbar input[value="i"] {
1341
+ font-style: italic;
1342
+ }
1343
+
1344
+ .quicktags-toolbar input[value="b"] {
1345
+ font-weight: bold;
1346
+ }
1347
+
1348
+ #wp_editbtns,
1349
+ #wp_gallerybtns {
1350
+ padding: 2px;
1351
+ position: absolute;
1352
+ display: none;
1353
+ z-index: 155000;
1354
+ }
1355
+
1356
+ #wp_editimgbtn,
1357
+ #wp_delimgbtn,
1358
+ #wp_editgallery,
1359
+ #wp_delgallery {
1360
+ border-color: #999;
1361
+ background-color: #eee;
1362
+ margin: 2px;
1363
+ padding: 2px;
1364
+ border-width: 1px;
1365
+ border-style: solid;
1366
+ -webkit-border-radius: 3px;
1367
+ border-radius: 3px;
1368
+ }
1369
+
1370
+ #wp_editimgbtn:hover,
1371
+ #wp_delimgbtn:hover,
1372
+ #wp_editgallery:hover,
1373
+ #wp_delgallery:hover {
1374
+ border-color: #555;
1375
+ background-color: #ccc;
1376
+ }
1377
+
1378
+ /*------------------------------------------------------------------------------
1379
+ wp-link
1380
+ ------------------------------------------------------------------------------*/
1381
+
1382
+ #wp-link {
1383
+ background-color: #F5F5F5;
1384
+ line-height: 1.4em;
1385
+ font-size: 12px;
1386
+ }
1387
+
1388
+ #wp-link ol,
1389
+ #wp-link ul {
1390
+ list-style: none;
1391
+ margin: 0;
1392
+ padding: 0;
1393
+ }
1394
+
1395
+ #wp-link input[type="text"] {
1396
+ -webkit-box-sizing: border-box;
1397
+ }
1398
+
1399
+ #wp-link input[type="text"],
1400
+ #wp-link textarea {
1401
+ border-width: 1px;
1402
+ border-style: solid;
1403
+ -webkit-border-radius: 4px;
1404
+ border-radius: 4px;
1405
+ font-size: 12px;
1406
+ margin: 1px;
1407
+ padding: 3px;
1408
+ }
1409
+
1410
+ #wp-link #link-options {
1411
+ padding: 10px 0 14px;
1412
+ border-bottom: 1px solid #dfdfdf;
1413
+ margin: 0 6px 14px;
1414
+ }
1415
+
1416
+ #wp-link p.howto {
1417
+ margin: 3px;
1418
+ }
1419
+
1420
+ #wp-link #internal-toggle {
1421
+ display: inline-block;
1422
+ cursor: pointer;
1423
+ padding-left: 18px;
1424
+ }
1425
+
1426
+ #wp-link .toggle-arrow {
1427
+ background: transparent url("../../../../../wp-includes/images/toggle-arrow.png") top left no-repeat;
1428
+ height: 23px;
1429
+ line-height: 23px;
1430
+ }
1431
+
1432
+ #wp-link .toggle-arrow-active {
1433
+ background-position: center left;
1434
+ }
1435
+
1436
+ #wp-link label input[type="text"] {
1437
+ width: 360px;
1438
+ margin-top: 5px;
1439
+ }
1440
+
1441
+ #wp-link #link-options label span,
1442
+ #wp-link #search-panel label span.search-label {
1443
+ display: inline-block;
1444
+ width: 80px;
1445
+ text-align: right;
1446
+ padding-right: 5px;
1447
+ }
1448
+
1449
+ #wp-link .link-search-field {
1450
+ float: left;
1451
+ width: 220px;
1452
+ }
1453
+
1454
+ #wp-link .link-search-wrapper {
1455
+ margin: 5px 6px 9px;
1456
+ display: block;
1457
+ overflow: hidden;
1458
+ }
1459
+
1460
+ #wp-link .link-search-wrapper span {
1461
+ float: left;
1462
+ margin-top: 4px;
1463
+ }
1464
+
1465
+ #wp-link .link-search-wrapper .spinner {
1466
+ display: none;
1467
+ vertical-align: text-bottom;
1468
+ }
1469
+
1470
+ #wp-link .link-target {
1471
+ width: auto;
1472
+ padding: 3px 0 0;
1473
+ margin: 0 0 0 87px;
1474
+ font-size: 11px;
1475
+ }
1476
+
1477
+ #wp-link .query-results {
1478
+ border: 1px #dfdfdf solid;
1479
+ margin: 0 5px 5px;
1480
+ background: #fff;
1481
+ height: 185px;
1482
+ overflow: auto;
1483
+ position: relative;
1484
+ }
1485
+
1486
+ #wp-link li,
1487
+ #wp-link .query-notice {
1488
+ clear: both;
1489
+ margin-bottom: 0;
1490
+ border-bottom: 1px solid #f1f1f1;
1491
+ color: #333;
1492
+ padding: 4px 6px;
1493
+ cursor: pointer;
1494
+ position: relative;
1495
+ }
1496
+
1497
+ #wp-link li:hover {
1498
+ background: #eaf2fa;
1499
+ color: #151515;
1500
+ }
1501
+
1502
+ #wp-link li.unselectable {
1503
+ border-bottom: 1px solid #dfdfdf;
1504
+ }
1505
+
1506
+ #wp-link li.unselectable:hover {
1507
+ background: #fff;
1508
+ cursor: auto;
1509
+ color: #333;
1510
+ }
1511
+
1512
+ #wp-link li.selected {
1513
+ background: #ddd;
1514
+ color: #333;
1515
+ }
1516
+
1517
+ #wp-link li.selected .item-title {
1518
+ font-weight: bold;
1519
+ }
1520
+
1521
+ #wp-link .item-title {
1522
+ display: inline-block;
1523
+ width: 80%;
1524
+ }
1525
+
1526
+ #wp-link .item-info {
1527
+ text-transform: uppercase;
1528
+ color: #666;
1529
+ font-size: 11px;
1530
+ position: absolute;
1531
+ right: 5px;
1532
+ top: 4px;
1533
+ bottom: 0;
1534
+ }
1535
+
1536
+ #wp-link #search-results {
1537
+ display: none;
1538
+ }
1539
+
1540
+ #wp-link #search-panel {
1541
+ float: left;
1542
+ width: 100%;
1543
+ }
1544
+
1545
+ #wp-link .river-waiting {
1546
+ display: none;
1547
+ padding: 10px 0;
1548
+ }
1549
+
1550
+ #wp-link .river-waiting .spinner {
1551
+ margin: 0 auto;
1552
+ display: block;
1553
+ }
1554
+
1555
+ #wp-link .submitbox {
1556
+ padding: 5px 10px;
1557
+ font-size: 11px;
1558
+ overflow: auto;
1559
+ height: 29px;
1560
+ }
1561
+
1562
+ #wp-link-cancel {
1563
+ line-height: 25px;
1564
+ float: left;
1565
+ }
1566
+
1567
+ #wp-link-update {
1568
+ line-height: 23px;
1569
+ float: right;
1570
+ }
1571
+
1572
+ /*!
1573
+ * jQuery UI CSS Framework 1.10.1
1574
+ * http://jqueryui.com
1575
+ *
1576
+ * Copyright 2013 jQuery Foundation and other contributors
1577
+ * Released under the MIT license.
1578
+ * http://jquery.org/license
1579
+ *
1580
+ * http://docs.jquery.com/UI/Theming/API
1581
+ */
1582
+
1583
+ /* Layout helpers
1584
+ ----------------------------------*/
1585
+ .ui-helper-hidden {
1586
+ display: none;
1587
+ }
1588
+ .ui-helper-hidden-accessible {
1589
+ border: 0;
1590
+ clip: rect(0 0 0 0);
1591
+ height: 1px;
1592
+ margin: -1px;
1593
+ overflow: hidden;
1594
+ padding: 0;
1595
+ position: absolute;
1596
+ width: 1px;
1597
+ }
1598
+ .ui-helper-reset {
1599
+ margin: 0;
1600
+ padding: 0;
1601
+ border: 0;
1602
+ outline: 0;
1603
+ line-height: 1.3;
1604
+ text-decoration: none;
1605
+ font-size: 100%;
1606
+ list-style: none;
1607
+ }
1608
+ .ui-helper-clearfix:before,
1609
+ .ui-helper-clearfix:after {
1610
+ content: "";
1611
+ display: table;
1612
+ border-collapse: collapse;
1613
+ }
1614
+ .ui-helper-clearfix:after {
1615
+ clear: both;
1616
+ }
1617
+ .ui-helper-clearfix {
1618
+ min-height: 0; /* support: IE7 */
1619
+ }
1620
+ .ui-helper-zfix {
1621
+ width: 100%;
1622
+ height: 100%;
1623
+ top: 0;
1624
+ left: 0;
1625
+ position: absolute;
1626
+ opacity: 0;
1627
+ filter:Alpha(Opacity=0);
1628
+ }
1629
+
1630
+ .ui-front {
1631
+ z-index: 100;
1632
+ }
1633
+
1634
+
1635
+ /* Interaction Cues
1636
+ ----------------------------------*/
1637
+ .ui-state-disabled {
1638
+ cursor: default !important;
1639
+ }
1640
+
1641
+
1642
+ /* Icons
1643
+ ----------------------------------*/
1644
+
1645
+ /* states and images */
1646
+ .ui-icon {
1647
+ display: block;
1648
+ text-indent: -99999px;
1649
+ overflow: hidden;
1650
+ background-repeat: no-repeat;
1651
+ }
1652
+
1653
+
1654
+ /* Misc visuals
1655
+ ----------------------------------*/
1656
+
1657
+ /* Overlays */
1658
+ .ui-widget-overlay {
1659
+ position: fixed;
1660
+ top: 0;
1661
+ left: 0;
1662
+ width: 100%;
1663
+ height: 100%;
1664
+ }
1665
+
1666
+
1667
+ /*!
1668
+ * jQuery UI Resizable 1.10.1
1669
+ * http://jqueryui.com
1670
+ *
1671
+ * Copyright 2013 jQuery Foundation and other contributors
1672
+ * Released under the MIT license.
1673
+ * http://jquery.org/license
1674
+ *
1675
+ * http://docs.jquery.com/UI/Resizable#theming
1676
+ */
1677
+ .ui-resizable {
1678
+ position: relative;
1679
+ }
1680
+ .ui-resizable-handle {
1681
+ position: absolute;
1682
+ font-size: 0.1px;
1683
+ display: block;
1684
+ }
1685
+ .ui-resizable-disabled .ui-resizable-handle,
1686
+ .ui-resizable-autohide .ui-resizable-handle {
1687
+ display: none;
1688
+ }
1689
+ .ui-resizable-n {
1690
+ cursor: n-resize;
1691
+ height: 7px;
1692
+ width: 100%;
1693
+ top: -5px;
1694
+ left: 0;
1695
+ }
1696
+ .ui-resizable-s {
1697
+ cursor: s-resize;
1698
+ height: 7px;
1699
+ width: 100%;
1700
+ bottom: -5px;
1701
+ left: 0;
1702
+ }
1703
+ .ui-resizable-e {
1704
+ cursor: e-resize;
1705
+ width: 7px;
1706
+ right: -5px;
1707
+ top: 0;
1708
+ height: 100%;
1709
+ }
1710
+ .ui-resizable-w {
1711
+ cursor: w-resize;
1712
+ width: 7px;
1713
+ left: -5px;
1714
+ top: 0;
1715
+ height: 100%;
1716
+ }
1717
+ .ui-resizable-se {
1718
+ cursor: se-resize;
1719
+ width: 12px;
1720
+ height: 12px;
1721
+ right: 1px;
1722
+ bottom: 1px;
1723
+ }
1724
+ .ui-resizable-sw {
1725
+ cursor: sw-resize;
1726
+ width: 9px;
1727
+ height: 9px;
1728
+ left: -5px;
1729
+ bottom: -5px;
1730
+ }
1731
+ .ui-resizable-nw {
1732
+ cursor: nw-resize;
1733
+ width: 9px;
1734
+ height: 9px;
1735
+ left: -5px;
1736
+ top: -5px;
1737
+ }
1738
+ .ui-resizable-ne {
1739
+ cursor: ne-resize;
1740
+ width: 9px;
1741
+ height: 9px;
1742
+ right: -5px;
1743
+ top: -5px;
1744
+ }
1745
+
1746
+ /*!
1747
+ * jQuery UI Dialog 1.10.1
1748
+ * http://jqueryui.com
1749
+ *
1750
+ * Copyright 2013 jQuery Foundation and other contributors
1751
+ * Released under the MIT license.
1752
+ * http://jquery.org/license
1753
+ *
1754
+ * http://docs.jquery.com/UI/Dialog#theming
1755
+ */
1756
+ .ui-dialog {
1757
+ position: absolute;
1758
+ top: 0;
1759
+ /* @noflip */
1760
+ left: 0;
1761
+ padding: .2em;
1762
+ outline: 0;
1763
+ }
1764
+ .ui-dialog .ui-dialog-titlebar {
1765
+ padding: .4em 1em;
1766
+ position: relative;
1767
+ }
1768
+ .ui-dialog .ui-dialog-title {
1769
+ float: left;
1770
+ margin: .1em 0;
1771
+ white-space: nowrap;
1772
+ width: 90%;
1773
+ overflow: hidden;
1774
+ text-overflow: ellipsis;
1775
+ }
1776
+ .ui-dialog .ui-dialog-titlebar-close {
1777
+ position: absolute;
1778
+ right: .3em;
1779
+ top: 50%;
1780
+ width: 21px;
1781
+ margin: -10px 0 0 0;
1782
+ padding: 1px;
1783
+ height: 20px;
1784
+ }
1785
+ .ui-dialog .ui-dialog-content {
1786
+ position: relative;
1787
+ border: 0;
1788
+ padding: .5em 1em;
1789
+ background: none;
1790
+ overflow: auto;
1791
+ }
1792
+ .ui-dialog .ui-dialog-buttonpane {
1793
+ text-align: left;
1794
+ border-width: 1px 0 0 0;
1795
+ background-image: none;
1796
+ margin-top: .5em;
1797
+ padding: .3em 1em .5em .4em;
1798
+ }
1799
+ .ui-dialog .ui-dialog-buttonpane .ui-dialog-buttonset {
1800
+ float: right;
1801
+ }
1802
+ .ui-dialog .ui-dialog-buttonpane button {
1803
+ margin: .5em .4em .5em 0;
1804
+ cursor: pointer;
1805
+ }
1806
+ .ui-dialog .ui-resizable-se {
1807
+ width: 12px;
1808
+ height: 12px;
1809
+ right: -5px;
1810
+ bottom: -5px;
1811
+ background-position: 16px 16px;
1812
+ }
1813
+ .ui-draggable .ui-dialog-titlebar {
1814
+ cursor: move;
1815
+ }
1816
+
1817
+ /* WP jQuery Dialog Theme */
1818
+ .wp-dialog {
1819
+ padding: 0;
1820
+ z-index: 300002;
1821
+ border: 0;
1822
+ -webkit-box-shadow: 0 5px 15px rgba(0,0,0,0.7);
1823
+ box-shadow: 0 5px 15px rgba(0,0,0,0.7);
1824
+ background-color: #f5f5f5;
1825
+ }
1826
+
1827
+ .wp-dialog .ui-dialog-title {
1828
+ display: block;
1829
+ text-align: center;
1830
+ padding: 0;
1831
+ }
1832
+
1833
+ .wp-dialog .ui-dialog-titlebar {
1834
+ padding: 0 1em;
1835
+ background-color: #444;
1836
+ font-size: 13px;
1837
+ line-height: 24px;
1838
+ color: #fff;
1839
+ }
1840
+
1841
+ .wp-dialog .ui-dialog-content {
1842
+ padding: 0;
1843
+ }
1844
+
1845
+ .wp-dialog .ui-dialog-titlebar-close {
1846
+ cursor: pointer;
1847
+ -webkit-appearance: none;
1848
+ border: 0;
1849
+ width: 30px;
1850
+ height: 20px;
1851
+ top: 13px;
1852
+ right: 6px;
1853
+ background: none;
1854
+ }
1855
+
1856
+ .wp-dialog .ui-dialog-titlebar-close:before {
1857
+ content: '\f158';
1858
+ font: normal 20px/1 'dashicons';
1859
+ speak: none;
1860
+ -webkit-font-smoothing: antialiased;
1861
+ -moz-osx-font-smoothing: grayscale;
1862
+ color: #999;
1863
+ padding-left: 12px;
1864
+ }
1865
+
1866
+ .wp-dialog .ui-dialog-titlebar-close:hover:before {
1867
+ color: #2ea2cc;
1868
+ }
1869
+
1870
+ .wp-dialog .ui-dialog-titlebar-close .ui-button-text {
1871
+ display: none;
1872
+ }
1873
+
1874
+ .wp-dialog .ui-dialog-titlebar-close:hover,
1875
+ .wp-dialog .ui-dialog-titlebar-close:focus {
1876
+ background-position: -87px -32px;
1877
+ }
1878
+
1879
+ .ui-widget-overlay {
1880
+ z-index: 300001;
1881
+ background-color: #000;
1882
+ opacity: 0.6;
1883
+ filter: alpha(opacity=60);
1884
+ }
1885
+
1886
+ /* TinyMCE modal */
1887
+ .clearlooks2 .mceTop {
1888
+ border-bottom: 1px solid #ccc;
1889
+ }
1890
+
1891
+ .clearlooks2 .mceTop span {
1892
+ font: 13px/24px "Open Sans", sans-serif;
1893
+ color: #e5e5e5;
1894
+ }
1895
+
1896
+ .clearlooks2 .mceTop .mceLeft {
1897
+ background: #444444;
1898
+ border-color: transparent;
1899
+ }
1900
+
1901
+ .clearlooks2 .mceTop .mceRight {
1902
+ background: #444444;
1903
+ border-color: transparent;
1904
+ }
1905
+
1906
+ .clearlooks2 .mceMiddle {
1907
+ clip: rect(24px auto auto auto);
1908
+ }
1909
+
1910
+ .clearlooks2 .mceMiddle .mceLeft {
1911
+ background: #f1f1f1;
1912
+ border-color: transparent;
1913
+ }
1914
+
1915
+ .clearlooks2 .mceMiddle .mceRight {
1916
+ background: #f1f1f1;
1917
+ border-color: transparent;
1918
+ }
1919
+
1920
+ .clearlooks2 .mceBottom {
1921
+ background: #f1f1f1;
1922
+ border-color: transparent;
1923
+ }
1924
+
1925
+ .clearlooks2 .mceBottom .mceLeft {
1926
+ background: #f1f1f1;
1927
+ border-color: transparent;
1928
+ }
1929
+
1930
+ .clearlooks2 .mceBottom .mceCenter {
1931
+ background: #f1f1f1;
1932
+ border-color: transparent;
1933
+ }
1934
+
1935
+ .clearlooks2 .mceBottom .mceRight {
1936
+ background: #f1f1f1;
1937
+ border-color: transparent;
1938
+ }
1939
+
1940
+ .clearlooks2 .mceClose,
1941
+ .clearlooks2 .mceFocus .mceClose,
1942
+ .clearlooks2 .mceFocus .mceClose:hover {
1943
+ background-image: none;
1944
+ }
1945
+ .clearlooks2 .mceClose:before {
1946
+ speak: none;
1947
+ -webkit-font-smoothing: antialiased;
1948
+ -moz-osx-font-smoothing: grayscale;
1949
+ color: #999;
1950
+ padding-left: 12px;
1951
+ }
1952
+
1953
+ /* Distraction Free Writing mode
1954
+ * =Overlay Styles
1955
+ -------------------------------------------------------------- */
1956
+ .fullscreen-overlay {
1957
+ z-index: 149999;
1958
+ display: none;
1959
+ position: fixed;
1960
+ top: 0;
1961
+ bottom: 0;
1962
+ left: 0;
1963
+ right: 0;
1964
+ filter: inherit;
1965
+ }
1966
+
1967
+ .fullscreen-active .fullscreen-overlay,
1968
+ .fullscreen-active #wp-fullscreen-body {
1969
+ display: block;
1970
+ }
1971
+
1972
+ .fullscreen-fader {
1973
+ z-index: 200000;
1974
+ }
1975
+
1976
+ .fullscreen-active .fullscreen-fader {
1977
+ display: none;
1978
+ }
1979
+
1980
+ /* =Overlay Body
1981
+ -------------------------------------------------------------- */
1982
+ #wp-fullscreen-body {
1983
+ width: 100%;
1984
+ z-index: 150005;
1985
+ display: none;
1986
+ position: absolute;
1987
+ top: 0;
1988
+ left: 0;
1989
+ font-size: 12px;
1990
+ }
1991
+
1992
+ #wp-fullscreen-wrap {
1993
+ margin: 0 auto 50px;
1994
+ position: relative;
1995
+ padding-top: 60px;
1996
+ }
1997
+
1998
+ #wp-fullscreen-title {
1999
+ font-size: 1.7em;
2000
+ line-height: 100%;
2001
+ outline: medium none;
2002
+ padding: 6px 7px;
2003
+ width: 100%;
2004
+ margin-bottom: 30px;
2005
+ -webkit-box-shadow: none;
2006
+ box-shadow: none;
2007
+ }
2008
+
2009
+ #wp-fullscreen-container {
2010
+ padding: 4px 10px 50px;
2011
+ }
2012
+
2013
+ #wp-fullscreen-title,
2014
+ #wp-fullscreen-container {
2015
+ -webkit-border-radius: 0;
2016
+ border-radius: 0;
2017
+ border: 1px dashed transparent;
2018
+ background: transparent;
2019
+ -moz-transition-property: border-color;
2020
+ -moz-transition-duration: 0.6s;
2021
+ -webkit-transition-property: border-color;
2022
+ -webkit-transition-duration: 0.6s;
2023
+ -o-transition-property: border-color;
2024
+ -o-transition-duration: 0.6s;
2025
+ transition-property: border-color;
2026
+ transition-duration: 0.6s;
2027
+ }
2028
+
2029
+ #wp_mce_fullscreen {
2030
+ width: 100%;
2031
+ min-height: 300px;
2032
+ border: 0;
2033
+ background: transparent;
2034
+ font-family: Consolas, Monaco, monospace;
2035
+ line-height: 1.6em;
2036
+ padding: 0;
2037
+ overflow-y: hidden;
2038
+ outline: none;
2039
+ resize: none;
2040
+ -webkit-box-shadow: none;
2041
+ box-shadow: none;
2042
+ }
2043
+
2044
+ #wp-fullscreen-tagline {
2045
+ color: #BBBBBB;
2046
+ font-size: 18px;
2047
+ float: right;
2048
+ padding-top: 5px;
2049
+ }
2050
+
2051
+ /* =Top bar
2052
+ -------------------------------------------------------------- */
2053
+ #fullscreen-topbar {
2054
+ background: #f5f5f5;
2055
+ border-bottom: 1px solid #fff;
2056
+ height: 40px;
2057
+ left: 0;
2058
+ min-width: 800px;
2059
+ position: fixed;
2060
+ top: 0;
2061
+ width: 100%;
2062
+ z-index: 150050;
2063
+ }
2064
+
2065
+ #wp-fullscreen-toolbar {
2066
+ padding: 6px 10px 0;
2067
+ clear: both;
2068
+ max-width: 1100px;
2069
+ min-width: 820px;
2070
+ margin: 0 auto;
2071
+ }
2072
+
2073
+ #wp-fullscreen-mode-bar,
2074
+ #wp-fullscreen-button-bar,
2075
+ #wp-fullscreen-close,
2076
+ #wp-fullscreen-count {
2077
+ float: left;
2078
+ }
2079
+
2080
+ #wp-fullscreen-save {
2081
+ float: right;
2082
+ padding: 2px 2px 0 5px;
2083
+ }
2084
+
2085
+ #wp-fullscreen-count,
2086
+ #wp-fullscreen-close {
2087
+ padding-top: 5px;
2088
+ }
2089
+
2090
+ #wp-fullscreen-central-toolbar {
2091
+ margin: auto;
2092
+ padding: 0;
2093
+ }
2094
+
2095
+ #wp-fullscreen-buttons > div {
2096
+ float: left;
2097
+ }
2098
+
2099
+ #wp-fullscreen-mode-bar {
2100
+ padding: 1px 14px 0 0;
2101
+ }
2102
+
2103
+ #wp-fullscreen-modes a {
2104
+ display: block;
2105
+ font-size: 11px;
2106
+ text-decoration: none;
2107
+ float: left;
2108
+ margin: 1px 0 0 0;
2109
+ padding: 2px 6px 2px;
2110
+ border-width: 1px 1px 1px 0;
2111
+ border-style: solid;
2112
+ border-color: #bbb;
2113
+ color: #777;
2114
+ text-shadow: 0 1px 0 #fff;
2115
+ background-color: #f4f4f4;
2116
+ background: #f4f4f4;
2117
+ background-image: -webkit-gradient(linear, left bottom, left top, from(#e4e4e4), to(#f9f9f9));
2118
+ background-image: -webkit-linear-gradient(bottom, #e4e4e4, #f9f9f9);
2119
+ background-image: -moz-linear-gradient(bottom, #e4e4e4, #f9f9f9);
2120
+ background-image: -o-linear-gradient(bottom, #e4e4e4, #f9f9f9);
2121
+ background-image: linear-gradient(to top, #e4e4e4, #f9f9f9);
2122
+ }
2123
+
2124
+ #wp-fullscreen-modes a:hover,
2125
+ .wp-html-mode #wp-fullscreen-modes a:last-child,
2126
+ .wp-tmce-mode #wp-fullscreen-modes a:first-child {
2127
+ color: #333;
2128
+ border-color: #999;
2129
+ background: #eee;
2130
+ background-image: -webkit-gradient(linear, left top, left bottom, from(#e4e4e4), to(#f9f9f9));
2131
+ background-image: -webkit-linear-gradient(top, #e4e4e4, #f9f9f9);
2132
+ background-image: -moz-linear-gradient(top, #e4e4e4, #f9f9f9);
2133
+ background-image: -o-linear-gradient(top, #e4e4e4, #f9f9f9);
2134
+ background-image: linear-gradient(to bottom, #e4e4e4, #f9f9f9);
2135
+ }
2136
+
2137
+ #wp-fullscreen-modes a:first-child {
2138
+ border-width: 1px;
2139
+ -webkit-border-top-left-radius: 3px;
2140
+ -webkit-border-bottom-left-radius: 3px;
2141
+ border-top-left-radius: 3px;
2142
+ border-bottom-left-radius: 3px;
2143
+ }
2144
+
2145
+ #wp-fullscreen-modes a:last-child {
2146
+ -webkit-border-top-right-radius: 3px;
2147
+ -webkit-border-bottom-right-radius: 3px;
2148
+ border-top-right-radius: 3px;
2149
+ border-bottom-right-radius: 3px;
2150
+ }
2151
+
2152
+ #wp-fullscreen-buttons .active a {
2153
+ background: inherit;
2154
+ }
2155
+
2156
+ #wp-fullscreen-buttons .hidden {
2157
+ display: none;
2158
+ }
2159
+
2160
+ #wp-fullscreen-buttons .disabled {
2161
+ opacity: 0.5;
2162
+ }
2163
+
2164
+ .wp-html-mode #wp-fullscreen-buttons div {
2165
+ display: none;
2166
+ }
2167
+
2168
+ .wp-html-mode #wp-fullscreen-buttons div.wp-fullscreen-both {
2169
+ display: block;
2170
+ }
2171
+
2172
+ #fullscreen-topbar.fullscreen-make-sticky {
2173
+ display: block !important;
2174
+ }
2175
+
2176
+ #wp-fullscreen-save img {
2177
+ vertical-align: middle;
2178
+ }
2179
+
2180
+ #wp-fullscreen-save img,
2181
+ #wp-fullscreen-save span {
2182
+ padding-right: 4px;
2183
+ display: none;
2184
+ }
2185
+
2186
+ /* =Thickbox Adjustments
2187
+ -------------------------------------------------------------- */
2188
+ .fullscreen-active #TB_overlay {
2189
+ z-index: 150100;
2190
+ }
2191
+
2192
+ .fullscreen-active #TB_window {
2193
+ z-index: 150102;
2194
+ }
2195
+
2196
+ /* =TinyMCE Adjustments
2197
+ -------------------------------------------------------------- */
2198
+ #wp_mce_fullscreen_ifr {
2199
+ background: transparent;
2200
+ }
2201
+
2202
+ #wp_mce_fullscreen_parent #wp_mce_fullscreen_tbl tr.mceFirst {
2203
+ display : none;
2204
+ }
2205
+
2206
+ #wp-fullscreen-container .wp_themeSkin table td {
2207
+ vertical-align: top;
2208
+ }
2209
+
2210
+ /* Colors */
2211
+ .fullscreen-overlay {
2212
+ background: #fff;
2213
+ }
2214
+
2215
+ .wp-fullscreen-focus #wp-fullscreen-title,
2216
+ .wp-fullscreen-focus #wp-fullscreen-container {
2217
+ border-color: #ccc;
2218
+ }
2219
+
2220
+ /* =CSS 3 transitions
2221
+ -------------------------------------------------------------- */
2222
+
2223
+ .fade-1000,
2224
+ .fade-600,
2225
+ .fade-400,
2226
+ .fade-300 {
2227
+ opacity: 0;
2228
+ -moz-transition-property: opacity;
2229
+ -webkit-transition-property: opacity;
2230
+ -o-transition-property: opacity;
2231
+ transition-property: opacity;
2232
+ }
2233
+
2234
+ .fade-1000 {
2235
+ -moz-transition-duration: 1s;
2236
+ -webkit-transition-duration: 1s;
2237
+ -o-transition-duration: 1s;
2238
+ transition-duration: 1s;
2239
+ }
2240
+
2241
+ .fade-600 {
2242
+ -moz-transition-duration: 0.6s;
2243
+ -webkit-transition-duration: 0.6s;
2244
+ -o-transition-duration: 0.6s;
2245
+ transition-duration: 0.6s;
2246
+ }
2247
+
2248
+ .fade-400 {
2249
+ -moz-transition-duration: 0.4s;
2250
+ -webkit-transition-duration: 0.4s;
2251
+ -o-transition-duration: 0.4s;
2252
+ transition-duration: 0.4s;
2253
+ }
2254
+
2255
+ .fade-300 {
2256
+ -moz-transition-duration: 0.3s;
2257
+ -webkit-transition-duration: 0.3s;
2258
+ -o-transition-duration: 0.3s;
2259
+ transition-duration: 0.3s;
2260
+ }
2261
+
2262
+ .fade-trigger {
2263
+ opacity: 1;
2264
+ }
2265
+
2266
+ /* =Localization
2267
+ -------------------------------------------------------------- */
2268
+ .rtl .wp_themeSkin .mceColorSplitMenu a.mceMoreColors,
2269
+ .rtl .wp_themeSkin .mceMenu .mceText,
2270
+ .rtl .wp-switch-editor,
2271
+ .rtl .quicktags-toolbar input,
2272
+ .rtl .clearlooks2 .mceTop span,
2273
+ .rtl .wp_themeSkin .mceColorSplitMenu a.mceMoreColors {
2274
+ font-family: Tahoma, sans-serif;
2275
+ }
2276
+
2277
+ html:lang(he-il) .rtl .wp_themeSkin .mceColorSplitMenu a.mceMoreColors,
2278
+ html:lang(he-il) .rtl .wp_themeSkin .mceMenu .mceText,
2279
+ html:lang(he-il) .rtl .wp-switch-editor,
2280
+ html:lang(he-il) .rtl .quicktags-toolbar input,
2281
+ html:lang(he-il) .rtl .clearlooks2 .mceTop span,
2282
+ html:lang(he-il) .rtl .wp_themeSkin .mceColorSplitMenu a.mceMoreColors {
2283
+ font-family: Arial, sans-serif;
2284
+ }
2285
+
2286
+
2287
+ /* HiDPI */
2288
+ @media print,
2289
+ (-o-min-device-pixel-ratio: 5/4),
2290
+ (-webkit-min-device-pixel-ratio: 1.25),
2291
+ (min-resolution: 120dpi) {
2292
+ .wp-media-buttons .add_media span.wp-media-buttons-icon,
2293
+ #wp-fullscreen-buttons #wp_fs_image span.mce_image {
2294
+ background: none;
2295
+ }
2296
+
2297
+ .wp_themeSkin .mceListBox .mceOpen,
2298
+ .wp_themeSkin .mceListBoxHover .mceOpen,
2299
+ .wp_themeSkin .mceListBoxSelected .mceOpen,
2300
+ .wp_themeSkin table.mceListBoxEnabled .mceOpen {
2301
+ background-image: url('../../../../../wp-includes/images/down_arrow-2x.gif');
2302
+ background-size: 10px 20px;
2303
+ }
2304
+
2305
+ .wp_themeSkin .mceSplitButtonEnabled a.mceOpen,
2306
+ .wp_themeSkin .mceSplitButtonSelected a.mceOpen,
2307
+ .wp_themeSkin .mceSplitButtonActive a.mceOpen,
2308
+ .wp_themeSkin .mceSplitButtonEnabled:hover a.mceOpen {
2309
+ background-image: url('../../../../../wp-includes/images/down_arrow-2x.gif');
2310
+ background-size: 10px 20px;
2311
+ }
2312
+
2313
+ #wp-link .toggle-arrow {
2314
+ background: transparent url('../../../../../wp-includes/images/toggle-arrow-2x.png') top left no-repeat;
2315
+ background-size: 19px 69px;
2316
+ }
2317
+ }
css/validationEngine.jquery.css CHANGED
@@ -1 +1 @@
1
- .widget_wysija_cont .inputContainer{position:relative;float:left}.widget_wysija_cont .ajaxSubmit{padding:20px;background:#55ea55;border:1px solid #999;display:none}.formError{position:absolute;top:300px;left:300px;display:block;z-index:5000;cursor:pointer}.formError .formErrorContent{background:none repeat scroll 0 0 #8E2121;border:1px solid #BBBBBB;color:#FFFFFF;font-family:tahoma;font-size:11px;padding:4px 10px;position:relative;width:150px;z-index:5001}.widget_wysija_cont .formError .formErrorArrow{width:15px;margin:-2px 0 0 13px;position:relative;z-index:5006}.widget_wysija_cont .formError .formErrorArrowBottom{margin:0px 0 0 12px;top:2px}.widget_wysija_cont .formError .formErrorArrow div{border-left:2px solid #ddd;border-right:2px solid #ddd;font-size:0px;height:1px;background:#8E2121;margin:0 auto;line-height:0;font-size:0;display:block}.widget_wysija_cont .greenPopup .formErrorArrow div{background:#33be40}.widget_wysija_cont .blackPopup .formErrorArrow div{background:#393939;color:#FFF}.widget_wysija_cont .formError .formErrorArrow .line10{width:15px;border:none}.widget_wysija_cont .formError .formErrorArrow .line9{width:13px;border:none}.widget_wysija_cont .formError .formErrorArrow .line8{width:11px}.widget_wysija_cont .formError .formErrorArrow .line7{width:9px}.widget_wysija_cont .formError .formErrorArrow .line6{width:7px}.widget_wysija_cont .formError .formErrorArrow .line5{width:5px}.widget_wysija_cont .formError .formErrorArrow .line4{width:3px}.widget_wysija_cont .formError .formErrorArrow .line3{width:1px;border-left:2px solid #ddd;border-right:2px solid #ddd;border-bottom:0 solid #ddd}.widget_wysija_cont .formError .formErrorArrow .line2{width:3px;border:none;background:#ddd}.widget_wysija_cont .formError .formErrorArrow .line1{width:1px;border:none;background:#ddd}.greenPopup .formErrorContent{background:none repeat scroll 0 0 #FFFBCC;color:#555555}.widget_wysija_cont .updated,.widget_wysija_cont .error,.widget_wysija_cont .xdetailed-errors{margin:5px 0 15px;color:#333333;font-family:sans-serif;font-size:12px;line-height:1.4em}.widget_wysija_cont .error,.widget_wysija_cont .login #login_error{background-color:#FFEBE8;border-color:#CC0000}.widget_wysija_cont .updated,.widget_wysija_cont .error,.widget_wysija_cont .xdetailed-errors{border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-style:solid;border-width:1px;margin:5px 15px 2px;padding:0 0.6em;color:#333333}.widget_wysija_cont.updated,.widget_wysija_cont .login .message{background-color:#FFFFE0;border-color:#E6DB55}.widget_wysija_cont .xdetailed-updated{background-color:#FFFFE0;border-color:#E6DB55;color:#000;font-weight:bold;display:none}.widget_wysija_cont .xdetailed-errors{background-color:#A50000;border-color:#888888;color:#DDDDDD;font-weight:bold;display:none}.widget_wysija_cont .instruct{font-style:italic;font-weight:bold;padding:5px 0;font-size:11px}.widget_wysija_cont .needInfo{padding-left:15px;text-decoration:underline}.widget_wysija_cont .wysija-submit{display:block;margin-top:20px}.widget_wysija_cont input.defaultlabels{color:#888}.widget_wysija_cont input.defaultlabels:focus{color:#373737}.widget_wysija_cont .abs-req{display:none}.widget_wysija_cont p label{display:block}.widget_wysija_cont .iframe-hidden{display:none}.widget_wysija_cont .updated,.widget_wysija_cont .error,.widget_wysija_cont .xdetailed-errors{background-color:#FFFFFF;border:1px solid;border-radius:0 0 0 0;font-weight:normal;margin:4px 0;padding:4px}.widget_wysija_cont .error,.widget_wysija_cont .xdetailed-errors{background-color:#e55057;color:#fff}.widget_wysija_cont .error,.widget_wysija_cont .xdetailed-errors{background-color:#e55057;color:#fff;border-color:#CC0000}.widget_wysija_cont .allmsgs ul{padding:0}.widget_wysija_cont .allmsgs li{list-style-type:none}.widget_wysija_cont .updated,.widget_wysija_cont .login .message{background-color:#FFFFE0;border-color:#E6DB55}.widget_wysija_cont .updated ul{margin:0}.widget_wysija_cont .showerrors{color:#DDDDDD}#wysija-subscriptions input.checkboxx{margin-left:0px;margin-right:10px}#wysija-subscriptions th label{margin-right:10px}#wysija-box-after-comment{width:25px}#wysija-box-after-register{margin:2px 6px 16px 0;padding:3px}.wysija-unsubscribed-on{color:#bbb}#profile-details-section-wysija{float:right;width:48%}.widget_wysija .wysija-required{font-weight:bold}.widget_wysija .wysija-checkbox-label{margin:0 0 10px 0}
1
+ .widget_wysija_cont .inputContainer{position:relative;float:left}.widget_wysija_cont .ajaxSubmit{padding:20px;background:#55ea55;border:1px solid #999;display:none}.formError{position:absolute;top:300px;left:300px;display:block;z-index:5000;cursor:pointer}.formError .formErrorContent{background:none repeat scroll 0 0 #8E2121;border:1px solid #BBBBBB;color:#FFFFFF;font-family:tahoma;font-size:11px;padding:4px 10px;position:relative;width:150px;z-index:5001}.widget_wysija_cont .formError .formErrorArrow{width:15px;margin:-2px 0 0 13px;position:relative;z-index:5006}.widget_wysija_cont .formError .formErrorArrowBottom{margin:0px 0 0 12px;top:2px}.widget_wysija_cont .formError .formErrorArrow div{border-left:2px solid #ddd;border-right:2px solid #ddd;font-size:0px;height:1px;background:#8E2121;margin:0 auto;line-height:0;font-size:0;display:block}.widget_wysija_cont .greenPopup .formErrorArrow div{background:#33be40}.widget_wysija_cont .blackPopup .formErrorArrow div{background:#393939;color:#FFF}.widget_wysija_cont .formError .formErrorArrow .line10{width:15px;border:none}.widget_wysija_cont .formError .formErrorArrow .line9{width:13px;border:none}.widget_wysija_cont .formError .formErrorArrow .line8{width:11px}.widget_wysija_cont .formError .formErrorArrow .line7{width:9px}.widget_wysija_cont .formError .formErrorArrow .line6{width:7px}.widget_wysija_cont .formError .formErrorArrow .line5{width:5px}.widget_wysija_cont .formError .formErrorArrow .line4{width:3px}.widget_wysija_cont .formError .formErrorArrow .line3{width:1px;border-left:2px solid #ddd;border-right:2px solid #ddd;border-bottom:0 solid #ddd}.widget_wysija_cont .formError .formErrorArrow .line2{width:3px;border:none;background:#ddd}.widget_wysija_cont .formError .formErrorArrow .line1{width:1px;border:none;background:#ddd}.greenPopup .formErrorContent{background:none repeat scroll 0 0 #FFFBCC;color:#555555}.widget_wysija_cont .updated,.widget_wysija_cont .error,.widget_wysija_cont .xdetailed-errors{margin:5px 0 15px;color:#333333;font-family:sans-serif;font-size:12px;line-height:1.4em}.widget_wysija_cont .error,.widget_wysija_cont .login #login_error{background-color:#FFEBE8;border-color:#CC0000}.widget_wysija_cont .updated,.widget_wysija_cont .error,.widget_wysija_cont .xdetailed-errors{border-radius:3px;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-style:solid;border-width:1px;margin:5px 15px 2px;padding:0 0.6em;color:#333333}.widget_wysija_cont.updated,.widget_wysija_cont .login .message{background-color:#FFFFE0;border-color:#E6DB55}.widget_wysija_cont .xdetailed-updated{background-color:#FFFFE0;border-color:#E6DB55;color:#000;font-weight:bold;display:none}.widget_wysija_cont .xdetailed-errors{background-color:#A50000;border-color:#888888;color:#DDDDDD;font-weight:bold;display:none}.widget_wysija_cont .instruct{font-style:italic;font-weight:bold;padding:5px 0;font-size:11px}.widget_wysija_cont .needInfo{padding-left:15px;text-decoration:underline}.widget_wysija_cont .wysija-submit{display:block;margin-top:20px}.widget_wysija_cont input.defaultlabels{color:#888}.widget_wysija_cont input.defaultlabels:focus{color:#373737}.widget_wysija_cont .abs-req{display:none}.widget_wysija_cont p label{display:block}.widget_wysija_cont .iframe-hidden{display:none}.widget_wysija_cont .updated,.widget_wysija_cont .error,.widget_wysija_cont .xdetailed-errors{background-color:#FFFFFF;border:1px solid;border-radius:0 0 0 0;font-weight:normal;margin:4px 0;padding:4px}.widget_wysija_cont .error,.widget_wysija_cont .xdetailed-errors{background-color:#e55057;color:#fff}.widget_wysija_cont .error,.widget_wysija_cont .xdetailed-errors{background-color:#e55057;color:#fff;border-color:#CC0000}.widget_wysija_cont .allmsgs ul{padding:0}.widget_wysija_cont .allmsgs li{list-style-type:none}.widget_wysija_cont .updated,.widget_wysija_cont .login .message{background-color:#FFFFE0;border-color:#E6DB55}.widget_wysija_cont .updated ul{margin:0}.widget_wysija_cont .showerrors{color:#DDDDDD}#wysija-subscriptions input.checkboxx{margin-left:0px;margin-right:10px}#wysija-subscriptions th label{margin-right:10px}#wysija-box-after-comment{width:25px}#wysija-box-after-register{margin:0 6px 0 0;padding:3px}.wysija-after-register{padding-bottom:10px}.wysija-unsubscribed-on{color:#bbb}.widget_wysija .wysija-required{font-weight:bold}.widget_wysija .wysija-radio-label,.widget_wysija .wysija-checkbox-label{margin:0 0 5px 0;cursor:pointer}.widget_wysija .wysija-radio,.widget_wysija .wysija-checkbox{margin:0 5px 0 0;vertical-align:middle}.xdetailed-errors,.xdetailed-updated{display:none}
css/vendor/bootstrap.tooltip.css ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ .tooltip {
2
+ position: absolute;
3
+ z-index: 1030;
4
+ display: block;
5
+ visibility: visible;
6
+ font-size: 12px;
7
+ line-height: 1.4;
8
+ opacity: 0;
9
+ filter: alpha(opacity=0);
10
+ }
11
+ .tooltip.in {
12
+ opacity: 0.9;
13
+ filter: alpha(opacity=90);
14
+ }
15
+ .tooltip.top {
16
+ margin-top: -3px;
17
+ padding: 5px 0;
18
+ }
19
+ .tooltip.right {
20
+ margin-left: 3px;
21
+ padding: 0 5px;
22
+ }
23
+ .tooltip.bottom {
24
+ margin-top: 3px;
25
+ padding: 5px 0;
26
+ }
27
+ .tooltip.left {
28
+ margin-left: -3px;
29
+ padding: 0 5px;
30
+ }
31
+ .tooltip-inner {
32
+ max-width: 200px;
33
+ padding: 3px 8px;
34
+ color: #ffffff;
35
+ text-align: center;
36
+ text-decoration: none;
37
+ background-color: #000000;
38
+ border-radius: 4px;
39
+ }
40
+ .tooltip-inner a {
41
+ color: #fff;
42
+ }
43
+ .tooltip-arrow {
44
+ position: absolute;
45
+ width: 0;
46
+ height: 0;
47
+ border-color: transparent;
48
+ border-style: solid;
49
+ }
50
+ .tooltip.top .tooltip-arrow {
51
+ bottom: 0;
52
+ left: 50%;
53
+ margin-left: -5px;
54
+ border-width: 5px 5px 0;
55
+ border-top-color: #000000;
56
+ }
57
+ .tooltip.top-left .tooltip-arrow {
58
+ bottom: 0;
59
+ left: 5px;
60
+ border-width: 5px 5px 0;
61
+ border-top-color: #000000;
62
+ }
63
+ .tooltip.top-right .tooltip-arrow {
64
+ bottom: 0;
65
+ right: 5px;
66
+ border-width: 5px 5px 0;
67
+ border-top-color: #000000;
68
+ }
69
+ .tooltip.right .tooltip-arrow {
70
+ top: 50%;
71
+ left: 0;
72
+ margin-top: -5px;
73
+ border-width: 5px 5px 5px 0;
74
+ border-right-color: #000000;
75
+ }
76
+ .tooltip.left .tooltip-arrow {
77
+ top: 50%;
78
+ right: 0;
79
+ margin-top: -5px;
80
+ border-width: 5px 0 5px 5px;
81
+ border-left-color: #000000;
82
+ }
83
+ .tooltip.bottom .tooltip-arrow {
84
+ top: 0;
85
+ left: 50%;
86
+ margin-left: -5px;
87
+ border-width: 0 5px 5px;
88
+ border-bottom-color: #000000;
89
+ }
90
+ .tooltip.bottom-left .tooltip-arrow {
91
+ top: 0;
92
+ left: 5px;
93
+ border-width: 0 5px 5px;
94
+ border-bottom-color: #000000;
95
+ }
96
+ .tooltip.bottom-right .tooltip-arrow {
97
+ top: 0;
98
+ right: 5px;
99
+ border-width: 0 5px 5px;
100
+ border-bottom-color: #000000;
101
+ }
css/wysija-editor.css CHANGED
@@ -1 +1 @@
1
- .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}.hidden{display:none}strong{font-weight:bold}img{vertical-align:middle}:focus{outline:0 !important}.inline{display:-moz-inline-box;display:inline-block;*display:inline;*float:left}.wysija_controls li,.wysija_tools li,.wysija_tools dd{margin:0 !important}#wysija_items{position:fixed;width:275px;right:20px;top:20px;z-index:999}#wysija_items li{line-height:100px;height:100px;outline:1px solid #ccc;text-align:center}.wysija_items li.disabled{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";filter:alpha(opacity=20);-moz-opacity:0.2;opacity:0.2}.wysija_items li.active a{height:100px;cursor:pointer;display:block}.wysija_header,.wysija_footer{position:relative;display:inline-table;display:block;height:1%;margin:0;padding:0;z-index:999}.wysija_header:after,.wysija_footer:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_block{position:relative;margin:0 10px;padding:10px 18px 10px 18px;display:inline-table;display:block;height:1%;margin:0;z-index:999}.wysija_block.dragging,.wysija_header.dragging,.wysija_footer.dragging{z-index:99000}.wysija_block:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_block.hover{border:1px dashed #bbb;margin:0 0 0 0;padding:9px 17px 9px 17px}.wysija_block.static{padding:0;margin:0}.wysija_block .wysija_controls{background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;border:1px solid #ccc;position:absolute;margin:0;padding:0;width:598px;height:20px;left:-1px;rigth:0;top:-22px}.wysija_block .wysija_controls .handle{width:598px}.wysija_block .wysija_controls li{float:left;width:20px;height:20px}.wysija_block .wysija_controls a{cursor:pointer;float:left;font-size:120%;font-weight:bold;height:20px;line-height:20px;text-align:center;width:20px;color:#000}.wysija_gallery .wysija_tools,.wysija_image .wysija_tools{position:absolute;height:34px;line-height:34px;margin:0;width:152px;top:-36px;z-index:1010;background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;border:1px solid #ccc;padding:0 0 0 5px}.wysija_gallery .wysija_tools{width:102px}.left .wysija_image .wysija_tools,.center .wysija_image .wysija_tools,.left.wysija_gallery .wysija_tools,.center.wysija_gallery .wysija_tools{left:0;text-align:left}.right .wysija_image .wysija_tools,.right.wysija_gallery .wysija_tools{right:0;text-align:right}.wysija_text .wysija_tools{position:absolute;height:20px;line-height:20px;top:0;right:0;margin:0;z-index:1000;width:20px}.wysija_text.alone .wysija_tools{display:none}.wysija_gallery .wysija_tools li,.wysija_image .wysija_tools li{float:left;width:25px;height:34px}.wysija_text .wysija_tools li{float:left;width:20px;height:20px}.wysija_gallery .wysija_tools a,.wysija_image .wysija_tools a,.wysija_text .wysija_tools a{background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));float:left;width:20px;height:20px;margin:5px 3px 0 0;-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.15),inset 0 0 2px 1px #fff;-moz-box-shadow:0 1px 0 rgba(0,0,0,0.15),inset 0 0 2px 1px #fff;box-shadow:0 1px 0 rgba(0,0,0,0.15),inset 0 0 2px 1px #fff;border:1px solid #ccc;z-index:1010;position:relative}.wysija_text .wysija_tools a{margin:0}.wysija_gallery .wysija_tools a:hover,.wysija_image .wysija_tools a:hover,.wysija_text .wysija_tools a:hover{background-color:#ddd;border-color:#909090}.wysija_gallery .wysija_tools a.active,.wysija_image .wysija_tools a.active,.wysija_text .wysija_tools a.active{background-color:#ddd;background-image:-moz-linear-gradient(center bottom, #eee, #bbb);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#eee), to(#bbb));border-color:#909090}.wysija_controls a span,.wysija_gallery .wysija_tools a span,.wysija_image .wysija_tools a span,.wysija_text .wysija_tools a span,.wj_content a span{display:block;height:20px;width:20px}.wysija_controls span input{margin:2px 0 0 0}.alignment-left span{background:url(../img/controls/icons.png) no-repeat 0 0}.alignment-left.active span,.alignment-left:hover span{background:url(../img/controls/icons.png) no-repeat 0 -20px}.alignment-center span{background:url(../img/controls/icons.png) no-repeat -20px 0}.alignment-center.active span,.alignment-center:hover span{background:url(../img/controls/icons.png) no-repeat -20px -20px}.alignment-right span{background:url(../img/controls/icons.png) no-repeat -40px 0}.alignment-right.active span,.alignment-right:hover span{background:url(../img/controls/icons.png) no-repeat -40px -20px}.add-link span{background:url(../img/controls/icons.png) no-repeat -60px 0}.add-link.active span,.add-link:hover span{background:url(../img/controls/icons.png) no-repeat -60px -20px}.remove-link span{background:url(../img/controls/icons.png) no-repeat -80px 0}.remove-link.active span,.remove-link:hover span{background:url(../img/controls/icons.png) no-repeat -80px -20px}.remove span{background:url(../img/controls/icons.png) no-repeat -100px 0}.remove.active span,.remove:hover span{background:url(../img/controls/icons.png) no-repeat -100px -20px}.handle span{background:url(../img/controls/icons.png) no-repeat -120px 0;cursor:move}.handle.active span,.handle:hover span{background:url(../img/controls/icons.png) no-repeat -120px -20px;cursor:move}.duplicate span{background:url(../img/controls/icons.png) no-repeat -140px 0}.duplicate.active span,.duplicate:hover span{background:url(../img/controls/icons.png) no-repeat -140px -20px}.settings span{background:url(../img/controls/icons.png) no-repeat -160px 0}.settings.active span,.settings:hover span{background:url(../img/controls/icons.png) no-repeat -160px -20px}.icon-plus span{background:url(../img/controls/icons.png) no-repeat -200px 0}.icon-plus.active span,.icon-plus:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.icon-minus span{background:url(../img/controls/icons.png) no-repeat -220px 0}.icon-minus.active span,.icon-minus:hover span{background:url(../img/controls/icons.png) no-repeat -220px -20px}.banner{color:#000;background-color:#fff;z-index:999;text-align:center;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=70)";filter:alpha(opacity=70);-moz-opacity:0.7;opacity:0.7;width:600px;position:absolute;top:0;right:0;left:0;bottom:0;white-space:nowrap;font-size:16px !important}.banner .banner-message{margin:20px auto 0 auto}.banner .banner-notice{margin:10px auto 0 auto;font-size:12px;font-style:italic}#wysija_wrapper{padding:20px;width:600px;border:1px solid #ccc;position:relative;background-color:#fff;-webkit-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);-moz-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);box-shadow:0 0 5px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1)}#wysija_wrapper:before,#wysija_wrapper:after{position:absolute;width:40%;height:10px;content:' ';left:12px;bottom:12px;background:transparent;-webkit-transform:skew(-5deg) rotate(-5deg);-moz-transform:skew(-5deg) rotate(-5deg);-ms-transform:skew(-5deg) rotate(-5deg);-o-transform:skew(-5deg) rotate(-5deg);transform:skew(-5deg) rotate(-5deg);-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.3);-moz-box-shadow:0 6px 12px rgba(0,0,0,0.3);box-shadow:0 6px 12px rgba(0,0,0,0.3);z-index:-1}#wysija_wrapper:after{left:auto;right:12px;-webkit-transform:skew(5deg) rotate(5deg);-moz-transform:skew(5deg) rotate(5deg);-ms-transform:skew(5deg) rotate(5deg);-o-transform:skew(5deg) rotate(5deg);transform:skew(5deg) rotate(5deg)}body.rtl #wysija_wrapper{right:603px !important}#wysija_container{margin:30px 0 0 0;width:600px;border-collapse:collapse;width:600px;margin:0;padding:0}#wysija_header{padding:0}#wysija_body{vertical-align:top;padding:0}#wysija_footer{padding:0}.empty{display:none}.empty.active.wysija_image,.empty.active.wysija_text{display:block}#wysija_block_placeholder{height:0;padding:0;margin:0}#block_placeholder{margin:0;height:0}#block_placeholder.active{margin:18px 18px 0px 18px;display:block;height:30px}.block_placeholder{border:0 none;z-index:9500;margin:0;position:relative;left:0;top:-10px;width:562px}.wysija_block .block_placeholder,.wysija_block .text_placeholder,.wysija_block .image_placeholder{margin:0}.image_placeholder{margin:1px 0 0 1px}.wysija_block .block_placeholder.active,.wysija_block .text_placeholder.active{height:30px}.block_placeholder,.text_placeholder,.image_placeholder.empty{transition:opacity .25s, height .25s linear;-moz-transition:opacity .25s, height .25s linear;-webkit-transition:opacity .25s, height .25s linear;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=0)";filter:alpha(opacity=0);-moz-opacity:0;opacity:0;height:0;margin:0}.image_placeholder.active{border:1px dashed #bbb;background-color:#f5f5f5;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;transition:opacity .25s;-moz-transition:opacity .25s;-webkit-transition:opacity .25s}.block_placeholder.active,.text_placeholder.active,.image_placeholder.empty.active{border:1px dashed #bbb;background-color:#f5f5f5;display:block;transition:opacity .25s, height .25s linear;-moz-transition:opacity .25s, height .25s linear;-webkit-transition:opacity .25s, height .25s linear;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5}.wysija_content .empty.editable{margin:0 !important}.block_placeholder.active,.wysija_content.center .text_placeholder.active{height:30px}.image_placeholder.empty.active{height:80px;width:80px}.wysija_image.empty.active{width:80px}.wysija_content.right .wysija_image.empty.active{margin-right:3px}.auto-post .block_placeholder.active{margin:0 0 0 18px}.block_placeholder.hover,.text_placeholder.hover,.image_placeholder.hover,.image_placeholder.empty.hover{background-color:#e5e5e5;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);-moz-opacity:1.0;opacity:1.0}.text_placeholder.hover{display:block}#wysija_header .wysija_image.active,#wysija_footer .wysija_image.active{left:0;top:0;right:0}.wysija_header .image_placeholder,.wysija_footer .image_placeholder{border:0 none !important;margin:0 !important}.wysija_header .image_placeholder.active,.wysija_footer .image_placeholder.active{border:0 none !important}.wysija_options{display:none}.wysija_content .wysija_image,.wysija_content.center .wysija_image{margin:0 auto 15px auto;cursor:move}.wysija_content.center .image_placeholder.active{margin:0 0 -2px 0}.wysija_header .wysija_content.center .wysija_image,.wysija_footer .wysija_content.center .wysija_image{margin:0 auto}.wysija_header .wysija_content.left .wysija_image,.wysija_header .wysija_content.right .wysija_image,.wysija_footer .wysija_content.left .wysija_image,.wysija_footer .wysija_content.right .wysija_image{margin:0 0 0 0}.wysija_header .wysija_content.center .image_placeholder.active,.wysija_footer .wysija_content.center .image_placeholder.active{margin:0}.wysija_content.left{float:none}.wysija_gallery.left{float:left}.wysija_content.left .wysija_image{float:left;margin:0 15px 5px 0}.wysija_gallery.right{float:right}.wysija_content.right .wysija_image{float:right;margin:0 0 5px 15px}.wysija_content .wysija_image.alone{margin:0 !important}.wysija_content.center .wysija_image.alone{margin:0 auto !important}.wysija_content.left .wysija_image.active{margin:0 13px 3px 0;left:-1px;top:-1px}.wysija_content.center .wysija_image.active{left:-1px;top:-1px}.wysija_content.right .wysija_image.active{margin:0 0 3px 13px;top:-1px;right:-1px}.wysija_image{position:relative;z-index:999}.wysija_image .url-info{position:absolute;bottom:0;left:0;font-size:0.7em;padding:2px;color:#000;background-color:#fff;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";filter:alpha(opacity=80);-moz-opacity:0.8;opacity:0.8}.wysija_content.left .wysija_image .url-info{right:0;left:auto}.wysija_text{position:relative;z-index:998}.wysija_text.editing{border:1px solid #dfdfdf}.wysija_content.left .wysija_text.editing{float:left}.wysija_text .editable:hover{cursor:pointer}#wysija_toolbar{left:657px;position:absolute;top:-1000px;width:295px}#wysija_toolbar .wysija_toolbar_tabs{border-bottom:1px solid #dfdfdf;line-height:0}#wysija_toolbar .wysija_toolbar_tabs li,#wysija_toolbar .wysija_toolbar_tabs a{margin:0;height:30px;line-height:30px;padding:0;display:-moz-inline-box;display:inline-block;*display:inline;*float:left;outline:0 none}#wysija_toolbar .wysija_toolbar_tabs a{outline:0 none;text-decoration:none;color:#a6a6a6}#wysija_toolbar .wysija_toolbar_tabs li{margin:0 0 1px 0}#wysija_toolbar .wysija_toolbar_tabs a{font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #f5f5f5);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#F5F5F5', endColorstr='#F9F9F9');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#f5f5f5));border:1px solid #DFDFDF;-moz-border-radius:3px 3px 0 0;-webkit-border-radius:3px 3px 0 0;-khtml-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;box-shadow:0 1px 0 #FFFFFF inset;padding:0 7px}#wysija_toolbar .wysija_toolbar_tabs a:hover{background-color:#eee}#wysija_toolbar .wysija_toolbar_tabs a.selected{color:#000;border-bottom:0 none;background:#fcfcfc;filter:none;padding-bottom:1px}#wysija_toolbar .wysija_toolbar_tabs,#wysija_toolbar .wj_content,#wysija_toolbar .wj_images,#wysija_toolbar .wj_styles,#wysija_toolbar .wj_themes{position:relative;z-index:9998;margin:0}#wysija_toolbar #wysija_notices span{font-size:12px !important;font-weight:normal !important}.wj_content{background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:0 0 10px 0}.wj_content li{padding:10px 10px 0 10px;position:relative}.wj_content li.notice{font-style:italic;font-size:11px}.wj_images{z-index:999;background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:9px}.wj_images ul{height:360px;overflow:auto;margin:0;padding:0}.wj_images li{float:left;width:80px;margin:2px;height:80px;overflow:hidden;position:relative;border:1px solid #dfdfdf}.wj_images li img{max-height:150px;width:80px}.wj_images li a{float:left;display:block;height:80px;width:80px}.wj_button{text-align:center;width:265px;margin:20px 0;height:30px;line-height:30px}.wj_images img{cursor:move;max-width:275px}.wj_images #wj_images_preview{border:3px solid #dfdfdf;position:absolute;right:295px;top:0;background-color:#fff}.wj_styles{z-index:999;background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:9px}.wj_styles p{margin:10px 0}.wj_styles .preview{width:20px;float:none !important;height:20px;vertical-align:middle;display:-moz-inline-box;display:inline-block;*display:inline;*float:left;border:1px solid #333}.wj_styles input,.wj_styles select{height:20px;border:0 none;border:1px solid #CCC;margin:0 3px 0 0 !important;padding:0 !important;vertical-align:middle;line-height:20px;font-size:12px}.wj_styles #aUnderlineInput{margin:0 0 0 10px !important}.wj_styles select{width:75px}.wj_styles input.checkbox,.wj_styles input[type=checkbox]{border:0 none !important}.wj_styles input.color{width:55px;padding:0 0 0 2px !important}.wj_styles input.color.disabled{background-color:#eee !important;color:#eee !important}.wj_styles select.small-size{width:50px}.wj_styles select.type{width:68px}.wj_styles select.size{width:58px}.wj_styles form label{cursor:normal;margin:0 0 0 3px}.wj_themes{z-index:999;background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:9px}.wj_themes ul{height:360px;overflow:auto;margin:0;padding:0}.wj_themes li{float:left;width:80px;margin:2px;height:80px;overflow:hidden;border:1px solid #dfdfdf;position:relative}.wj_themes li img{max-height:150px;width:80px}.wj_themes li a{display:block}.wj_themes #wj_themes_preview{border:3px solid #dfdfdf;position:absolute;right:295px;top:0;background-color:#fff}.wysija_widget{width:275px;height:25px;line-height:25px;z-index:9999 !important}.wj_content a.wysija_item,.wysija_widget{height:25px;line-height:25px;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;display:block;font-size:12px;font-weight:bold;padding:0 0 0 7px;cursor:move;color:#222;text-shadow:0 1px 0 #FFFFFF}.wj_content a.wysija_item.disabled{cursor:help;color:#cccccc}.wysija_item_settings{position:absolute;right:15px;top:14px}.wysija_widget.image{z-index:9999 !important;height:auto !important;width:150px !important;background:none !important;border:0 none !important;box-shadow:none !important;border-radius:0 !important;padding:0 !important}#wysija_notices{z-index:20000;position:relative;left:0;top:0;padding:5px;border:1px solid #dfdfdf;border-top:0 none}#wysija_notices.notice{background-color:#FFFFE0;border-color:#E6DB55;z-index:9999}#wysija_notices.error{background-color:#FFEBE8;border-color:#CC0000}#wysija_notice_msg{font-size:14px;font-weight:bold}.align-center{text-align:center}.align-left{text-align:left}.align-right{text-align:right}.align-justify{text-align:justify}.wysija_gallery{position:relative}.wysija_gallery.center{margin:0 auto}.wysija_gallery.right{text-align:right}.wysija_gallery.left{text-align:left}.wysija_row{width:100%}.wysija_cell{float:left;text-align:center}.resize-controls{position:absolute;left:-1px;right:-1px;top:-1px;height:100%;z-index:99000;border:1px dashed #ccc}.resize-handle{position:absolute;bottom:0;right:0;width:20px;height:20px;border:0 none;z-index:1001;cursor:se-resize;background:transparent url(../img/controls/resize-se.png) no-repeat scroll right bottom}.resize-info{position:absolute;bottom:0;left:0;font-size:0.8em;padding:2px;text-shadow:0 1px 0 #F7F5F2}.right .resize-handle{position:absolute;bottom:0;left:0;width:20px;height:20px;border:0 none;z-index:1001;cursor:sw-resize;background:transparent url(../img/controls/resize-sw.png) no-repeat scroll left bottom}.right .resize-info{position:absolute;bottom:0;right:0;text-align:right}#adminmenu li .wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{z-index:1001 !important}.wysija_divider{margin:0 auto;width:564px}.wysija_block.auto-post.hover .wysija_content *,.wysija_block.auto-post.hover .wysija_divider{z-index:1000;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";filter:alpha(opacity=30);-moz-opacity:0.3;opacity:0.3}.wysija_auto-post .wysija_divider{text-align:center;margin:0 !important;width:100% !important}.wysija_auto-post .nopost{height:100px}.wysija_auto-post .nopost p{margin:25px 0 0 0}.wysija_settings{left:10px;position:absolute;top:0;z-index:1000}.wysija_settings a{background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;font-size:12px;font-weight:normal;cursor:pointer;color:#222;text-shadow:0 1px 0 #FFFFFF;text-decoration:none;display:block;padding:5px 5px 3px 27px}.wysija_settings a span{width:20px;height:20px;position:absolute;top:3px;left:5px}#wysija_toggle_images{position:absolute;top:5px;right:5px;z-index:1000;width:73px;height:33px;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;background-color:#fff}#wysija_toggle_images.on{background:url(../img/controls/images-toggle-on.png) no-repeat}#wysija_toggle_images.off{background:url(../img/controls/images-toggle-off.png) no-repeat}#wysija_toggle_images:hover{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);-moz-opacity:1.0;opacity:1.0}.wysija_block.auto-post{padding:0px 1px !important}.wysija_block.auto-post.hover{padding:0 !important}.wysija_auto-post .wysija_content{padding:10px 18px !important}.wysija_auto-post .wysija_divider{padding:10px 0 !important}.wysija_block.auto-post.hover .wysija_content{padding:10px 17px !important}.wysija_block.auto-post.hover .wysija_content.first{padding:9px 17px 10px 17px !important}.wysija_block.auto-post.hover .wysija_content.last{padding:10px 17px 9px 17px !important}.wysija_auto-post .loading{padding:10px 18px;font-size:10px}#wysija_popup_overlay{background-color:#000;height:100%;left:0;position:fixed;top:0;width:100%;z-index:999989;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=75)";filter:alpha(opacity=75);-moz-opacity:0.75;opacity:0.75}#wysija_popup_overlay.loading{background:url(../img/popup/loading.gif) no-repeat 50% 50% #000}#wysija_popup{position:absolute;top:0;left:0;width:600px;height:400px;background-color:#fff;z-index:999999;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;-moz-box-shadow:#000 0 4px 30px;-webkit-box-shadow:#000 0 4px 30px;-khtml-box-shadow:#000 0 4px 30px;box-shadow:#000 0 4px 30px;border:1px solid #555}.rtl #wysija_popup{min-width:700px}#wysija_popup_content{padding:0;overflow:hidden;position:relative}#wysija_popup_title{background-color:#222;border:1px solid #333;height:27px;margin:0;padding:0}#wysija_popup_title h3{color:#cfcfcf;font-size:12px;font-weight:normal;margin:6px 0 0 10px;padding:0;float:left;font:12px "Lucida Grande", Verdana, Arial, sans-serif}#wysija_popup_iframe{border:0 none;outline:0 none}.rtl #wysija_popup_iframe{min-width:700px}#wysija_popup_close{background:url(../img/popup/close.png) no-repeat;height:15px;width:15px;background-color:#333;display:block;float:right;margin:6px 10px 0 0}.debug-line{position:absolute;left:0;top:0;display:block;height:1px;width:100%}.debug-line.red{background-color:#f00}.debug-line.green{background-color:#0f0}.debug-line.blue{background-color:#00f}
1
+ .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}.hidden{display:none}strong{font-weight:bold}img{vertical-align:middle}:focus{outline:0 !important}.inline{display:-moz-inline-box;display:inline-block;*display:inline;*float:left}.wysija_tools li,.wysija_tools dd{margin:0 !important}.wysija_controls li{margin:0 0 0 3px !important}#wysija_items{position:fixed;width:275px;right:20px;top:20px;z-index:999}#wysija_items li{line-height:100px;height:100px;outline:1px solid #ccc;text-align:center}.wysija_items li.disabled{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=20)";filter:alpha(opacity=20);-moz-opacity:0.2;opacity:0.2}.wysija_items li.active a{height:100px;cursor:pointer;display:block}.wysija_header,.wysija_footer{position:relative;display:inline-table;display:block;height:1%;margin:0;padding:0;z-index:98}.wysija_header:after,.wysija_footer:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_block{position:relative;margin:0 10px;padding:10px 18px 10px 18px;display:inline-table;display:block;height:1%;margin:0;z-index:98}.wysija_block.dragging,.wysija_header.dragging,.wysija_footer.dragging{z-index:99000}.wysija_block:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_block.hover{border:1px dashed #bbb;margin:0 0 0 0;padding:9px 17px 9px 17px}.wysija_block.static{padding:0;margin:0}.wysija_block .wysija_controls{background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;border:1px solid #ccc;position:absolute;margin:0;padding:0;width:598px;height:20px;left:-1px;right:0;top:-22px;width:100%}.wysija_block .wysija_controls .handle{width:600px}.wysija_block .wysija_controls li{float:left;width:20px;height:20px}.wysija_block .wysija_controls a{cursor:pointer;float:left;font-size:120%;font-weight:bold;height:20px;line-height:20px;text-align:center;width:20px;color:#000}.wysija_block .handle_container,.wysija_block .handle_container a{float:none;width:40px}.wysija_block .handle_container{left:280px;top:0;position:absolute}.wysija_gallery .wysija_tools,.wysija_image .wysija_tools{position:absolute;height:34px;line-height:34px;margin:0;width:152px;top:-36px;z-index:1010;background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;border:1px solid #ccc;padding:0 0 0 5px}.wysija_gallery .wysija_tools{width:102px}.left .wysija_image .wysija_tools,.center .wysija_image .wysija_tools,.left.wysija_gallery .wysija_tools,.center.wysija_gallery .wysija_tools{left:0;text-align:left}.right .wysija_image .wysija_tools,.right.wysija_gallery .wysija_tools{right:0;text-align:right}.wysija_text .wysija_tools{position:absolute;height:20px;line-height:20px;top:0;right:0;margin:0;z-index:1000;width:20px}.wysija_text.alone .wysija_tools{display:none}.wysija_gallery .wysija_tools li,.wysija_image .wysija_tools li{float:left;width:25px;height:34px}.wysija_text .wysija_tools li{float:left;width:20px;height:20px}.wysija_gallery .wysija_tools a,.wysija_image .wysija_tools a,.wysija_text .wysija_tools a{background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));float:left;width:20px;height:20px;margin:5px 3px 0 0;-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;-webkit-box-shadow:0 1px 0 rgba(0,0,0,0.15),inset 0 0 2px 1px #fff;-moz-box-shadow:0 1px 0 rgba(0,0,0,0.15),inset 0 0 2px 1px #fff;box-shadow:0 1px 0 rgba(0,0,0,0.15),inset 0 0 2px 1px #fff;border:1px solid #ccc;z-index:1010;position:relative}.wysija_text .wysija_tools a{margin:0}.wysija_gallery .wysija_tools a:hover,.wysija_image .wysija_tools a:hover,.wysija_text .wysija_tools a:hover{background-color:#ddd;border-color:#909090}.wysija_gallery .wysija_tools a.active,.wysija_image .wysija_tools a.active,.wysija_text .wysija_tools a.active{background-color:#ddd;background-image:-moz-linear-gradient(center bottom, #eee, #bbb);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#eee), to(#bbb));border-color:#909090}.wysija_controls a span,.wysija_gallery .wysija_tools a span,.wysija_image .wysija_tools a span,.wysija_text .wysija_tools a span,.wj_content a span{display:block;height:20px;width:20px}.wysija_controls span input{margin:2px 0 0 0;padding:0;color:transparent}.alignment-left span{background:url(../img/controls/icons.png) no-repeat 0 0}.alignment-left.active span,.alignment-left:hover span{background:url(../img/controls/icons.png) no-repeat 0 -20px}.alignment-center span{background:url(../img/controls/icons.png) no-repeat -20px 0}.alignment-center.active span,.alignment-center:hover span{background:url(../img/controls/icons.png) no-repeat -20px -20px}.alignment-right span{background:url(../img/controls/icons.png) no-repeat -40px 0}.alignment-right.active span,.alignment-right:hover span{background:url(../img/controls/icons.png) no-repeat -40px -20px}.add-link span{background:url(../img/controls/icons.png) no-repeat -60px 0}.add-link.active span,.add-link:hover span{background:url(../img/controls/icons.png) no-repeat -60px -20px}.remove-link span{background:url(../img/controls/icons.png) no-repeat -80px 0}.remove-link.active span,.remove-link:hover span{background:url(../img/controls/icons.png) no-repeat -80px -20px}.remove span{background:url(../img/controls/icons.png) no-repeat -100px 0}.remove.active span,.remove:hover span{background:url(../img/controls/icons.png) no-repeat -100px -20px}.handle span{background:url(../img/controls/grip-handle.png) no-repeat;cursor:move;width:40px !important}.duplicate span{background:url(../img/controls/icons.png) no-repeat -140px 0}.duplicate.active span,.duplicate:hover span{background:url(../img/controls/icons.png) no-repeat -140px -20px}.settings span{background:url(../img/controls/icons.png) no-repeat -160px 0}.settings.active span,.settings:hover span{background:url(../img/controls/icons.png) no-repeat -160px -20px}.icon-plus span{background:url(../img/controls/icons.png) no-repeat -200px 0}.icon-plus.active span,.icon-plus:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.icon-minus span{background:url(../img/controls/icons.png) no-repeat -220px 0}.icon-minus.active span,.icon-minus:hover span{background:url(../img/controls/icons.png) no-repeat -220px -20px}.banner{color:#000;z-index:999;text-align:center;width:600px;position:absolute;top:0;right:0;left:0;bottom:0;white-space:nowrap;font-size:16px !important;-webkit-touch-callout:none;-webkit-user-select:none;-khtml-user-select:none;-moz-user-select:none;-ms-user-select:none;user-select:none}.banner .banner-message{margin:20px auto 0 auto}.banner .banner-icon{background:url(../img/controls/image-placeholder.png) no-repeat;padding:2px 0 0 28px}.banner .banner-notice{margin:10px auto 0 auto;font-size:12px;font-style:italic}#wysija_wrapper{padding:20px;width:600px;border:1px solid #ccc;position:relative;background-color:#fff;-webkit-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);-moz-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);box-shadow:0 0 5px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1)}#wysija_wrapper:before,#wysija_wrapper:after{position:absolute;width:40%;height:10px;content:' ';left:12px;bottom:12px;background:transparent;-webkit-transform:skew(-5deg) rotate(-5deg);-moz-transform:skew(-5deg) rotate(-5deg);-ms-transform:skew(-5deg) rotate(-5deg);-o-transform:skew(-5deg) rotate(-5deg);transform:skew(-5deg) rotate(-5deg);-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.3);-moz-box-shadow:0 6px 12px rgba(0,0,0,0.3);box-shadow:0 6px 12px rgba(0,0,0,0.3);z-index:-1}#wysija_wrapper:after{left:auto;right:12px;-webkit-transform:skew(5deg) rotate(5deg);-moz-transform:skew(5deg) rotate(5deg);-ms-transform:skew(5deg) rotate(5deg);-o-transform:skew(5deg) rotate(5deg);transform:skew(5deg) rotate(5deg)}body.rtl #wysija_wrapper{right:603px !important}#wysija_container{margin:30px 0 0 0;width:600px;border-collapse:collapse;width:600px;margin:0;padding:0}#wysija_header{padding:0}#wysija_body{vertical-align:top;padding:0}#wysija_footer{padding:0}#wysija_block_placeholder{height:0;padding:0;margin:0}.block_placeholder,.text_placeholder{font-weight:bold;height:0;overflow:hidden;line-height:30px;text-align:center;border:0 none;width:598px;z-index:9500;margin:0 auto;text-indent:-9999px}.wysija_block .block_placeholder,.wysija_block .text_placeholder,.wysija_block .image_placeholder{margin:0}.image_placeholder{margin:1px 0 0 1px}.hover .image_placeholder{margin:0}.wysija_content .empty.editable{font-size:13px;line-height:30px}.wysija_image.empty{height:0;width:0;margin:0 !important;z-index:-1;overflow:hidden}.wysija_image.empty.active{height:auto}.wysija_image.active{background:url(../img/controls/image-placeholder.png) no-repeat center center #f5f5f5;border:1px dashed #dfdfdf}#wysija_header .wysija_image.empty,#wysija_footer .wysija_image.empty{background-image:none;height:auto}#wysija_header .wysija_image.active,#wysija_footer .wysija_image.active{border:0 none}.block_placeholder.active,.text_placeholder.active{text-indent:0;border:1px dashed #dfdfdf;background-color:#f5f5f5;display:block;overflow:auto;height:30px}.image_placeholder.empty.active{display:block}.block_placeholder.hover,.text_placeholder.hover,.image_hover .wysija_image{background-color:#0074a2;border-color:#0074a2;color:#fff !important}.image_placeholder.active{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=25)";filter:alpha(opacity=25);-moz-opacity:0.25;opacity:0.25;z-index:9501}.wysija_image.empty.active,.wysija_text.empty.active{display:block;margin:0}#wysija_header .wysija_image.active,#wysija_footer .wysija_image.active{left:0;top:0;right:0}.wysija_header .image_placeholder,.wysija_footer .image_placeholder{border:0 none !important;margin:0 !important}.wysija_header .image_placeholder.active,.wysija_footer .image_placeholder.active{border:0 none !important}.wysija_options{display:none}.wysija_content .wysija_image{margin:0 auto 15px auto;cursor:move}.wysija_header .wysija_content.left .wysija_image,.wysija_header .wysija_content.right .wysija_image,.wysija_footer .wysija_content.left .wysija_image,.wysija_footer .wysija_content.right .wysija_image{margin:0 0 0 0 !important}.wysija_content.center .image_placeholder.active{margin:0 0 -2px 0}.wysija_header .wysija_content.center .wysija_image,.wysija_footer .wysija_content.center .wysija_image{margin:0 auto !important}.wysija_header .wysija_content.center .image_placeholder.active,.wysija_footer .wysija_content.center .image_placeholder.active{margin:0}.wysija_block .wysija_content.center .wysija_image.empty.active{margin-bottom:5px !important}.wysija_content.left{float:none}.wysija_gallery.left{float:left}.wysija_content.left .wysija_image{float:left;margin:0 15px 5px 0}.wysija_content.left .wysija_image.active{margin:0 13px 3px 0}.wysija_content.left .wysija_image.empty.active{margin:0 15px 5px 0 !important}.wysija_gallery.right{float:right}.wysija_content.right .wysija_image{float:right;margin:0 0 5px 15px}.wysija_content.right .wysija_image.active{margin:0 0 3px 13px}.wysija_content.right .wysija_image.empty.active{margin:0 0 5px 15px !important}.wysija_content .wysija_image.alone{margin:0 !important}.wysija_content.center .wysija_image.alone{margin:0 auto !important}.wysija_image{position:relative;z-index:999}.wysija_image .url-info{position:absolute;bottom:0;left:0;font-size:0.7em;padding:2px;color:#000;background-color:#fff;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=80)";filter:alpha(opacity=80);-moz-opacity:0.8;opacity:0.8}.wysija_content.left .wysija_image .url-info{right:0;left:auto}.wysija_text{position:relative;z-index:998}.wysija_text.editing{border:1px solid #dfdfdf}.wysija_content.left .wysija_text.editing{float:left}.wysija_text .editable:hover{cursor:pointer}#wysija_toolbar{left:657px;position:absolute;top:-1000px;width:295px}#wysija_toolbar .wysija_toolbar_tabs{border-bottom:1px solid #dfdfdf;line-height:0}#wysija_toolbar .wysija_toolbar_tabs li,#wysija_toolbar .wysija_toolbar_tabs a{margin:0;height:30px;line-height:30px;padding:0;display:-moz-inline-box;display:inline-block;*display:inline;*float:left;outline:0 none}#wysija_toolbar .wysija_toolbar_tabs a{outline:0 none;text-decoration:none;color:#a6a6a6}#wysija_toolbar .wysija_toolbar_tabs li{margin:0 0 1px 0}#wysija_toolbar .wysija_toolbar_tabs a{font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #f5f5f5);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#F5F5F5', endColorstr='#F9F9F9');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#f5f5f5));border:1px solid #DFDFDF;-moz-border-radius:3px 3px 0 0;-webkit-border-radius:3px 3px 0 0;-khtml-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;box-shadow:0 1px 0 #FFFFFF inset;padding:0 7px}#wysija_toolbar .wysija_toolbar_tabs a:hover{background-color:#eee}#wysija_toolbar .wysija_toolbar_tabs a.selected{color:#000;border-bottom:0 none;background:#fcfcfc;filter:none;padding-bottom:1px}#wysija_toolbar .wysija_toolbar_tabs,#wysija_toolbar .wj_content,#wysija_toolbar .wj_images,#wysija_toolbar .wj_styles,#wysija_toolbar .wj_themes{position:relative;z-index:9998;margin:0}#wysija_toolbar #wysija_notices span{font-size:12px !important;font-weight:normal !important}.wj_content{background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:0 0 10px 0}.wj_content li{padding:10px 10px 0 10px;position:relative}.wj_content li.notice{font-style:italic;font-size:11px;margin:0 !important;border:0 none !important;background:none !important}.wj_images{z-index:999;background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:9px}.wj_images ul{height:360px;overflow:auto;margin:0;padding:0}.wj_images li{float:left;width:80px;margin:2px;height:80px;overflow:hidden;position:relative;border:1px solid #dfdfdf}.wj_images li img{max-height:150px;width:80px}.wj_images li a{float:left;display:block;height:80px;width:80px}.wj_button{text-align:center;width:265px;margin:20px 0;height:30px;line-height:30px}.wj_images img{cursor:move;max-width:275px}#wysija-upload-browse,#wysija-themes-browse{float:none}.wj_images #wj_images_preview{border:3px solid #dfdfdf;position:absolute;right:295px;top:0;background-color:#fff}.wj_styles{z-index:999;background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:9px}.wj_styles p{margin:10px 0}.wj_styles .preview{width:20px;float:none !important;height:20px;vertical-align:middle;display:-moz-inline-box;display:inline-block;*display:inline;*float:left;border:1px solid #333}.wj_styles input,.wj_styles select{height:20px;border:0 none;border:1px solid #CCC;margin:0 3px 0 0 !important;padding:0 !important;vertical-align:middle;line-height:20px;font-size:12px}.wj_styles #aUnderlineInput{margin:0 0 0 10px !important}.wj_styles select{width:75px}.wj_styles input.checkbox,.wj_styles input[type=checkbox]{border:0 none !important}.wj_styles input.color{width:55px;padding:0 0 0 2px !important}.wj_styles input.color.disabled{background-color:#eee !important;color:#eee !important}.wj_styles select.small-size{width:50px}.wj_styles select.type{width:68px}.wj_styles select.size{width:58px}.wj_styles form label{cursor:normal;margin:0 0 0 3px}.wj_themes{z-index:999;background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:9px}.wj_themes ul{height:360px;overflow:auto;margin:0;padding:0}.wj_themes li{float:left;width:80px;margin:2px;height:80px;overflow:hidden;border:1px solid #dfdfdf;position:relative}.wj_themes li img{max-height:150px;width:80px}.wj_themes li a{display:block}.wj_themes #wj_themes_preview{border:3px solid #dfdfdf;position:absolute;right:295px;top:0;background-color:#fff}.wysija_widget{width:275px;height:25px;line-height:25px;z-index:9999 !important}.wj_content a.wysija_item,.wysija_widget{height:25px;line-height:25px;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;display:block;font-size:12px;font-weight:bold;padding:0 0 0 7px;cursor:move;color:#222;text-shadow:0 1px 0 #FFFFFF}.wj_content a.wysija_item.disabled{cursor:help;color:#cccccc}.wysija_item_settings{position:absolute;right:15px;top:13px}.wysija_widget.image{z-index:9999 !important;height:auto !important;width:150px !important;background:none !important;border:0 none !important;box-shadow:none !important;border-radius:0 !important;padding:0 !important}#wysija_notices{z-index:20000;position:relative;left:0;top:0;padding:5px;border:1px solid #dfdfdf;border-top:0 none}#wysija_notices.notice{background-color:#FFFFE0;border-color:#E6DB55;z-index:9999}#wysija_notices.error{background-color:#FFEBE8;border-color:#CC0000}#wysija_notice_msg{font-size:14px;font-weight:bold}.align-center{text-align:center}.align-left{text-align:left}.align-right{text-align:right}.align-justify{text-align:justify}.wysija_gallery{position:relative}.wysija_gallery.center{margin:0 auto}.wysija_gallery.right{text-align:right}.wysija_gallery.left{text-align:left}.wysija_row{width:100%}.wysija_cell{float:left;text-align:center}.resize-controls{position:absolute;left:0;right:0;top:0;bottom:0;z-index:99000;border:1px dashed #ccc}.resize-handle{position:absolute;bottom:0;right:0;width:20px;height:20px;border:0 none;z-index:1001;cursor:se-resize;background:transparent url(../img/controls/resize-se.png) no-repeat scroll right bottom}.resize-info{position:absolute;bottom:0;left:4px;font-size:0.8em;padding:0;margin:0;text-shadow:0 1px 0 #F7F5F2;white-space:nowrap}.right .resize-handle{position:absolute;bottom:0;left:0;width:20px;height:20px;border:0 none;z-index:1001;cursor:sw-resize;background:transparent url(../img/controls/resize-sw.png) no-repeat scroll left bottom}.right .resize-info{left:auto !important;right:4px}#adminmenu li .wp-submenu,.folded #adminmenu .wp-has-current-submenu .wp-submenu{z-index:1001 !important}.wysija_divider{margin:0 auto;width:564px}.wysija_block.auto-post.hover .wysija_content *,.wysija_block.auto-post.hover .wysija_divider{z-index:1000;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=30)";filter:alpha(opacity=30);-moz-opacity:0.3;opacity:0.3}.wysija_auto-post .wysija_divider{text-align:center;margin:0 !important;width:100% !important}.wysija_auto-post .nopost{height:100px}.wysija_auto-post .nopost p{margin:25px 0 0 0}.wysija_settings{left:10px;position:absolute;top:0;z-index:1000}.wysija_settings a{background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;font-size:12px;font-weight:normal;cursor:pointer;color:#222;text-shadow:0 1px 0 #FFFFFF;text-decoration:none;display:block;padding:5px 5px 3px 27px}.wysija_settings a span{width:20px;height:20px;position:absolute;top:3px;left:5px}#wysija_toggle_images{position:absolute;top:5px;right:5px;z-index:1000;width:73px;height:33px;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=50)";filter:alpha(opacity=50);-moz-opacity:0.5;opacity:0.5;background-color:#fff}#wysija_toggle_images.on{background:url(../img/controls/images-toggle-on.png) no-repeat}#wysija_toggle_images.off{background:url(../img/controls/images-toggle-off.png) no-repeat}#wysija_toggle_images:hover{-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=100)";filter:alpha(opacity=100);-moz-opacity:1.0;opacity:1.0}.wysija_block.auto-post{padding:0 !important}.wysija_auto-post .wysija_content{padding:10px 17px !important}.wysija_auto-post .wysija_content:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_auto-post .wysija_content{display:inline-table}* html .wysija_auto-post .wysija_content{height:1%}.wysija_auto-post .wysija_content{display:block}.wysija_auto-post .wysija_divider{padding:9px 0 !important}.wysija_block.auto-post.hover .wysija_content{padding:10px 17px !important}.wysija_auto-post .wysija_text{pointer-events:none;cursor:default}.wysija_auto-post .wysija_image{pointer-events:none;cursor:default}.auto-post.hover .wysija_content:last-child{padding:9px 17px 9px 17px !important}.wysija_auto-post .loading{padding:10px 17px;font-size:10px}#wysija_popup_overlay{background-color:#000;height:100%;left:0;position:fixed;top:0;width:100%;z-index:999989;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=75)";filter:alpha(opacity=75);-moz-opacity:0.75;opacity:0.75}#wysija_popup_overlay.loading{background:url(../img/popup/loading.gif) no-repeat 50% 50% #000}#wysija_popup{position:absolute;top:0;left:0;width:600px;height:400px;background-color:#fff;z-index:999999;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;-moz-box-shadow:#000 0 4px 30px;-webkit-box-shadow:#000 0 4px 30px;-khtml-box-shadow:#000 0 4px 30px;box-shadow:#000 0 4px 30px;border:1px solid #555}#wysija_popup_content{padding:0;overflow:hidden;position:relative}#wysija_popup_title{background-color:#222;border:1px solid #333;height:27px;margin:0;padding:0}#wysija_popup_title h3{color:#cfcfcf;font-size:12px;font-weight:normal;margin:6px 0 0 10px;padding:0;float:left;font:12px "Lucida Grande", Verdana, Arial, sans-serif}#wysija_popup_iframe{border:0 none;outline:0 none}#wysija_popup_close{background:url(../img/popup/close.png) no-repeat;height:15px;width:15px;background-color:#333;display:block;float:right;margin:6px 10px 0 0}.mpoet-ui .wysija_item_settings{text-decoration:none}.mpoet-ui .settings span{background:none;color:#999}.mpoet-ui .wysija_item_settings:hover .dashicons-admin-generic:before,.mpoet-ui .settings:hover .dashicons-admin-generic:before{color:#2ea2cc}.wp_themeSkin .mceToolbar{margin:0 !important;padding:0 !important}
css/wysija-form-editor.css CHANGED
@@ -1 +1 @@
1
- .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}.hidden{display:none}strong{font-weight:bold}img{vertical-align:middle}:focus{outline:0 !important}.inline{display:-moz-inline-box;display:inline-block;*display:inline;*float:left}#form-error{padding:10px;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;color:#000;font-weight:normal;background-color:#ffebe8;border:1px solid #c00}#form-notice{padding:10px;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;color:#555555;font-weight:normal;background-color:#FFFBCC;border:1px solid #E6DB55}#wysija_form_editor{padding:20px;width:600px;border:1px solid #ccc;position:relative;background-color:#fff;-webkit-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);-moz-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);box-shadow:0 0 5px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1)}#wysija_form_editor:before,#wysija_form_editor:after{position:absolute;width:40%;height:10px;content:' ';left:12px;bottom:12px;background:transparent;-webkit-transform:skew(-5deg) rotate(-5deg);-moz-transform:skew(-5deg) rotate(-5deg);-ms-transform:skew(-5deg) rotate(-5deg);-o-transform:skew(-5deg) rotate(-5deg);transform:skew(-5deg) rotate(-5deg);-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.3);-moz-box-shadow:0 6px 12px rgba(0,0,0,0.3);box-shadow:0 6px 12px rgba(0,0,0,0.3);z-index:-1}#wysija_form_editor:after{left:auto;right:12px;-webkit-transform:skew(5deg) rotate(5deg);-moz-transform:skew(5deg) rotate(5deg);-ms-transform:skew(5deg) rotate(5deg);-o-transform:skew(5deg) rotate(5deg);transform:skew(5deg) rotate(5deg)}.wysija_form_block .wysija_warning{font-weight:bold;color:#900}.block_placeholder{margin:0;border:0 none}.block_placeholder.active{border:1px dashed #b4b4b4;margin:10px;display:block}.block_placeholder.hover{margin:10px;border:1px dashed #b4b4b4;background-color:#f5f5f5}.wysija_form_block{background-color:#fff;height:20px}.wysija_form_block img{max-width:100%}.wysija_form_block p{margin:5px 0}.wysija_form_block p input.radio,.wysija_form_block p input.checkbox{margin:0 5px 0 10px}#wysija_form_container{width:640px;margin:0}#wysija_form_toolbar{position:absolute;width:295px}#wysija_form_toolbar .wysija_form_toolbar_tabs{border-bottom:1px solid #dfdfdf;line-height:0}#wysija_form_toolbar .add_custom_field{text-align:center;padding:15px 0 5px 0}#wysija_form_toolbar .wysija_form_toolbar_tabs li,#wysija_form_toolbar .wysija_form_toolbar_tabs a{margin:0;height:30px;line-height:30px;padding:0;display:-moz-inline-box;display:inline-block;*display:inline;*float:left;outline:0 none}#wysija_form_toolbar .wysija_form_toolbar_tabs a{outline:0 none;text-decoration:none;color:#a6a6a6}#wysija_form_toolbar .wysija_form_toolbar_tabs li{margin:0 0 1px 0}#wysija_form_toolbar .wysija_form_toolbar_tabs a{font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #f5f5f5);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#F5F5F5', endColorstr='#F9F9F9');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#f5f5f5));border:1px solid #DFDFDF;-moz-border-radius:3px 3px 0 0;-webkit-border-radius:3px 3px 0 0;-khtml-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;box-shadow:0 1px 0 #FFFFFF inset;padding:0 7px}#wysija_form_toolbar .wysija_form_toolbar_tabs a:hover{background-color:#eee}#wysija_form_toolbar .wysija_form_toolbar_tabs a.selected{color:#000;border-bottom:0 none;background:#fcfcfc;filter:none;padding-bottom:1px}#wysija_form_toolbar .wysija_form_toolbar_tabs,#wysija_form_toolbar .wj_content,#wysija_form_toolbar .wj_images,#wysija_form_toolbar .wj_styles,#wysija_form_toolbar .wj_themes{position:relative;z-index:9998;margin:0}.wysija_form_widget{width:275px;height:25px;line-height:25px;z-index:9999 !important}#wysija_form_toolbar a.wysija_form_item,.wysija_form_widget{height:25px;line-height:25px;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;display:block;font-size:12px;font-weight:bold;padding:0 0 0 7px;cursor:move;color:#222;text-shadow:0 1px 0 #FFFFFF}#wysija_form_toolbar a.wysija_form_item.disabled{cursor:pointer;color:#cccccc}.wysija_form_item_settings{position:absolute;right:15px;top:14px}.wj_content{background-color:#fcfcfc;border:1px solid #dfdfdf;border-top:0 none;padding:0 0 10px 0}.wj_content li{padding:10px 10px 0 10px;position:relative}.wj_content li.notice{font-style:italic;font-size:11px}.wysija_form_block{position:relative;margin:0;padding:10px 18px 10px 18px;display:inline-table;display:block;height:1%;margin:0;z-index:990}.wysija_form_block.dragging{z-index:99000}.wysija_form_block:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_form_block.hover{border:1px dashed #bbb;margin:0 0 0 0;padding:9px 17px 9px 17px}.wysija_form_block.static{background-color:#999}.wysija_form_block .wysija_controls{background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;border:1px solid #ccc;position:absolute;margin:0;padding:0;width:598px;height:20px;left:-1px;rigth:0;top:-22px}.wysija_form_block .wysija_controls li{float:left;width:20px;height:20px}.wysija_form_block .wysija_controls a{cursor:pointer;float:left;font-size:120%;font-weight:bold;height:20px;line-height:20px;text-align:center;width:20px;color:#000}.wysija_controls a span,.wysija_gallery .wysija_tools a span,.wysija_image .wysija_tools a span,.wysija_text .wysija_tools a span,.wj_content a span{display:block;height:20px;width:20px}.wysija_controls span input{margin:2px 0 0 0}.alignment-left span{background:url(../img/controls/icons.png) no-repeat 0 0}.alignment-left.active span,.alignment-left:hover span{background:url(../img/controls/icons.png) no-repeat 0 -20px}.alignment-center span{background:url(../img/controls/icons.png) no-repeat -20px 0}.alignment-center.active span,.alignment-center:hover span{background:url(../img/controls/icons.png) no-repeat -20px -20px}.alignment-right span{background:url(../img/controls/icons.png) no-repeat -40px 0}.alignment-right.active span,.alignment-right:hover span{background:url(../img/controls/icons.png) no-repeat -40px -20px}.add-link span{background:url(../img/controls/icons.png) no-repeat -60px 0}.add-link.active span,.add-link:hover span{background:url(../img/controls/icons.png) no-repeat -60px -20px}.remove-link span{background:url(../img/controls/icons.png) no-repeat -80px 0}.remove-link.active span,.remove-link:hover span{background:url(../img/controls/icons.png) no-repeat -80px -20px}.remove span{background:url(../img/controls/icons.png) no-repeat -100px 0}.remove.active span,.remove:hover span{background:url(../img/controls/icons.png) no-repeat -100px -20px}.handle span{background:url(../img/controls/icons.png) no-repeat -120px 0;cursor:move}.handle.active span,.handle:hover span{background:url(../img/controls/icons.png) no-repeat -120px -20px;cursor:move}.duplicate span{background:url(../img/controls/icons.png) no-repeat -140px 0}.duplicate.active span,.duplicate:hover span{background:url(../img/controls/icons.png) no-repeat -140px -20px}.settings span{background:url(../img/controls/icons.png) no-repeat -160px 0}.settings.active span,.settings:hover span{background:url(../img/controls/icons.png) no-repeat -160px -20px}.icon-plus span{background:url(../img/controls/icons.png) no-repeat -200px 0}.icon-plus.active span,.icon-plus:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.icon-minus span{background:url(../img/controls/icons.png) no-repeat -220px 0}.icon-minus.active span,.icon-minus:hover span{background:url(../img/controls/icons.png) no-repeat -220px -20px}.wysija_options{display:none}.wysija_settings{left:10px;position:absolute;top:0;z-index:1000}.wysija_settings a{background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;font-size:12px;font-weight:normal;cursor:pointer;color:#222;text-shadow:0 1px 0 #FFFFFF;text-decoration:none;display:block;padding:5px 5px 3px 27px}.wysija_settings a span{width:20px;height:20px;position:absolute;top:3px;left:5px}.wysija_form_block label{margin:0 5px 0 0;display:block}#wysija_widget_templates{display:none}#wysija_popup_overlay{background-color:#000;height:100%;left:0;position:fixed;top:0;width:100%;z-index:999998;-ms-filter:"progid:DXImageTransform.Microsoft.Alpha(Opacity=75)";filter:alpha(opacity=75);-moz-opacity:0.75;opacity:0.75}#wysija_popup_overlay.loading{background:url(../img/popup/loading.gif) no-repeat 50% 50% #000}#wysija_popup{position:absolute;top:0;left:0;width:600px;height:400px;background-color:#fff;z-index:999999;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;-moz-box-shadow:#000 0 4px 30px;-webkit-box-shadow:#000 0 4px 30px;-khtml-box-shadow:#000 0 4px 30px;box-shadow:#000 0 4px 30px;border:1px solid #555}.rtl #wysija_popup{min-width:700px}#wysija_popup_content{padding:0;overflow:hidden;clear:both}#wysija_popup_title{background-color:#222;border:1px solid #333;height:27px;margin:0;padding:0}#wysija_popup_title h3{color:#cfcfcf;font-size:12px;font-weight:normal;margin:6px 0 0 10px;padding:0;float:left;font:12px "Lucida Grande", Verdana, Arial, sans-serif}#wysija_popup_title.empty{background-color:transparent;height:0;border:0 none}#wysija_popup_iframe{border:0 none;outline:0 none}.rtl #wysija_popup_iframe{min-width:700px}#wysija_popup_close{background:url(../img/popup/close.png) no-repeat;height:15px;width:15px;background-color:#333;display:block;float:right;margin:6px 10px 0 0}h2.title{height:40px;line-height:40px;margin:0 0 15px 0}h2.title span,h2.title form{float:left;margin:0 5px 0 0;vertical-align:middle}h2.title span#form-name{padding:0 3px;margin:0 10px 0 0;font-style:italic}h2.title span#form-name-default{display:none}h2.title #edit-form-name{float:left;margin:10px 5px 0 0}h2.title input{margin:0 10px 0 0}#after-submit textarea{width:300px;height:50px}#form-export textarea{width:100%;height:100px}#list-selection{width:600px}#list-selection label{display:block}#wysija_notices{z-index:20000;position:relative;left:0;top:0;padding:5px;border:1px solid #dfdfdf;border-top:0 none}#wysija_notices.notice{background-color:#FFFFE0;border-color:#E6DB55;z-index:9999}#wysija_notices.error{background-color:#FFEBE8;border-color:#CC0000}#wysija_notice_msg{font-size:14px;font-weight:bold}.expand-code{cursor:pointer}
1
+ .clearfix:after{content:".";display:block;height:0;clear:both;visibility:hidden}.clearfix{display:inline-table}* html .clearfix{height:1%}.clearfix{display:block}.hidden{display:none}strong{font-weight:bold}img{vertical-align:middle}:focus{outline:0 !important}.inline{display:-moz-inline-box;display:inline-block;*display:inline;*float:left}#form-error{padding:10px;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;color:#000;font-weight:normal;background-color:#ffebe8;border:1px solid #c00}#form-notice{padding:10px;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;color:#555555;font-weight:normal;background-color:#FFFBCC;border:1px solid #E6DB55}#wysija_form_editor{padding:20px;width:600px;border:1px solid #ccc;position:relative;background-color:#fff;-webkit-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);-moz-box-shadow:0 0 4px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1);box-shadow:0 0 5px rgba(0,0,0,0.2),inset 0 0 20px rgba(0,0,0,0.1)}#wysija_form_editor:before,#wysija_form_editor:after{position:absolute;width:40%;height:10px;content:' ';left:12px;bottom:12px;background:transparent;-webkit-transform:skew(-5deg) rotate(-5deg);-moz-transform:skew(-5deg) rotate(-5deg);-ms-transform:skew(-5deg) rotate(-5deg);-o-transform:skew(-5deg) rotate(-5deg);transform:skew(-5deg) rotate(-5deg);-webkit-box-shadow:0 6px 12px rgba(0,0,0,0.3);-moz-box-shadow:0 6px 12px rgba(0,0,0,0.3);box-shadow:0 6px 12px rgba(0,0,0,0.3);z-index:-1}#wysija_form_editor:after{left:auto;right:12px;-webkit-transform:skew(5deg) rotate(5deg);-moz-transform:skew(5deg) rotate(5deg);-ms-transform:skew(5deg) rotate(5deg);-o-transform:skew(5deg) rotate(5deg);transform:skew(5deg) rotate(5deg)}.wysija_form_block .wysija_warning{font-weight:bold;color:#900}.block_placeholder{margin:0;border:0 none}.block_placeholder.active{border:1px dashed #b4b4b4;margin:10px;display:block}.block_placeholder.hover{margin:10px;border:1px dashed #b4b4b4;background-color:#f5f5f5}.wysija_form_block{background-color:#fff;height:20px;border:0 none}.wysija_form_block.highlighted{border:1px solid #5897FB;padding:9px 17px}.wysija_form_block img{max-width:100%}.wysija_form_block p{margin:5px 0;word-wrap:break-word}.wysija_form_block p input.radio,.wysija_form_block p input.checkbox{margin:0 5px 0 0}#wysija_form_container{width:640px;margin:0}#wysija-add-field{float:none}#wysija_form_toolbar{position:absolute;width:295px}#wysija_form_toolbar .wysija_form_toolbar_tabs{border-bottom:1px solid #dfdfdf;line-height:0}#wysija_form_toolbar .add_custom_field{text-align:center;padding:15px 0 5px 0}#wysija_form_toolbar .wysija_form_toolbar_tabs li,#wysija_form_toolbar .wysija_form_toolbar_tabs a{margin:0;height:30px;line-height:30px;padding:0;display:-moz-inline-box;display:inline-block;*display:inline;*float:left;outline:0 none}#wysija_form_toolbar .wysija_form_toolbar_tabs a{outline:0 none;text-decoration:none;color:#a6a6a6}#wysija_form_toolbar .wysija_form_toolbar_tabs li{margin:0 0 1px 0}#wysija_form_toolbar .wysija_form_toolbar_tabs a{font-family:Georgia,"Times New Roman","Bitstream Charter",Times,serif;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #f5f5f5);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#F5F5F5', endColorstr='#F9F9F9');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#f5f5f5));border:1px solid #DFDFDF;-moz-border-radius:3px 3px 0 0;-webkit-border-radius:3px 3px 0 0;-khtml-border-radius:3px 3px 0 0;border-radius:3px 3px 0 0;box-shadow:0 1px 0 #FFFFFF inset;padding:0 7px}#wysija_form_toolbar .wysija_form_toolbar_tabs a:hover{background-color:#eee}#wysija_form_toolbar .wysija_form_toolbar_tabs a.selected{color:#000;border-bottom:0 none;background:#fcfcfc;filter:none;padding-bottom:1px}#wysija_form_toolbar .wysija_form_toolbar_tabs,#wysija_form_toolbar .wj_content,#wysija_form_toolbar .wj_images,#wysija_form_toolbar .wj_styles,#wysija_form_toolbar .wj_themes{position:relative;z-index:9998;margin:0}.wysija_form_widget{width:275px;height:25px;line-height:25px;z-index:9999 !important}#wysija_form_toolbar a.wysija_form_item,.wysija_form_widget{height:25px;line-height:25px;background-color:#F5F5F5;background-image:-moz-linear-gradient(center top, #f9f9f9, #ececec);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#f9f9f9', endColorstr='#ececec');background:-webkit-gradient(linear, left top, left bottom, from(#f9f9f9), to(#ececec));border:1px solid #DFDFDF;-moz-border-radius:3px;-webkit-border-radius:3px;-khtml-border-radius:3px;border-radius:3px;box-shadow:0 1px 0 #FFFFFF inset;display:block;font-size:12px;font-weight:bold;padding:0 0 0 7px;cursor:move;color:#222;text-shadow:0 1px 0 #FFFFFF}#wysija_form_toolbar a.wysija_form_item.disabled{cursor:pointer;color:#cccccc;pointer-events:none}.wysija_form_item_settings{position:absolute;right:35px;top:13px}.wysija_form_item_delete{position:absolute;right:15px;top:13px}.wj_content{background-color:#fcfcfc;border:1px solid #dfdfdf;padding:0 0 10px 0}.wj_content li{padding:10px 10px 0 10px;position:relative}.wj_content li.notice{font-style:italic;font-size:11px;margin:0 !important;border:0 none !important;background:none !important}.wysija_form_block{position:relative;margin:0;padding:10px 18px 10px 18px;display:inline-table;display:block;height:1%;margin:0;z-index:98}.wysija_form_block.dragging{z-index:99000;pointer-events:none}.wysija_form_block:after{content:".";display:block;height:0;clear:both;visibility:hidden}.wysija_form_block.hover{border:1px dashed #bbb;margin:0 0 0 0;padding:9px 17px 9px 17px}.wysija_form_block.static{background-color:#999}.wysija_form_block .wysija_controls{background-color:#dfdfdf;background-image:-moz-linear-gradient(center bottom, #bbb, #eee);filter:progid:DXImageTransform.Microsoft.gradient(startColorstr='#eeeeee', endColorstr='#bbbbbb');background:-webkit-gradient(linear, left bottom, left top, from(#bbb), to(#eee));-moz-border-radius:2px;-webkit-border-radius:2px;-khtml-border-radius:2px;border-radius:2px;border:1px solid #ccc;position:absolute;margin:0;padding:0;width:598px;height:20px;left:-1px;right:0;top:-22px}.wysija_form_block .wysija_controls li{float:left;width:20px;height:20px}.wysija_form_block .wysija_controls a{cursor:pointer;float:left;font-size:120%;font-weight:bold;height:20px;line-height:20px;text-align:center;width:20px;color:#000}.wysija_form_block .wysija_controls a.remove{margin:0 0 0 1px}.wysija_form_block .handle_container,.wysija_form_block .handle_container a{float:none;width:40px !important}.wysija_form_block .handle_container{left:280px;top:0;position:absolute}.wysija_controls a span,.wysija_gallery .wysija_tools a span,.wysija_image .wysija_tools a span,.wysija_text .wysija_tools a span,.wj_content a span{display:block;height:20px;width:20px}.wysija_controls span input{margin:2px 0 0 0;padding:0;color:transparent}.alignment-left span{background:url(../img/controls/icons.png) no-repeat 0 0}.alignment-left.active span,.alignment-left:hover span{background:url(../img/controls/icons.png) no-repeat 0 -20px}.alignment-center span{background:url(../img/controls/icons.png) no-repeat -20px 0}.alignment-center.active span,.alignment-center:hover span{background:url(../img/controls/icons.png) no-repeat -20px -20px}.alignment-right span{background:url(../img/controls/icons.png) no-repeat -40px 0}.alignment-right.active span,.alignment-right:hover span{background:url(../img/controls/icons.png) no-repeat -40px -20px}.add-link span{background:url(../img/controls/icons.png) no-repeat -60px 0}.add-link.active span,.add-link:hover span{background:url(../img/controls/icons.png) no-repeat -60px -20px}.remove-link span{background:url(../img/controls/icons.png) no-repeat -80px 0}.remove-link.active span,.remove-link:hover span{background:url(../img/controls/icons.png) no-repeat -80px -20px}.remove span,.delete span{background:url(../img/controls/icons.png) no-repeat -100px 0}.remove.active span,.remove:hover span,.delete.active span,.delete:hover span{background:url(../img/controls/icons.png) no-repeat -100px -20px}.handle span{background:url(../img/controls/grip-handle.png) no-repeat;cursor:move;width:40px !important}.duplicate span{background:url(../img/controls/icons.png) no-repeat -140px 0}.duplicate.active span,.duplicate:hover span{background:url(../img/controls/icons.png) no-repeat -140px -20px}.settings span{background:url(../img/controls/icons.png) no-repeat -160px 0}.settings.active span,.settings:hover span{background:url(../img/controls/icons.png) no-repeat -160px -20px}.icon-plus span{background:url(../img/controls/icons.png) no-repeat -200px 0}.icon-plus.active span,.icon-plus:hover span{background:url(../img/controls/icons.png) no-repeat -200px -20px}.icon-minus span{background:url(../img/controls/icons.png) no-repeat -220px 0}.icon-minus.active span,.icon-minus:hover span{background:url(../img/controls/icons.png) no-repeat -220p