Changeset 1904 for trunk/admin


Ignore:
Timestamp:
Mar 14, 2007, 12:01:16 AM (18 years ago)
Author:
rub
Message:

Fix bad default value for language on table user_info
Improve mail send (Undisclosed-recipients, switch language, ...)
Improve send an email to group members (Use Bcc, template, multi-language, ...) (But need more improvements)

Location:
trunk/admin
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/admin/cat_modify.php

    r1900 r1904  
    530530if (isset($_POST['submitEmail']))
    531531{
    532   $query = '
    533 SELECT
    534     user_id,
    535     '.$conf['user_fields']['email'].' AS email
    536   FROM '.USER_GROUP_TABLE.'
    537     INNER JOIN '.USERS_TABLE.' ON '.$conf['user_fields']['id'].' = user_id
    538   WHERE '.$conf['user_fields']['email'].' IS NOT NULL
    539     AND group_id = '.$_POST['group'].'
    540 ;';
    541   $result = pwg_query($query);
    542 
    543   while ($row = mysql_fetch_array($result))
    544   {
    545     pwg_mail(
    546       $row['email'],
    547       array(
    548         'content' => get_absolute_root_url().make_index_url(
     532  set_make_full_url();
     533
     534  /* TODO: if $category['representative_picture_id']
     535    is empty find child representative_picture_id */
     536  if (!empty($category['representative_picture_id']))
     537  {
     538    $query = '
     539SELECT id, file, path, tn_ext
     540  FROM '.IMAGES_TABLE.'
     541  WHERE id = '.$category['representative_picture_id'].'
     542;';
     543
     544    $result = pwg_query($query);
     545    if (mysql_num_rows($result) > 0)
     546    {
     547      $element = mysql_fetch_assoc($result);
     548
     549      $img_url  = '<a href="'.
     550                      make_picture_url(array(
     551                          'image_id' => $element['id'],
     552                          'image_file' => $element['file'],
     553                          'category' => $category
     554                        ))
     555                      .'"><img src="'.get_thumbnail_url($element).'"/></a>';
     556    }
     557  }
     558 
     559  if (!isset($img_url))
     560  {
     561    $img_url = '';
     562  }
     563
     564  // TODO Mettre un array pour traduction subjet
     565  pwg_mail_group(
     566    $_POST['group'],
     567    get_str_email_format(true), /* TODO add a checkbox in order to choose format*/
     568    $category['name'],
     569    'cat_group_info',
     570    array
     571    (
     572      'IMG_URL' => $img_url,
     573      'LINK' => make_index_url(
    549574          array(
    550575            'category' => array(
    551576              'id' => $category['id'],
    552577              'name' => $category['name'],
    553               'permalink' => $category['permalink'],
    554               )
    555             )
    556           ),
    557         'subject' => $category['name']
    558         )
    559       );
    560   }
     578              'permalink' => $category['permalink']
     579              ))),
     580      'CPL_CONTENT' => '' /* TODO Add text area to add complementary content */
     581    ),
     582    '' /* TODO Add listbox in order to choose Language selected */);
     583
     584  unset_make_full_url();
    561585
    562586  $query = '
  • trunk/admin/include/functions_notification_by_mail.inc.php

    r1900 r1904  
    193193  // Save $user, $lang_info and $lang arrays (include/user.inc.php has been executed)
    194194  $env_nbm['save_user'] = $user;
    195   $env_nbm['save_lang_info'] = $lang_info;
    196   $env_nbm['save_lang'] = $lang;
    197   // Last Language
    198   $env_nbm['last_language'] = $user['language'];
     195  // Save current language to stack, necessary because $user change during NBM
     196  switch_lang_to($user['language']);
    199197
    200198  $env_nbm['is_to_send_mail'] = $is_to_send_mail;
     
    228226  // Restore $user, $lang_info and $lang arrays (include/user.inc.php has been executed)
    229227  $user = $env_nbm['save_user'];
    230   $lang_info = $env_nbm['save_lang_info'];
    231   $lang = $env_nbm['save_lang'];
     228  // Restore current language to stack, necessary because $user change during NBM
     229  switch_lang_back();
    232230
    233231  if ($env_nbm['is_to_send_mail'])
     
    245243
    246244  unset($env_nbm['save_user']);
    247   unset($env_nbm['save_lang_info']);
    248   unset($env_nbm['save_lang']);
    249   unset($env_nbm['last_language']);
    250245  unset($env_nbm['is_to_send_mail']);
    251 
    252246}
    253247
     
    263257  $user = build_user( $nbm_user['user_id'], true );
    264258
    265   if ($env_nbm['last_language'] != $user['language'])
    266   {
    267     $env_nbm['last_language'] = $user['language'];
    268 
    269     // Re-Init language arrays
    270     $lang_info = array();
    271     $lang  = array();
    272 
    273     // language files
    274     include(get_language_filepath('common.lang.php'));
    275     // No test admin because script is checked admin (user selected no)
    276     // Translations are in admin file too
    277     include(get_language_filepath('admin.lang.php'));
    278     trigger_action('loading_lang');
    279     @include(get_language_filepath('local.lang.php'));
    280   }
    281  
     259  switch_lang_to($user['language']);
     260
    282261  if ($is_action_send)
    283262  {
     
    300279  global $env_nbm;
    301280
     281  switch_lang_back();
    302282  unset($env_nbm['mail_template']);
    303283}
Note: See TracChangeset for help on using the changeset viewer.