1 | <?php |
---|
2 | // +-----------------------------------------------------------------------+ |
---|
3 | // | PhpWebGallery - a PHP based picture gallery | |
---|
4 | // | Copyright (C) 2002-2003 Pierrick LE GALL - pierrick@phpwebgallery.net | |
---|
5 | // | Copyright (C) 2003-2006 PhpWebGallery Team - http://phpwebgallery.net | |
---|
6 | // | Copyright (C) 2006 Ruben ARNAUD - team@phpwebgallery.net | |
---|
7 | // +-----------------------------------------------------------------------+ |
---|
8 | // | branch : BSF (Best So Far) |
---|
9 | // | file : $RCSfile$ |
---|
10 | // | last update : $Date: 2006-04-12 22:49:42 +0000 (Wed, 12 Apr 2006) $ |
---|
11 | // | last modifier : $Author: rub $ |
---|
12 | // | revision : $Revision: 1156 $ |
---|
13 | // +-----------------------------------------------------------------------+ |
---|
14 | // | This program is free software; you can redistribute it and/or modify | |
---|
15 | // | it under the terms of the GNU General Public License as published by | |
---|
16 | // | the Free Software Foundation | |
---|
17 | // | | |
---|
18 | // | This program is distributed in the hope that it will be useful, but | |
---|
19 | // | WITHOUT ANY WARRANTY; without even the implied warranty of | |
---|
20 | // | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
---|
21 | // | General Public License for more details. | |
---|
22 | // | | |
---|
23 | // | You should have received a copy of the GNU General Public License | |
---|
24 | // | along with this program; if not, write to the Free Software | |
---|
25 | // | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, | |
---|
26 | // | USA. | |
---|
27 | // +-----------------------------------------------------------------------+ |
---|
28 | |
---|
29 | // +-----------------------------------------------------------------------+ |
---|
30 | // | include | |
---|
31 | // +-----------------------------------------------------------------------+ |
---|
32 | |
---|
33 | if (!defined('PHPWG_ROOT_PATH')) |
---|
34 | { |
---|
35 | die ("Hacking attempt!"); |
---|
36 | } |
---|
37 | |
---|
38 | include_once(PHPWG_ROOT_PATH.'admin/include/functions.php'); |
---|
39 | include_once(PHPWG_ROOT_PATH.'admin/include/functions_notification_by_mail.inc.php'); |
---|
40 | include_once(PHPWG_ROOT_PATH.'include/common.inc.php'); |
---|
41 | include_once(PHPWG_ROOT_PATH.'include/functions_notification.inc.php'); |
---|
42 | include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php'); |
---|
43 | |
---|
44 | // +-----------------------------------------------------------------------+ |
---|
45 | // | Check Access and exit when user status is not ok | |
---|
46 | // +-----------------------------------------------------------------------+ |
---|
47 | check_status(ACCESS_ADMINISTRATOR); |
---|
48 | |
---|
49 | // +-----------------------------------------------------------------------+ |
---|
50 | // | Initialization | |
---|
51 | // +-----------------------------------------------------------------------+ |
---|
52 | $base_url = get_root_url().'admin.php'; |
---|
53 | |
---|
54 | // +-----------------------------------------------------------------------+ |
---|
55 | // | functions | |
---|
56 | // +-----------------------------------------------------------------------+ |
---|
57 | |
---|
58 | /* |
---|
59 | * Do background treatmetn in order to finish to send mails |
---|
60 | * |
---|
61 | * @param $post_keyname: key of check_key post array |
---|
62 | * @param check_key_treated:array of check_key treated |
---|
63 | * @return none |
---|
64 | */ |
---|
65 | function do_background_treatment($post_keyname, $check_key_treated = array()) |
---|
66 | { |
---|
67 | global $env_nbm, $base_url; |
---|
68 | |
---|
69 | if ($env_nbm['is_sendmail_timeout']) |
---|
70 | { |
---|
71 | if (isset($_POST[$post_keyname])) |
---|
72 | { |
---|
73 | $post_count = count($_POST[$post_keyname]); |
---|
74 | $treated_count = count($check_key_treated); |
---|
75 | if ($treated_count != 0) |
---|
76 | { |
---|
77 | $time_refresh = ceil((get_moment() - $env_nbm['start_time']) * $post_count / $treated_count); |
---|
78 | } |
---|
79 | else |
---|
80 | { |
---|
81 | $time_refresh = 10; |
---|
82 | } |
---|
83 | $_POST[$post_keyname] = array_diff($_POST[$post_keyname], $check_key_treated); |
---|
84 | re_post_http($base_url.get_query_string_diff(array()), sprintf(l10n('nbm_background_treatment_redirect'), $time_refresh) , $time_refresh); |
---|
85 | } |
---|
86 | } |
---|
87 | |
---|
88 | } |
---|
89 | |
---|
90 | /* |
---|
91 | * Get the authorized_status for each tab |
---|
92 | * return corresponding status |
---|
93 | */ |
---|
94 | function get_tab_status($mode) |
---|
95 | { |
---|
96 | $result = ACCESS_WEBMASTER; |
---|
97 | switch ($mode) |
---|
98 | { |
---|
99 | case 'param': |
---|
100 | case 'subscribe': |
---|
101 | $result = ACCESS_WEBMASTER; |
---|
102 | break; |
---|
103 | case 'send': |
---|
104 | $result = ACCESS_ADMINISTRATOR; |
---|
105 | break; |
---|
106 | default: |
---|
107 | $result = ACCESS_WEBMASTER; |
---|
108 | break; |
---|
109 | } |
---|
110 | return $result; |
---|
111 | } |
---|
112 | |
---|
113 | /* |
---|
114 | * Inserting News users |
---|
115 | */ |
---|
116 | function insert_new_data_user_mail_notification() |
---|
117 | { |
---|
118 | global $conf, $page, $env_nbm; |
---|
119 | |
---|
120 | // Set null mail_address empty |
---|
121 | $query = ' |
---|
122 | update |
---|
123 | '.USERS_TABLE.' |
---|
124 | set |
---|
125 | '.$conf['user_fields']['email'].' = null |
---|
126 | where |
---|
127 | trim('.$conf['user_fields']['email'].') = \'\';'; |
---|
128 | pwg_query($query); |
---|
129 | |
---|
130 | // null mail_address are not selected in the list |
---|
131 | $query = ' |
---|
132 | select |
---|
133 | u.'.$conf['user_fields']['id'].' as user_id, |
---|
134 | u.'.$conf['user_fields']['username'].' as username, |
---|
135 | u.'.$conf['user_fields']['email'].' as mail_address |
---|
136 | from |
---|
137 | '.USERS_TABLE.' as u left join '.USER_MAIL_NOTIFICATION_TABLE.' as m on u.'.$conf['user_fields']['id'].' = m.user_id |
---|
138 | where |
---|
139 | u.'.$conf['user_fields']['email'].' is not null and |
---|
140 | m.user_id is null |
---|
141 | order by |
---|
142 | user_id;'; |
---|
143 | |
---|
144 | $result = pwg_query($query); |
---|
145 | |
---|
146 | if (mysql_num_rows($result) > 0) |
---|
147 | { |
---|
148 | $inserts = array(); |
---|
149 | $check_key_list = array(); |
---|
150 | |
---|
151 | while ($nbm_user = mysql_fetch_array($result)) |
---|
152 | { |
---|
153 | // Calculate key |
---|
154 | $nbm_user['check_key'] = find_available_check_key(); |
---|
155 | |
---|
156 | // Save key |
---|
157 | array_push($check_key_list, $nbm_user['check_key']); |
---|
158 | |
---|
159 | // Insert new nbm_users |
---|
160 | array_push |
---|
161 | ( |
---|
162 | $inserts, |
---|
163 | array |
---|
164 | ( |
---|
165 | 'user_id' => $nbm_user['user_id'], |
---|
166 | 'check_key' => $nbm_user['check_key'], |
---|
167 | 'enabled' => 'false' // By default if false, set to true with specific functions |
---|
168 | ) |
---|
169 | ); |
---|
170 | |
---|
171 | array_push($page['infos'], sprintf(l10n('nbm_user_x_added'), $nbm_user['username'], $nbm_user['mail_address'])); |
---|
172 | } |
---|
173 | |
---|
174 | // Insert new nbm_users |
---|
175 | mass_inserts(USER_MAIL_NOTIFICATION_TABLE, array('user_id', 'check_key', 'enabled'), $inserts); |
---|
176 | // Update field enabled with specific function |
---|
177 | $check_key_treated = do_subscribe_unsubcribe_notification_by_mail |
---|
178 | ( |
---|
179 | true, |
---|
180 | $conf['nbm_default_value_user_enabled'], |
---|
181 | $check_key_list |
---|
182 | ); |
---|
183 | |
---|
184 | // On timeout simulate like tabsheet send |
---|
185 | if ($env_nbm['is_sendmail_timeout']) |
---|
186 | { |
---|
187 | if ($conf['nbm_default_value_user_enabled']) |
---|
188 | { |
---|
189 | $_POST['trueify'] = 'trueify'; |
---|
190 | $_POST['cat_false'] = $check_key_list; |
---|
191 | do_background_treatment('cat_false', $check_key_treated); |
---|
192 | } |
---|
193 | else |
---|
194 | { |
---|
195 | $_POST['falsify'] = 'falsify'; |
---|
196 | $_POST['cat_true'] = $check_key_list; |
---|
197 | do_background_treatment('cat_true', $check_key_treated); |
---|
198 | } |
---|
199 | } |
---|
200 | } |
---|
201 | } |
---|
202 | |
---|
203 | /* |
---|
204 | * Send mail for notification to all users |
---|
205 | * Return list of "selected" users for 'list_to_send' |
---|
206 | * Return list of "treated" check_key for 'send' |
---|
207 | */ |
---|
208 | function do_action_send_mail_notification($action = 'list_to_send', $check_key_list = array(), $customize_mail_content = '') |
---|
209 | { |
---|
210 | global $conf, $page, $user, $lang_info, $lang, $env_nbm; |
---|
211 | $return_list = array(); |
---|
212 | |
---|
213 | if (in_array($action, array('list_to_send', 'send'))) |
---|
214 | { |
---|
215 | list($dbnow) = mysql_fetch_row(pwg_query('SELECT NOW();')); |
---|
216 | |
---|
217 | $is_action_send = ($action == 'send'); |
---|
218 | |
---|
219 | if (isset($customize_mail_content)) |
---|
220 | { |
---|
221 | $customize_mail_content = $conf['nbm_complementary_mail_content']; |
---|
222 | } |
---|
223 | |
---|
224 | // disabled and null mail_address are not selected in the list |
---|
225 | $data_users = get_user_notifications('send', $check_key_list); |
---|
226 | |
---|
227 | // Check if exist news to list user or send mails |
---|
228 | if (($conf['nbm_list_all_enabled_users_to_send'] == false) or ($is_action_send)) |
---|
229 | { |
---|
230 | if (count($data_users) > 0) |
---|
231 | { |
---|
232 | $datas = array(); |
---|
233 | |
---|
234 | // Prepare message after change language |
---|
235 | if ($is_action_send) |
---|
236 | { |
---|
237 | $msg_break_timeout = l10n('nbm_nbm_break_timeout_send_mail'); |
---|
238 | } |
---|
239 | else |
---|
240 | { |
---|
241 | $msg_break_timeout = l10n('nbm_break_timeout_list_user'); |
---|
242 | } |
---|
243 | |
---|
244 | // Begin nbm users environment |
---|
245 | begin_users_env_nbm($is_action_send); |
---|
246 | |
---|
247 | foreach ($data_users as $nbm_user) |
---|
248 | { |
---|
249 | if ((!$is_action_send) and check_sendmail_timeout()) |
---|
250 | { |
---|
251 | // Stop fill list on 'list_to_send', if the quota is override |
---|
252 | array_push($page['infos'], $msg_break_timeout); |
---|
253 | break; |
---|
254 | } |
---|
255 | if (($is_action_send) and check_sendmail_timeout()) |
---|
256 | { |
---|
257 | // Stop fill list on 'send', if the quota is override |
---|
258 | array_push($page['errors'], $msg_break_timeout); |
---|
259 | break; |
---|
260 | } |
---|
261 | |
---|
262 | // set env nbm user |
---|
263 | set_user_id_on_env_nbm($nbm_user['user_id']); |
---|
264 | |
---|
265 | if ($is_action_send) |
---|
266 | { |
---|
267 | // Fill return list of "treated" check_key for 'send' |
---|
268 | array_push($return_list, $nbm_user['check_key']); |
---|
269 | $message = ''; |
---|
270 | |
---|
271 | if ($conf['nbm_send_detailed_content']) |
---|
272 | { |
---|
273 | $news = news($nbm_user['last_send'], $dbnow); |
---|
274 | $exist_data = count($news) > 0; |
---|
275 | } |
---|
276 | else |
---|
277 | { |
---|
278 | $exist_data = news_exists($nbm_user['last_send'], $dbnow); |
---|
279 | } |
---|
280 | |
---|
281 | if ($exist_data) |
---|
282 | { |
---|
283 | $subject = '['.$conf['gallery_title'].']: '.l10n('nbm_object_news'); |
---|
284 | $message .= sprintf(l10n('nbm_content_hello'), $nbm_user['username']).",\n\n"; |
---|
285 | |
---|
286 | if (!is_null($nbm_user['last_send'])) |
---|
287 | $message .= sprintf(l10n('nbm_content_new_elements_between'), $nbm_user['last_send'], $dbnow); |
---|
288 | else |
---|
289 | $message .= sprintf(l10n('nbm_content_new_elements'), $dbnow); |
---|
290 | |
---|
291 | if ($conf['nbm_send_detailed_content']) |
---|
292 | { |
---|
293 | $message .= ":\n"; |
---|
294 | |
---|
295 | foreach ($news as $line) |
---|
296 | { |
---|
297 | $message .= ' o '.$line."\n"; |
---|
298 | } |
---|
299 | $message .= "\n"; |
---|
300 | } |
---|
301 | else |
---|
302 | { |
---|
303 | $message .= ".\n"; |
---|
304 | } |
---|
305 | |
---|
306 | $message .= sprintf(l10n('nbm_content_goto'), $conf['gallery_title'], $conf['gallery_url'])."\n\n"; |
---|
307 | $message .= $customize_mail_content."\n\n"; |
---|
308 | $message .= l10n('nbm_content_byebye')."\n ".$env_nbm['send_as_name']."\n\n"; |
---|
309 | |
---|
310 | $message .= get_mail_content_subscribe_unsubcribe($nbm_user); |
---|
311 | |
---|
312 | if (pwg_mail(format_email($nbm_user['username'], $nbm_user['mail_address']), $env_nbm['send_as_mail_formated'], $subject, $message)) |
---|
313 | { |
---|
314 | inc_mail_sent_success($nbm_user); |
---|
315 | |
---|
316 | $data = array('user_id' => $nbm_user['user_id'], |
---|
317 | 'last_send' => $dbnow); |
---|
318 | array_push($datas, $data); |
---|
319 | } |
---|
320 | else |
---|
321 | { |
---|
322 | inc_mail_sent_failed($nbm_user); |
---|
323 | } |
---|
324 | } |
---|
325 | } |
---|
326 | else |
---|
327 | { |
---|
328 | if (news_exists($nbm_user['last_send'], $dbnow)) |
---|
329 | { |
---|
330 | // Fill return list of "selected" users for 'list_to_send' |
---|
331 | array_push($return_list, $nbm_user); |
---|
332 | } |
---|
333 | } |
---|
334 | } |
---|
335 | |
---|
336 | // Restore nbm environment |
---|
337 | end_users_env_nbm(); |
---|
338 | |
---|
339 | if ($is_action_send) |
---|
340 | { |
---|
341 | mass_updates( |
---|
342 | USER_MAIL_NOTIFICATION_TABLE, |
---|
343 | array( |
---|
344 | 'primary' => array('user_id'), |
---|
345 | 'update' => array('last_send') |
---|
346 | ), |
---|
347 | $datas |
---|
348 | ); |
---|
349 | |
---|
350 | display_counter_info(); |
---|
351 | } |
---|
352 | } |
---|
353 | else |
---|
354 | { |
---|
355 | if ($is_action_send) |
---|
356 | { |
---|
357 | array_push($page['errors'], l10n('nbm_no_user_to send_notifications_by_mail')); |
---|
358 | } |
---|
359 | } |
---|
360 | } |
---|
361 | else |
---|
362 | { |
---|
363 | // Quick List, don't check news |
---|
364 | // Fill return list of "selected" users for 'list_to_send' |
---|
365 | $return_list = $data_users; |
---|
366 | } |
---|
367 | } |
---|
368 | |
---|
369 | // Return list of "selected" users for 'list_to_send' |
---|
370 | // Return list of "treated" check_key for 'send' |
---|
371 | return $return_list; |
---|
372 | } |
---|
373 | |
---|
374 | // +-----------------------------------------------------------------------+ |
---|
375 | // | Main | |
---|
376 | // +-----------------------------------------------------------------------+ |
---|
377 | if (!isset($_GET['mode'])) |
---|
378 | { |
---|
379 | $page['mode'] = 'send'; |
---|
380 | } |
---|
381 | else |
---|
382 | { |
---|
383 | $page['mode'] = $_GET['mode']; |
---|
384 | } |
---|
385 | |
---|
386 | // +-----------------------------------------------------------------------+ |
---|
387 | // | Check Access and exit when user status is not ok | |
---|
388 | // +-----------------------------------------------------------------------+ |
---|
389 | check_status(get_tab_status($page['mode'])); |
---|
390 | |
---|
391 | // +-----------------------------------------------------------------------+ |
---|
392 | // | Insert new users with mails | |
---|
393 | // +-----------------------------------------------------------------------+ |
---|
394 | if (!isset($_POST) or (count($_POST) ==0)) |
---|
395 | { |
---|
396 | // No insert data in post mode |
---|
397 | insert_new_data_user_mail_notification(); |
---|
398 | } |
---|
399 | |
---|
400 | // +-----------------------------------------------------------------------+ |
---|
401 | // | Treatment of tab post | |
---|
402 | // +-----------------------------------------------------------------------+ |
---|
403 | switch ($page['mode']) |
---|
404 | { |
---|
405 | case 'param' : |
---|
406 | { |
---|
407 | $updated_param_count = 0; |
---|
408 | // Update param |
---|
409 | $result = pwg_query('select param, value from '.CONFIG_TABLE.' where param like \'nbm\\_%\''); |
---|
410 | while ($nbm_user = mysql_fetch_array($result)) |
---|
411 | { |
---|
412 | if (isset($_POST['param_submit'])) |
---|
413 | { |
---|
414 | if (isset($_POST[$nbm_user['param']])) |
---|
415 | { |
---|
416 | $value = $_POST[$nbm_user['param']]; |
---|
417 | |
---|
418 | $query = ' |
---|
419 | update |
---|
420 | '.CONFIG_TABLE.' |
---|
421 | set |
---|
422 | value = \''. str_replace("\'", "''", $value).'\' |
---|
423 | where |
---|
424 | param = \''.$nbm_user['param'].'\';'; |
---|
425 | pwg_query($query); |
---|
426 | $updated_param_count += 1; |
---|
427 | } |
---|
428 | } |
---|
429 | |
---|
430 | $conf[$nbm_user['param']] = $nbm_user['value']; |
---|
431 | |
---|
432 | // if the parameter is present in $_POST array (if a form is submited), we |
---|
433 | // override it with the submited value |
---|
434 | if (isset($_POST[$nbm_user['param']])) |
---|
435 | { |
---|
436 | $conf[$nbm_user['param']] = stripslashes($_POST[$nbm_user['param']]); |
---|
437 | } |
---|
438 | |
---|
439 | // If the field is true or false, the variable is transformed into a |
---|
440 | // boolean value. |
---|
441 | if ($conf[$nbm_user['param']] == 'true' or $conf[$nbm_user['param']] == 'false') |
---|
442 | { |
---|
443 | $conf[$nbm_user['param']] = get_boolean($conf[$nbm_user['param']]); |
---|
444 | } |
---|
445 | } |
---|
446 | |
---|
447 | if ($updated_param_count != 0) |
---|
448 | { |
---|
449 | array_push($page['infos'], sprintf(l10n('nbm_updated_param_count'), $updated_param_count)); |
---|
450 | } |
---|
451 | } |
---|
452 | case 'subscribe' : |
---|
453 | { |
---|
454 | if (isset($_POST['falsify']) and isset($_POST['cat_true'])) |
---|
455 | { |
---|
456 | $check_key_treated = unsubcribe_notification_by_mail(true, $_POST['cat_true']); |
---|
457 | do_background_treatment('cat_true', $check_key_treated); |
---|
458 | } |
---|
459 | else |
---|
460 | if (isset($_POST['trueify']) and isset($_POST['cat_false'])) |
---|
461 | { |
---|
462 | $check_key_treated = subcribe_notification_by_mail(true, $_POST['cat_false']); |
---|
463 | do_background_treatment('cat_false', $check_key_treated); |
---|
464 | } |
---|
465 | break; |
---|
466 | } |
---|
467 | |
---|
468 | case 'send' : |
---|
469 | { |
---|
470 | if (isset($_POST['send_submit']) and isset($_POST['send_selection']) and isset($_POST['send_customize_mail_content'])) |
---|
471 | { |
---|
472 | $check_key_treated = do_action_send_mail_notification('send', $_POST['send_selection'], $_POST['send_customize_mail_content']); |
---|
473 | do_background_treatment('send_selection', $check_key_treated); |
---|
474 | } |
---|
475 | } |
---|
476 | } |
---|
477 | |
---|
478 | // +-----------------------------------------------------------------------+ |
---|
479 | // | template initialization | |
---|
480 | // +-----------------------------------------------------------------------+ |
---|
481 | $template->set_filenames |
---|
482 | ( |
---|
483 | array |
---|
484 | ( |
---|
485 | 'double_select' => 'admin/double_select.tpl', |
---|
486 | 'notification_by_mail'=>'admin/notification_by_mail.tpl' |
---|
487 | ) |
---|
488 | ); |
---|
489 | |
---|
490 | $template->assign_vars |
---|
491 | ( |
---|
492 | array |
---|
493 | ( |
---|
494 | 'U_TABSHEET_TITLE' => l10n('nbm_'.$page['mode'].'_mode'), |
---|
495 | 'U_HELP' => add_url_params(get_root_url().'popuphelp.php', array('page' => 'notification_by_mail')), |
---|
496 | 'F_ACTION'=> $base_url.get_query_string_diff(array()) |
---|
497 | ) |
---|
498 | ); |
---|
499 | |
---|
500 | if (is_autorize_status(ACCESS_WEBMASTER)) |
---|
501 | { |
---|
502 | $template->assign_block_vars |
---|
503 | ( |
---|
504 | 'header_link', |
---|
505 | array |
---|
506 | ( |
---|
507 | 'PARAM_MODE' => add_url_params($base_url.get_query_string_diff(array('mode', 'select')), array('mode' => 'param')), |
---|
508 | 'SUBSCRIBE_MODE' => add_url_params($base_url.get_query_string_diff(array('mode', 'select')), array('mode' => 'subscribe')), |
---|
509 | 'SEND_MODE' => add_url_params($base_url.get_query_string_diff(array('mode', 'select')), array('mode' => 'send')) |
---|
510 | ) |
---|
511 | ); |
---|
512 | } |
---|
513 | |
---|
514 | switch ($page['mode']) |
---|
515 | { |
---|
516 | case 'param' : |
---|
517 | { |
---|
518 | $template->assign_block_vars( |
---|
519 | $page['mode'], |
---|
520 | array( |
---|
521 | 'SEND_MAIL_AS' => $conf['nbm_send_mail_as'], |
---|
522 | 'SEND_DETAILED_CONTENT_YES' => ($conf['nbm_send_detailed_content'] ? 'checked="checked"' : ''), |
---|
523 | 'SEND_DETAILED_CONTENT_NO' => (!$conf['nbm_send_detailed_content'] ? 'checked="checked"' : ''), |
---|
524 | 'COMPLEMENTARY_MAIL_CONTENT' => $conf['nbm_complementary_mail_content'] |
---|
525 | )); |
---|
526 | break; |
---|
527 | } |
---|
528 | |
---|
529 | case 'subscribe' : |
---|
530 | { |
---|
531 | $template->assign_block_vars( |
---|
532 | $page['mode'], |
---|
533 | array( |
---|
534 | )); |
---|
535 | |
---|
536 | $template->assign_vars( |
---|
537 | array( |
---|
538 | 'L_CAT_OPTIONS_TRUE' => l10n('nbm_subscribe_col'), |
---|
539 | 'L_CAT_OPTIONS_FALSE' => l10n('nbm_unsubscribe_col') |
---|
540 | ) |
---|
541 | ); |
---|
542 | |
---|
543 | $data_users = get_user_notifications('subscribe'); |
---|
544 | foreach ($data_users as $nbm_user) |
---|
545 | { |
---|
546 | $template->assign_block_vars( |
---|
547 | (get_boolean($nbm_user['enabled']) ? 'category_option_true' : 'category_option_false'), |
---|
548 | array('SELECTED' => ( // Keep selected user where enabled are not changed when change has been notify |
---|
549 | get_boolean($nbm_user['enabled']) ? (isset($_POST['falsify']) and isset($_POST['cat_true']) and in_array($nbm_user['check_key'], $_POST['cat_true'])) |
---|
550 | : (isset($_POST['trueify']) and isset($_POST['cat_false']) and in_array($nbm_user['check_key'], $_POST['cat_false'])) |
---|
551 | ) ? 'selected="selected"' : '', |
---|
552 | 'VALUE' => $nbm_user['check_key'], |
---|
553 | 'OPTION' => $nbm_user['username'].'['.$nbm_user['mail_address'].']' |
---|
554 | )); |
---|
555 | } |
---|
556 | |
---|
557 | break; |
---|
558 | } |
---|
559 | |
---|
560 | case 'send' : |
---|
561 | { |
---|
562 | $template->assign_block_vars($page['mode'], array()); |
---|
563 | |
---|
564 | $data_users = do_action_send_mail_notification('list_to_send'); |
---|
565 | |
---|
566 | if (count($data_users) == 0) |
---|
567 | { |
---|
568 | $template->assign_block_vars($page['mode'].'.send_empty', array()); |
---|
569 | } |
---|
570 | else |
---|
571 | { |
---|
572 | $template->assign_block_vars( |
---|
573 | $page['mode'].'.send_data', |
---|
574 | array( |
---|
575 | 'CUSTOMIZE_MAIL_CONTENT' => isset($_POST['send_customize_mail_content']) ? $_POST['send_customize_mail_content'] : $conf['nbm_complementary_mail_content'] |
---|
576 | )); |
---|
577 | |
---|
578 | foreach ($data_users as $num => $nbm_user) |
---|
579 | $template->assign_block_vars( |
---|
580 | $page['mode'].'.send_data.user_send_mail', |
---|
581 | array( |
---|
582 | 'CLASS' => ($num % 2 == 1) ? 'nbm_user2' : 'nbm_user1', |
---|
583 | 'ID' => $nbm_user['check_key'], |
---|
584 | 'CHECKED' => ( // not check if not selected, on init select<all |
---|
585 | isset($_POST['send_selection']) and // not init |
---|
586 | !in_array($nbm_user['check_key'], $_POST['send_selection']) // not selected |
---|
587 | ) ? '' : 'checked="checked"', |
---|
588 | 'USERNAME'=> $nbm_user['username'], |
---|
589 | 'EMAIL' => $nbm_user['mail_address'], |
---|
590 | 'LAST_SEND'=> $nbm_user['last_send'] |
---|
591 | )); |
---|
592 | } |
---|
593 | |
---|
594 | break; |
---|
595 | } |
---|
596 | } |
---|
597 | |
---|
598 | // +-----------------------------------------------------------------------+ |
---|
599 | // | Sending html code | |
---|
600 | // +-----------------------------------------------------------------------+ |
---|
601 | $template->assign_var_from_handle('DOUBLE_SELECT', 'double_select'); |
---|
602 | $template->assign_var_from_handle('ADMIN_CONTENT', 'notification_by_mail'); |
---|
603 | |
---|
604 | ?> |
---|