source: trunk/admin/notification_by_mail.php @ 5302

Last change on this file since 5302 was 5302, checked in by plg, 14 years ago

remove the \n from the language key and split into 2 separate strings to avoid
useless exceptions in translation analysis scripts.

  • Property svn:eol-style set to LF
File size: 23.8 KB
RevLine 
[1049]1<?php
2// +-----------------------------------------------------------------------+
[2297]3// | Piwigo - a PHP based picture gallery                                  |
4// +-----------------------------------------------------------------------+
[5196]5// | Copyright(C) 2008-2010 Piwigo Team                  http://piwigo.org |
[2297]6// | Copyright(C) 2003-2008 PhpWebGallery Team    http://phpwebgallery.net |
7// | Copyright(C) 2002-2003 Pierrick LE GALL   http://le-gall.net/pierrick |
8// +-----------------------------------------------------------------------+
9// | This program is free software; you can redistribute it and/or modify  |
10// | it under the terms of the GNU General Public License as published by  |
11// | the Free Software Foundation                                          |
12// |                                                                       |
13// | This program is distributed in the hope that it will be useful, but   |
14// | WITHOUT ANY WARRANTY; without even the implied warranty of            |
15// | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU      |
16// | General Public License for more details.                              |
17// |                                                                       |
18// | You should have received a copy of the GNU General Public License     |
19// | along with this program; if not, write to the Free Software           |
20// | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, |
21// | USA.                                                                  |
22// +-----------------------------------------------------------------------+
[1049]23
24// +-----------------------------------------------------------------------+
[1091]25// | include                                                               |
[1049]26// +-----------------------------------------------------------------------+
27
28if (!defined('PHPWG_ROOT_PATH'))
29{
30  die ("Hacking attempt!");
31}
[1072]32
[1049]33include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
[1105]34include_once(PHPWG_ROOT_PATH.'admin/include/functions_notification_by_mail.inc.php');
[2226]35include_once(PHPWG_ROOT_PATH.'admin/include/tabsheet.class.php');
[1049]36include_once(PHPWG_ROOT_PATH.'include/common.inc.php');
37include_once(PHPWG_ROOT_PATH.'include/functions_notification.inc.php');
38include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
39
40// +-----------------------------------------------------------------------+
[1072]41// | Check Access and exit when user status is not ok                      |
42// +-----------------------------------------------------------------------+
43check_status(ACCESS_ADMINISTRATOR);
44
45// +-----------------------------------------------------------------------+
[1156]46// | Initialization                                                        |
47// +-----------------------------------------------------------------------+
48$base_url = get_root_url().'admin.php';
[1177]49$must_repost = false;
[1156]50
51// +-----------------------------------------------------------------------+
[1091]52// | functions                                                             |
[1049]53// +-----------------------------------------------------------------------+
[1105]54
[1049]55/*
[1177]56 * Do timeout treatment in order to finish to send mails
[1156]57 *
58 * @param $post_keyname: key of check_key post array
[1177]59 * @param check_key_treated: array of check_key treated
[1156]60 * @return none
61 */
[1177]62function do_timeout_treatment($post_keyname, $check_key_treated = array())
[1156]63{
[1177]64  global $env_nbm, $base_url, $page, $must_repost;
[1156]65
66  if ($env_nbm['is_sendmail_timeout'])
67  {
68    if (isset($_POST[$post_keyname]))
69    {
70      $post_count = count($_POST[$post_keyname]);
71      $treated_count = count($check_key_treated);
72      if ($treated_count != 0)
73      {
74        $time_refresh = ceil((get_moment() - $env_nbm['start_time']) * $post_count / $treated_count);
75      }
76      else
77      {
[1177]78        $time_refresh = 0;
[1156]79      }
80      $_POST[$post_keyname] = array_diff($_POST[$post_keyname], $check_key_treated);
[1214]81
[1177]82      $must_repost = true;
[1784]83      array_push($page['errors'],
[5036]84        l10n_dec('Execution time is out, treatment must be continue [Estmated time: %d second].',
85                 'Execution time is out, treatment must be continue [Estmated time: %d seconds].',
[1784]86                  $time_refresh));
[1156]87    }
88  }
89
90}
91
92/*
[1105]93 * Get the authorized_status for each tab
94 * return corresponding status
[1115]95 */
[1105]96function get_tab_status($mode)
[1049]97{
[1105]98  $result = ACCESS_WEBMASTER;
99  switch ($mode)
[1049]100  {
[1105]101    case 'param':
[1115]102    case 'subscribe':
[1105]103      $result = ACCESS_WEBMASTER;
104      break;
[1115]105    case 'send':
[1105]106      $result = ACCESS_ADMINISTRATOR;
107      break;
108    default:
109      $result = ACCESS_WEBMASTER;
110      break;
[1049]111  }
[1105]112  return $result;
[1049]113}
114
[1115]115/*
[1105]116 * Inserting News users
[1049]117 */
[1105]118function insert_new_data_user_mail_notification()
[1049]119{
[1156]120  global $conf, $page, $env_nbm;
[1049]121
[1070]122  // Set null mail_address empty
[1049]123  $query = '
[1094]124update
[1070]125  '.USERS_TABLE.'
126set
[1115]127  '.$conf['user_fields']['email'].' = null
[1070]128where
[1115]129  trim('.$conf['user_fields']['email'].') = \'\';';
[1070]130  pwg_query($query);
131
[1105]132  // null mail_address are not selected in the list
[1070]133  $query = '
[1049]134select
[1115]135  u.'.$conf['user_fields']['id'].' as user_id,
136  u.'.$conf['user_fields']['username'].' as username,
137  u.'.$conf['user_fields']['email'].' as mail_address
[1049]138from
[1115]139  '.USERS_TABLE.' as u left join '.USER_MAIL_NOTIFICATION_TABLE.' as m on u.'.$conf['user_fields']['id'].' = m.user_id
[1049]140where
[1115]141  u.'.$conf['user_fields']['email'].' is not null and
[1074]142  m.user_id is null
[1049]143order by
[1115]144  user_id;';
[1049]145
146  $result = pwg_query($query);
147
[4325]148  if (pwg_db_num_rows($result) > 0)
[1049]149  {
150    $inserts = array();
[1105]151    $check_key_list = array();
[1049]152
[4325]153    while ($nbm_user = pwg_db_fetch_assoc($result))
[1049]154    {
[1105]155      // Calculate key
[1115]156      $nbm_user['check_key'] = find_available_check_key();
[1105]157
158      // Save key
[1115]159      array_push($check_key_list, $nbm_user['check_key']);
[1105]160
[1115]161      // Insert new nbm_users
[1105]162      array_push
163      (
[2089]164        $inserts,
[1105]165        array
166        (
[1115]167          'user_id' => $nbm_user['user_id'],
168          'check_key' => $nbm_user['check_key'],
[1105]169          'enabled' => 'false' // By default if false, set to true with specific functions
170        )
171      );
172
[1458]173      array_push
174      (
[2089]175        $page['infos'],
[1458]176        sprintf(
[5021]177          l10n('User %s [%s] added.'),
[4304]178          stripslashes($nbm_user['username']),
[1458]179          get_email_address_as_display_text($nbm_user['mail_address'])
180        )
181      );
[1049]182    }
183
[1115]184    // Insert new nbm_users
[1049]185    mass_inserts(USER_MAIL_NOTIFICATION_TABLE, array('user_id', 'check_key', 'enabled'), $inserts);
[1105]186    // Update field enabled with specific function
[1806]187    $check_key_treated = do_subscribe_unsubscribe_notification_by_mail
[1105]188    (
[1116]189      true,
190      $conf['nbm_default_value_user_enabled'],
[1105]191      $check_key_list
192    );
[1156]193
194     // On timeout simulate like tabsheet send
195    if ($env_nbm['is_sendmail_timeout'])
196    {
[1177]197      $quoted_check_key_list = quote_check_key_list(array_diff($check_key_list, $check_key_treated));
198      if (count($quoted_check_key_list) != 0 )
[1156]199      {
[1177]200        $query = 'delete from '.USER_MAIL_NOTIFICATION_TABLE.' where check_key in ('.implode(",", $quoted_check_key_list).');';
201        $result = pwg_query($query);
202
[5302]203        redirect($base_url.get_query_string_diff(array(), false), l10n('Processing treatment.')."\n".l10n('Please wait...'));
[1156]204      }
205    }
[1049]206  }
207}
208
209/*
[2140]210 * Apply global functions to mail content
211 * return customize mail content rendered
212 */
213function render_global_customize_mail_content($customize_mail_content)
214{
215  global $conf;
216
217  if ($conf['nbm_send_html_mail'] and !(strpos($customize_mail_content, '<') === 0))
218  {
219    // On HTML mail, detects if the content are HTML format.
220    // If it's plain text format, convert content to readable HTML
221    return nl2br(htmlspecialchars($customize_mail_content));
222  }
223  else
224  {
225    return $customize_mail_content;
226  }
227}
228
229/*
[1105]230 * Send mail for notification to all users
[1156]231 * Return list of "selected" users for 'list_to_send'
232 * Return list of "treated" check_key for 'send'
[1049]233 */
[1116]234function do_action_send_mail_notification($action = 'list_to_send', $check_key_list = array(), $customize_mail_content = '')
[1049]235{
[1116]236  global $conf, $page, $user, $lang_info, $lang, $env_nbm;
[1115]237  $return_list = array();
[2089]238
[1116]239  if (in_array($action, array('list_to_send', 'send')))
[1105]240  {
[4325]241    list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
[1105]242
[1115]243    $is_action_send = ($action == 'send');
[1049]244
[1115]245    // disabled and null mail_address are not selected in the list
246    $data_users = get_user_notifications('send', $check_key_list);
[1114]247
[1177]248    // List all if it's define on options or on timeout
249    $is_list_all_without_test = ($env_nbm['is_sendmail_timeout'] or $conf['nbm_list_all_enabled_users_to_send']);
250
[1116]251    // Check if exist news to list user or send mails
[1214]252    if ((!$is_list_all_without_test) or ($is_action_send))
[1105]253    {
[1116]254      if (count($data_users) > 0)
[1115]255      {
[1116]256        $datas = array();
[1114]257
[1818]258        if (!isset($customize_mail_content))
259        {
260          $customize_mail_content = $conf['nbm_complementary_mail_content'];
261        }
262
[2140]263        $customize_mail_content = 
264          trigger_event('nbm_render_global_customize_mail_content', $customize_mail_content);
[1818]265
[2140]266
[1156]267        // Prepare message after change language
268        if ($is_action_send)
269        {
[5021]270          $msg_break_timeout = l10n('Time to send mail is limited. Others mails are skipped.');
[1156]271        }
272        else
273        {
[5021]274          $msg_break_timeout = l10n('Prepared time for list of users to send mail is limited. Others users are not listed.');
[1156]275        }
276
[1116]277        // Begin nbm users environment
278        begin_users_env_nbm($is_action_send);
[1105]279
[1116]280        foreach ($data_users as $nbm_user)
[1115]281        {
[1156]282          if ((!$is_action_send) and check_sendmail_timeout())
[1115]283          {
[1116]284            // Stop fill list on 'list_to_send', if the quota is override
[1156]285            array_push($page['infos'], $msg_break_timeout);
[1116]286            break;
[1115]287          }
[1156]288          if (($is_action_send) and check_sendmail_timeout())
[1115]289          {
[1116]290            // Stop fill list on 'send', if the quota is override
[1156]291            array_push($page['errors'], $msg_break_timeout);
[1116]292            break;
[1115]293          }
294
[1116]295          // set env nbm user
[1809]296          set_user_on_env_nbm($nbm_user, $is_action_send);
[1116]297
298          if ($is_action_send)
[1115]299          {
[1784]300            set_make_full_url();
[1156]301            // Fill return list of "treated" check_key for 'send'
302            array_push($return_list, $nbm_user['check_key']);
[1115]303
304            if ($conf['nbm_send_detailed_content'])
305            {
[1784]306               $news = news($nbm_user['last_send'], $dbnow, false, $conf['nbm_send_html_mail']);
[1116]307               $exist_data = count($news) > 0;
[1115]308            }
309            else
310            {
[1116]311              $exist_data = news_exists($nbm_user['last_send'], $dbnow);
[1115]312            }
313
[1116]314            if ($exist_data)
[1115]315            {
[5021]316              $subject = '['.$conf['gallery_title'].']: '.l10n('New elements added');
[1116]317
[1784]318              // Assign current var for nbm mail
319              assign_vars_nbm_mail_content($nbm_user);
320
[1116]321              if (!is_null($nbm_user['last_send']))
[1784]322              {
[2285]323                $env_nbm['mail_template']->assign
[1784]324                (
325                  'content_new_elements_between',
326                  array
327                  (
[2089]328                    'DATE_BETWEEN_1' => $nbm_user['last_send'],
[1784]329                    'DATE_BETWEEN_2' => $dbnow,
330                  )
331                );
332              }
[1116]333              else
[1784]334              {
[2285]335                $env_nbm['mail_template']->assign
[1784]336                (
337                  'content_new_elements_single',
338                  array
339                  (
340                    'DATE_SINGLE' => $dbnow,
341                  )
342                );
343              }
[1116]344
345              if ($conf['nbm_send_detailed_content'])
346              {
[2285]347                $env_nbm['mail_template']->assign('global_new_lines', $news);
[1116]348              }
[1784]349
[2140]350              $nbm_user_customize_mail_content = 
351                trigger_event('nbm_render_user_customize_mail_content',
352                  $customize_mail_content, $nbm_user);
353              if (!empty($nbm_user_customize_mail_content))
[1116]354              {
[2285]355                $env_nbm['mail_template']->assign
[1784]356                (
[2285]357                  'custom_mail_content', $nbm_user_customize_mail_content
[1784]358                );
[1116]359              }
360
[1784]361              if ($conf['nbm_send_html_mail'] and $conf['nbm_send_recent_post_dates'])
362              {
[1871]363                $recent_post_dates = get_recent_post_dates_array(
364                  $conf['recent_post_dates']['NBM']);
[1784]365                foreach ($recent_post_dates as $date_detail)
366                {
[2285]367                  $env_nbm['mail_template']->append
[1784]368                  (
[2285]369                    'recent_posts',
[1784]370                    array
371                    (
372                      'TITLE' => get_title_recent_post_date($date_detail),
373                      'HTML_DATA' => get_html_description_recent_post_date($date_detail)
374                    )
375                  );
376                }
377              }
[1116]378
[2285]379              $env_nbm['mail_template']->assign
[1784]380              (
381                array
382                (
[2285]383                  'GOTO_GALLERY_TITLE' => $conf['gallery_title'],
384                  'GOTO_GALLERY_URL' => $conf['gallery_url'],
385                  'SEND_AS_NAME'      => $env_nbm['send_as_name'],
[1784]386                )
387              );
[1116]388
[1809]389              if (pwg_mail
390                  (
[4304]391                    format_email(stripslashes($nbm_user['username']), $nbm_user['mail_address']),
[1809]392                    array
393                    (
394                      'from' => $env_nbm['send_as_mail_formated'],
395                      'subject' => $subject,
396                      'email_format' => $env_nbm['email_format'],
397                      'content' => $env_nbm['mail_template']->parse('notification_by_mail', true),
398                      'content_format' => $env_nbm['email_format'],
399                      'theme' => $nbm_user['theme']
400                    )
401                  ))
[1116]402              {
403                inc_mail_sent_success($nbm_user);
404
405                $data = array('user_id' => $nbm_user['user_id'],
406                              'last_send' => $dbnow);
407                array_push($datas, $data);
408              }
409              else
410              {
411                inc_mail_sent_failed($nbm_user);
412              }
[1784]413
414              unset_make_full_url();
[1115]415            }
[1116]416          }
417          else
418          {
419            if (news_exists($nbm_user['last_send'], $dbnow))
[1115]420            {
[1156]421              // Fill return list of "selected" users for 'list_to_send'
[1116]422              array_push($return_list, $nbm_user);
[1115]423            }
424          }
[2089]425
[1784]426          // unset env nbm user
427          unset_user_on_env_nbm();
[1049]428        }
[1116]429
430        // Restore nbm environment
431        end_users_env_nbm();
432
433        if ($is_action_send)
[1115]434        {
[1116]435          mass_updates(
436            USER_MAIL_NOTIFICATION_TABLE,
437            array(
438              'primary' => array('user_id'),
439              'update' => array('last_send')
440             ),
441             $datas
442             );
443
444          display_counter_info();
[1115]445        }
[1049]446      }
[1116]447      else
[1105]448      {
[1116]449        if ($is_action_send)
[1115]450        {
[5021]451          array_push($page['errors'], l10n('No user to send notifications by mail.'));
[1115]452        }
[1105]453      }
[1115]454    }
455    else
456    {
[1116]457      // Quick List, don't check news
[1156]458      // Fill return list of "selected" users for 'list_to_send'
[1116]459      $return_list = $data_users;
[1049]460    }
461  }
[1156]462
463  // Return list of "selected" users for 'list_to_send'
464  // Return list of "treated" check_key for 'send'
[1115]465  return $return_list;
[1049]466}
467
468// +-----------------------------------------------------------------------+
[1091]469// | Main                                                                  |
[1049]470// +-----------------------------------------------------------------------+
[1091]471if (!isset($_GET['mode']))
472{
473  $page['mode'] = 'send';
474}
475else
476{
477  $page['mode'] = $_GET['mode'];
478}
[1049]479
480// +-----------------------------------------------------------------------+
[1105]481// | Check Access and exit when user status is not ok                      |
482// +-----------------------------------------------------------------------+
483check_status(get_tab_status($page['mode']));
484
[2140]485
[1105]486// +-----------------------------------------------------------------------+
[2140]487// | Add event handler                                                     |
488// +-----------------------------------------------------------------------+
489add_event_handler('nbm_render_global_customize_mail_content', 'render_global_customize_mail_content');
490trigger_action('nbm_event_handler_added');
491
492
493// +-----------------------------------------------------------------------+
[1105]494// | Insert new users with mails                                           |
495// +-----------------------------------------------------------------------+
496if (!isset($_POST) or (count($_POST) ==0))
497{
498  // No insert data in post mode
499  insert_new_data_user_mail_notification();
500}
501
502// +-----------------------------------------------------------------------+
503// | Treatment of tab post                                                 |
504// +-----------------------------------------------------------------------+
505switch ($page['mode'])
506{
507  case 'param' :
508  {
[1748]509    if (isset($_POST['param_submit']) and !is_adviser())
[1105]510    {
[1748]511      $updated_param_count = 0;
512      // Update param
513      $result = pwg_query('select param, value from '.CONFIG_TABLE.' where param like \'nbm\\_%\'');
[4325]514      while ($nbm_user = pwg_db_fetch_assoc($result))
[1105]515      {
[1115]516        if (isset($_POST[$nbm_user['param']]))
[1105]517        {
[1115]518          $value = $_POST[$nbm_user['param']];
[1105]519
520          $query = '
521update
[1748]522'.CONFIG_TABLE.'
523set
[1105]524  value = \''. str_replace("\'", "''", $value).'\'
525where
[1115]526  param = \''.$nbm_user['param'].'\';';
[1105]527          pwg_query($query);
528          $updated_param_count += 1;
529        }
530      }
[2089]531
[1784]532      array_push($page['infos'],
[5036]533        l10n_dec('%d parameter was updated.', '%d parameters were updated.',
[1784]534          $updated_param_count));
[1748]535
536      // Reload conf with new values
537      load_conf_from_db('param like \'nbm\\_%\'');
[1105]538    }
539  }
540  case 'subscribe' :
541  {
[1571]542    if (!is_adviser())
[1105]543    {
[1571]544      if (isset($_POST['falsify']) and isset($_POST['cat_true']))
545      {
[1806]546        $check_key_treated = unsubscribe_notification_by_mail(true, $_POST['cat_true']);
[1571]547        do_timeout_treatment('cat_true', $check_key_treated);
548      }
549      else
550      if (isset($_POST['trueify']) and isset($_POST['cat_false']))
551      {
[1806]552        $check_key_treated = subscribe_notification_by_mail(true, $_POST['cat_false']);
[1571]553        do_timeout_treatment('cat_false', $check_key_treated);
554      }
[1105]555    }
556    break;
557  }
558
559  case 'send' :
560  {
[1571]561    if (isset($_POST['send_submit']) and isset($_POST['send_selection']) and isset($_POST['send_customize_mail_content']) and !is_adviser())
[1105]562    {
[1521]563      $check_key_treated = do_action_send_mail_notification('send', $_POST['send_selection'], stripslashes($_POST['send_customize_mail_content']));
[1177]564      do_timeout_treatment('send_selection', $check_key_treated);
[1105]565    }
566  }
567}
568
569// +-----------------------------------------------------------------------+
[1091]570// | template initialization                                               |
[1049]571// +-----------------------------------------------------------------------+
[1105]572$template->set_filenames
573(
574  array
575  (
[2530]576    'double_select' => 'double_select.tpl',
577    'notification_by_mail'=>'notification_by_mail.tpl'
[1105]578  )
579);
[1049]580
[2286]581$template->assign
[1105]582(
583  array
584  (
[1156]585    'U_HELP' => add_url_params(get_root_url().'popuphelp.php', array('page' => 'notification_by_mail')),
[1091]586    'F_ACTION'=> $base_url.get_query_string_diff(array())
[1105]587  )
588);
[1091]589
[1105]590if (is_autorize_status(ACCESS_WEBMASTER))
591{
[2226]592  // TabSheet
593  $tabsheet = new tabsheet();
[1874]594  // TabSheet initialization
[5021]595  $tabsheet->add('param', l10n('Parameter'),
[2226]596    add_url_params($base_url.get_query_string_diff(array('mode', 'select')),
597        array('mode' => 'param')));
[5021]598  $tabsheet->add('subscribe', l10n('Subscribe'),
[2226]599    add_url_params($base_url.get_query_string_diff(array('mode', 'select')),
600      array('mode' => 'subscribe')));
[5021]601  $tabsheet->add('send', l10n('Send'),
[2226]602    add_url_params($base_url.get_query_string_diff(array('mode', 'select')),
603      array('mode' => 'send')));
604  // TabSheet selection
605  $tabsheet->select($page['mode']);
[1874]606  // Assign tabsheet to template
[2226]607  $tabsheet->assign();
[1105]608}
609
[1177]610if ($must_repost)
611{
612  // Get name of submit button
613  $repost_submit_name = '';
614  if (isset($_POST['falsify']))
615  {
616    $repost_submit_name = 'falsify';
617  }
618  elseif (isset($_POST['trueify']))
619  {
620    $repost_submit_name = 'trueify';
621  }
622  elseif (isset($_POST['send_submit']))
623  {
624    $repost_submit_name = 'send_submit';
625  }
626
[2286]627  $template->assign('REPOST_SUBMIT_NAME', $repost_submit_name);
[1177]628}
629
[1091]630switch ($page['mode'])
631{
632  case 'param' :
633  {
[2286]634    $template->assign(
[1091]635      $page['mode'],
636      array(
[2286]637        'SEND_HTML_MAIL' => $conf['nbm_send_html_mail'],
[1105]638        'SEND_MAIL_AS' => $conf['nbm_send_mail_as'],
[2286]639        'SEND_DETAILED_CONTENT' => $conf['nbm_send_detailed_content'],
[1784]640        'COMPLEMENTARY_MAIL_CONTENT' => $conf['nbm_complementary_mail_content'],
[2286]641        'SEND_RECENT_POST_DATES' => $conf['nbm_send_recent_post_dates'],
[1091]642        ));
643    break;
644  }
[1105]645
[1091]646  case 'subscribe' :
647  {
[2286]648    $template->assign( $page['mode'], true );
[1091]649
[2286]650    $template->assign(
[1091]651      array(
[5021]652        'L_CAT_OPTIONS_TRUE' => l10n('Subscribed'),
653        'L_CAT_OPTIONS_FALSE' => l10n('Unsubscribed')
[1091]654        )
655      );
656
[1115]657    $data_users = get_user_notifications('subscribe');
[2249]658   
[2262]659    $opt_true = array();
660    $opt_true_selected = array();
661    $opt_false = array();
662    $opt_false_selected = array();
[1115]663    foreach ($data_users as $nbm_user)
[1105]664    {
[2262]665      if (get_boolean($nbm_user['enabled']))
[2249]666      {
[4304]667        $opt_true[ $nbm_user['check_key'] ] = stripslashes($nbm_user['username']).'['.get_email_address_as_display_text($nbm_user['mail_address']).']';
[2262]668        if ((isset($_POST['falsify']) and isset($_POST['cat_true']) and in_array($nbm_user['check_key'], $_POST['cat_true'])))
[2249]669        {
670          $opt_true_selected[] = $nbm_user['check_key'];
671        }
672      }
673      else
674      {
[4304]675        $opt_false[ $nbm_user['check_key'] ] = stripslashes($nbm_user['username']).'['.get_email_address_as_display_text($nbm_user['mail_address']).']';
[2249]676        if (isset($_POST['trueify']) and isset($_POST['cat_false']) and in_array($nbm_user['check_key'], $_POST['cat_false']))
677        {
678          $opt_false_selected[] = $nbm_user['check_key'];
679        }
680      }
[1105]681    }
[2249]682    $template->assign( array(
683        'category_option_true'          => $opt_true,
684        'category_option_true_selected' => $opt_true_selected,
685        'category_option_false'         => $opt_false,
[2286]686        'category_option_false_selected' => $opt_false_selected,
[2249]687        )
688    );
[2286]689    $template->assign_var_from_handle('DOUBLE_SELECT', 'double_select');
[1091]690    break;
691  }
[1105]692
[1091]693  case 'send' :
694  {
[2286]695    $tpl_var = array('users'=> array() );
[1091]696
[1116]697    $data_users = do_action_send_mail_notification('list_to_send');
[1091]698
[2286]699    $tpl_var['CUSTOMIZE_MAIL_CONTENT'] = 
700      isset($_POST['send_customize_mail_content']) 
701        ? stripslashes($_POST['send_customize_mail_content']) 
702        : $conf['nbm_complementary_mail_content'];
703
704    if  (count($data_users))
[1105]705    {
[2286]706      foreach ($data_users as $nbm_user)
[1214]707      {
708        if (
709            (!$must_repost) or // Not timeout, normal treatment
710            (($must_repost) and in_array($nbm_user['check_key'], $_POST['send_selection']))  // Must be repost, show only user to send
711            )
712        {
[2286]713          $tpl_var['users'][] = 
[1105]714            array(
[1115]715              'ID' => $nbm_user['check_key'],
716              'CHECKED' =>  ( // not check if not selected,  on init select<all
717                              isset($_POST['send_selection']) and // not init
[1177]718                              !in_array($nbm_user['check_key'], $_POST['send_selection']) // not selected
[1115]719                            )   ? '' : 'checked="checked"',
[4304]720              'USERNAME'=> stripslashes($nbm_user['username']),
[1458]721              'EMAIL' => get_email_address_as_display_text($nbm_user['mail_address']),
[1115]722              'LAST_SEND'=> $nbm_user['last_send']
[2286]723              );
[1214]724        }
725      }
[1105]726    }
[2286]727    $template->assign($page['mode'], $tpl_var);
[1091]728    break;
729  }
730}
731
[1049]732// +-----------------------------------------------------------------------+
[1091]733// | Sending html code                                                     |
734// +-----------------------------------------------------------------------+
735$template->assign_var_from_handle('ADMIN_CONTENT', 'notification_by_mail');
736
[5302]737?>
Note: See TracBrowser for help on using the repository browser.