Changeset 26914


Ignore:
Timestamp:
Jan 22, 2014, 11:35:07 PM (10 years ago)
Author:
Eric
Message:

Improve confirmation email sending - More accurate when users or admins are set to confirm registrations

Location:
extensions/UserAdvManager/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserAdvManager/trunk/admin/UAM_admin.php

    r25745 r26914  
    169169    $conf_UAM_ConfirmMail = unserialize($conf['UserAdvManager_ConfirmMail']);
    170170   
    171     if (((isset($conf_UAM['1']) and ($conf_UAM['1'] == 'false' or $conf_UAM['1'] == 'local')) or ($_POST['UAM_Confirm_Mail'] == 'false' or $_POST['UAM_Confirm_Mail'] == 'local')) and $_POST['UAM_GTAutoMail'] == 'true')
     171    if (((isset($conf_UAM['CONFIRM_MAIL']) and ($conf_UAM['CONFIRM_MAIL'] == 'false' or $conf_UAM['CONFIRM_MAIL'] == 'local')) or ($_POST['UAM_Confirm_Mail'] == 'false' or $_POST['UAM_Confirm_Mail'] == 'local')) and $_POST['UAM_GTAutoMail'] == 'true')
    172172    {
    173173      $newvalue = 'false';
  • extensions/UserAdvManager/trunk/include/functions.inc.php

    r26077 r26914  
    287287    }
    288288
    289     $typemail = 3; // Only information email send to user on user profile update if checked
    290 
    291     if (!empty($_POST['use_new_pwd']))
    292     {
    293       $typemail = 2; // Confirmation email on user profile update - With information email
    294     }
    295 
    296289    // Sending registration confirmation by email
    297290    // ------------------------------------------
     
    310303        list($current_email) = pwg_db_fetch_row(pwg_query($query));
    311304
    312         // This is to send a new validation key
    313         // ------------------------------------
    314         if ($_POST['mail_address'] != $current_email and (isset($conf_UAM['CONFIRM_MAIL']) and $conf_UAM['CONFIRM_MAIL'] == 'true'))
     305        // This is to set the user to "waiting" group or status until validation
     306        // ---------------------------------------------------------------------
     307        if ($_POST['mail_address'] != $current_email and (isset($conf_UAM['CONFIRM_MAIL']) and ($conf_UAM['CONFIRM_MAIL'] == 'true' or $conf_UAM['CONFIRM_MAIL'] == 'local')))
    315308        {
    316309          SetPermission($user['id']);// Set to "waiting" group or status until user validation
     
    318311          $confirm_mail_need = true;
    319312        }
    320 
    321         // This is to set the user to "waiting" group or status until admin validation
    322         // ---------------------------------------------------------------------------
    323         elseif ($_POST['mail_address'] != $current_email and (isset($conf_UAM['CONFIRM_MAIL']) and $conf_UAM['CONFIRM_MAIL'] == 'local'))
     313        else
    324314        {
    325           SetPermission($user['id']);// Set to "waiting" group or status until admin validation
    326           SetUnvalidated($user['id']); // Set UAM_validated field to false in #_users table
    327315          $confirm_mail_need = false;
    328         }       
    329       }
    330 
    331       if (((!empty($_POST['use_new_pwd']) and (isset($conf_UAM['MAIL_INFO']) and $conf_UAM['MAIL_INFO'] == 'true')) or $confirm_mail_need))
     316        }
     317      }
     318
     319      $typemail = 2;
     320
     321      // Send email
     322      if ((isset($conf_UAM['MAIL_INFO']) and $conf_UAM['MAIL_INFO'] == 'true') or $confirm_mail_need)
    332323      {
    333324        $query = '
     
    338329
    339330        list($username) = pwg_db_fetch_row(pwg_query($query));
     331
    340332        SendMail2User($typemail, $user['id'], $username, $_POST['use_new_pwd'], $_POST['mail_address'], $confirm_mail_need);
    341333      }
     
    11091101      break;
    11101102
    1111     case 2: // Confirmation email on user profile update - With information email if modification done in user profile
    1112       if (isset($conf_UAM['CONFIRMMAIL_SUBJECT']) and !empty($conf_UAM['CONFIRMMAIL_SUBJECT']))
     1103    case 2: // Confirmation email on user profile update - Information email if modification done in user profile
     1104      if (isset($conf_UAM['INFOMAIL_SUBJECT']) and !empty($conf_UAM['INFOMAIL_SUBJECT']))
    11131105      {
    11141106        // Management of Extension flags ([username], [mygallery])
     
    11211113        if (function_exists('get_user_language_desc'))
    11221114        {
    1123           $subject = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM['CONFIRMMAIL_SUBJECT']))."\n\n";
     1115          $subject = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM['INFOMAIL_SUBJECT']))."\n\n";
    11241116        }
    1125         else $subject = l10n(preg_replace($patterns, $replacements, $conf_UAM['CONFIRMMAIL_SUBJECT']))."\n\n";
    1126       }
    1127 
    1128       $password = !empty($password) ? $password : l10n('UAM_empty_pwd');
     1117        else $subject = l10n(preg_replace($patterns, $replacements, $conf_UAM['INFOMAIL_SUBJECT']))."\n\n";
     1118      }
     1119
     1120      $password = !empty($password) ? $password : l10n('UAM_no_update_pwd');
    11291121
    11301122      if (isset($conf_UAM['MAILINFO_TEXT']) and !empty($conf_UAM['MAILINFO_TEXT']))
     
    11701162
    11711163      break;
    1172 
    1173     case 3: // Only information email send to user if checked
    1174       if (isset($conf_UAM['INFOMAIL_SUBJECT']) and !empty($conf_UAM['INFOMAIL_SUBJECT']))
    1175       {
    1176         // Management of Extension flags ([username], [mygallery])
    1177         // -------------------------------------------------------
    1178         $patterns[] = '#\[username\]#i';
    1179         $replacements[] = $username;
    1180         $patterns[] = '#\[mygallery\]#i';
    1181         $replacements[] = $conf['gallery_title'];
    1182 
    1183         if (function_exists('get_user_language_desc'))
    1184         {
    1185           $subject = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM['INFOMAIL_SUBJECT']))."\n\n";
    1186         }
    1187         else $subject = l10n(preg_replace($patterns, $replacements, $conf_UAM['INFOMAIL_SUBJECT']))."\n\n";
    1188       }
    1189 
    1190       $password = !empty($password) ? $password : l10n('UAM_no_update_pwd');
    1191 
    1192       if (isset($conf_UAM['MAILINFO_TEXT']) and !empty($conf_UAM['MAILINFO_TEXT']))
    1193       {
    1194         // Management of Extension flags ([username], [mygallery], [myurl])
    1195         // ----------------------------------------------------------------
    1196         $patterns[] = '#\[username\]#i';
    1197         $replacements[] = $username;
    1198         $patterns[] = '#\[mygallery\]#i';
    1199         $replacements[] = $conf['gallery_title'];
    1200         $patterns[] = '#\[myurl\]#i';
    1201         $replacements[] = get_gallery_home_url();
    1202 
    1203         if (function_exists('get_user_language_desc'))
    1204         {
    1205           $infos1_perso = get_user_language_desc(preg_replace($patterns, $replacements, $conf_UAM['MAILINFO_TEXT']))."\n\n";
    1206         }
    1207         else $infos1_perso = l10n(preg_replace($patterns, $replacements, $conf_UAM['MAILINFO_TEXT']))."\n\n";
    1208       }
    1209 
    1210       if (isset($conf_UAM['MAIL_INFO']) and $conf_UAM['MAIL_INFO'] == 'true')
    1211       {
    1212         if (isset($conf_UAM['HIDEPASSW']) and $conf_UAM['HIDEPASSW'] == 'true') // Allow display of clear password in email
    1213         {
    1214           $infos1 = array(
    1215             get_l10n_args('UAM_infos_mail %s', stripslashes($username)),
    1216             get_l10n_args('UAM_User: %s', stripslashes($username)),
    1217             get_l10n_args('UAM_Password: %s', $password),
    1218             get_l10n_args('Email: %s', $email),
    1219             get_l10n_args('', ''),
    1220           );
    1221         }
    1222         else // Do not allow display of clear password in email
    1223         {
    1224           $infos1 = array(
    1225             get_l10n_args('UAM_infos_mail %s', stripslashes($username)),
    1226             get_l10n_args('UAM_User: %s', stripslashes($username)),
    1227             get_l10n_args('Email: %s', $email),
    1228             get_l10n_args('', ''),
    1229           );
    1230         }
    1231       }
    1232 
    1233       break;
    12341164  }
    12351165
     
    12661196  }
    12671197
     1198
    12681199// Sending the email with subject and contents
    12691200// -------------------------------------------
    1270   if ((isset($conf_UAM['CONFIRM_MAIL']) and $conf_UAM['CONFIRM_MAIL'] == 'local') and $confirm)
    1271         {
     1201
     1202  if ((isset($conf_UAM['CONFIRM_MAIL']) and $conf_UAM['CONFIRM_MAIL'] == 'local') and $confirm) // Confirmation email send to admins
     1203  {
    12721204    switch_lang_to(get_default_language());
    12731205
    1274         load_language('plugin.lang', UAM_PATH);
    1275         $subject = get_l10n_args('UAM_Subject admin validation for %s',$username);
    1276 
    1277                 $content = array(
    1278         get_l10n_args('UAM_Manual_validation_needed_for %s', stripslashes($username)),
    1279      get_l10n_args('', ''),
    1280      get_l10n_args('UAM_Link: %s', AddConfirmMail($id, $email)),
     1206    load_language('plugin.lang', UAM_PATH);
     1207    $subject_admin = get_l10n_args('UAM_Subject admin validation for %s',$username);
     1208
     1209    $content_admin = array(
     1210      get_l10n_args('UAM_Manual_validation_needed_for %s', stripslashes($username)),
     1211      get_l10n_args('', ''),
     1212      get_l10n_args('UAM_Link: %s', AddConfirmMail($id, $email)),
    12811213    );
    12821214
    1283     //UAM_mail_notification_admins($subject, $content);
    1284     pwg_mail_notification_admins($subject, $content, true);
    1285   }
    1286         elseif ((isset($conf_UAM['CONFIRM_MAIL']) and $conf_UAM['CONFIRM_MAIL'] == 'true') and $confirm)
     1215    pwg_mail_notification_admins($subject_admin, $content_admin, true);
     1216  }
     1217
     1218
     1219        if (isset($conf_UAM['CONFIRM_MAIL']) and $conf_UAM['CONFIRM_MAIL'] == 'true' and $confirm) // Confirmation email send to users
    12871220        {
    12881221          // Adding gallery URL at the end of the email
    12891222    if (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'true')
    12901223    {
    1291       $content = (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "").get_absolute_root_url();
     1224      $content_confirmation = (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "").get_absolute_root_url();
    12921225
    12931226      pwg_mail(
     
    12971230          ),
    12981231        array(
    1299           'content' => $content,
     1232          'content' => $content_confirmation,
    13001233          'content_format' => 'text/plain',
    13011234          'subject' => $subject,
     
    13061239    elseif (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'false')
    13071240    {
    1308       $content = (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "");
     1241      $content_confirmation = (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "");
    13091242
    13101243      pwg_mail(
     
    13141247          ),
    13151248        array(
    1316           'content' => $content,
     1249          'content' => $content_confirmation,
    13171250          'content_format' => 'text/plain',
    13181251          'subject' => $subject,
     
    13231256    else
    13241257    {
    1325       $content = (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "");
     1258      $content_confirmation = (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "");
    13261259
    13271260      pwg_mail(
     
    13311264          ),
    13321265        array(
    1333           'content' => $content,
     1266          'content' => $content_confirmation,
     1267          'content_format' => 'text/plain',
     1268          'subject' => $subject,
     1269          )
     1270        );
     1271    }
     1272        }
     1273
     1274
     1275        if (isset($conf_UAM['MAIL_INFO']) and $conf_UAM['MAIL_INFO'] == 'true') // Information email send to users
     1276        {
     1277          // Adding gallery URL at the end of the email
     1278    if (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'true')
     1279    {
     1280      $content_info = (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "").get_absolute_root_url();
     1281
     1282      pwg_mail(
     1283        array(
     1284          'name' => stripslashes($username),
     1285          'email' => $email,
     1286          ),
     1287        array(
     1288          'content' => $content_info,
     1289          'content_format' => 'text/plain',
     1290          'subject' => $subject,
     1291          )
     1292        );
     1293    }
     1294    // Do not add gallery URL at the end of the email
     1295    elseif (isset($conf_UAM['ADD_GALLERY_URL_TO_EMAILS']) and $conf_UAM['ADD_GALLERY_URL_TO_EMAILS'] == 'false')
     1296    {
     1297      $content_info = (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "");
     1298
     1299      pwg_mail(
     1300        array(
     1301          'name' => stripslashes($username),
     1302          'email' => $email,
     1303          ),
     1304        array(
     1305          'content' => $content_info,
     1306          'content_format' => 'text/plain',
     1307          'subject' => $subject,
     1308          )
     1309        );
     1310    }
     1311    // By default do not add gallery URL at the end of the email
     1312    else
     1313    {
     1314      $content_info = (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "");
     1315
     1316      pwg_mail(
     1317        array(
     1318          'name' => stripslashes($username),
     1319          'email' => $email,
     1320          ),
     1321        array(
     1322          'content' => $content_info,
    13341323          'content_format' => 'text/plain',
    13351324          'subject' => $subject,
Note: See TracChangeset for help on using the changeset viewer.