Changeset 18125


Ignore:
Timestamp:
Sep 21, 2012, 7:43:03 PM (8 years ago)
Author:
Eric
Message:

Finally I got it !!
Admins are now notified by email containing a validation link. The email is send in gallery's default language.

Location:
extensions/UserAdvManager/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserAdvManager/trunk/include/functions.inc.php

    r18087 r18125  
    11811181                if (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')
    11821182                {
    1183                                 $validation_url = AddConfirmMail($id, $email);
    1184                 UAM_Admins_notification($username,AddConfirmMail($id, $validation_url));
     1183                switch_lang_to(get_default_language());
     1184               
     1185                load_language('plugin.lang', UAM_PATH);
     1186                $subject = get_l10n_args('UAM_Subject admin validation for %s',$username);
     1187
     1188                  $content = array(
     1189                get_l10n_args('UAM_Manual_validation_needed_for %s', stripslashes($username)),
     1190    get_l10n_args('', ''),
     1191    get_l10n_args('UAM_Link: %s', AddConfirmMail($id, $email)),
     1192    );
     1193
     1194    UAM_mail_notification_admins($subject, $content);
    11851195                }
    11861196                else
     
    11971207
    11981208
    1199 function UAM_Admins_notification($username,$validation_url)
    1200 {
    1201                 include_once(PHPWG_ROOT_PATH.'include/functions_mail.inc.php');
    1202                 $keyargs_content = array
    1203   (
    1204                 get_l10n_args('UAM_Manual_validation_needed_for %s', stripslashes($username)),
    1205     get_l10n_args('', ''),
    1206     get_l10n_args('UAM_Link: %s', $validation_url)
    1207   );
    1208 
    1209   pwg_mail_notification_admins(
    1210     get_l10n_args('UAM_Subject admin validation for %s',stripslashes($username)),
    1211     $keyargs_content,
    1212     false
    1213   );
     1209/**
     1210 * Function called from SendMail2User in functions.inc.php to notify admins on user registration validation with validation key
     1211 *
     1212 * @param:
     1213 *   - keyargs_subject: mail subject on l10n_args format
     1214 *   - keyargs_content: mail content on l10n_args format
     1215 *
     1216 * @return boolean (Ok or not)
     1217 */
     1218function UAM_mail_notification_admins($keyargs_subject, $keyargs_content)
     1219{
     1220  global $conf, $user;
     1221 
     1222  // Check arguments
     1223  if (empty($keyargs_subject) or empty($keyargs_content))
     1224  {
     1225    return false;
     1226  }
     1227
     1228  $return = true;
     1229
     1230  $admins = array();
     1231
     1232  $query = '
     1233SELECT
     1234    u.'.$conf['user_fields']['username'].' AS username,
     1235    u.'.$conf['user_fields']['email'].' AS mail_address
     1236  FROM '.USERS_TABLE.' AS u
     1237    JOIN '.USER_INFOS_TABLE.' AS i ON i.user_id =  u.'.$conf['user_fields']['id'].'
     1238  WHERE i.status in (\'webmaster\',  \'admin\')
     1239    AND '.$conf['user_fields']['email'].' IS NOT NULL
     1240    AND i.user_id <> '.$user['id'].'
     1241  ORDER BY username
     1242;';
     1243
     1244  $datas = pwg_query($query);
     1245  if (!empty($datas))
     1246  {
     1247    while ($admin = pwg_db_fetch_assoc($datas))
     1248    {
     1249      if (!empty($admin['mail_address']))
     1250      {
     1251        array_push($admins, format_email($admin['username'], $admin['mail_address']));
     1252      }
     1253    }
     1254  }
     1255
     1256  if (count($admins) > 0)
     1257  {
     1258    $content = l10n_args($keyargs_content)."\n";
     1259
     1260    $return = pwg_mail(
     1261      implode(', ', $admins),
     1262      array(
     1263        'subject' => '['.$conf['gallery_title'].'] '.l10n_args($keyargs_subject),
     1264        'content' => $content,
     1265        'content_format' => 'text/plain',
     1266        'email_format' => 'text/plain',
     1267        )
     1268      );
     1269  }
     1270
     1271  return $return;
    12141272}
    12151273
  • extensions/UserAdvManager/trunk/language/en_UK/plugin.lang.php

    r18087 r18125  
    1414$lang['UAM_User: %s'] = 'User : %s';
    1515$lang['UAM_Password: %s'] = 'Password: %s';
    16 $lang['UAM_Link: %s'] = 'Please, click on this link to confirm your registration : %s';
     16$lang['UAM_Link: %s'] = 'Please, click on this link to confirm the registration : %s';
    1717
    1818
Note: See TracChangeset for help on using the changeset viewer.