Changeset 21084


Ignore:
Timestamp:
03/01/13 14:19:59 (6 years ago)
Author:
Eric
Message:

Bug 2829 fixed - Workflow refactory if confirmation of registrations are done by admins :

  • Admins add manually user *and* confirmation of registration for admins is set to OFF -> new added users are considered automatically as validated.
  • Admins add manually user *and* confirmation of registration for admins is set to ON -> new added users receive the confirmation email.
  • Finally, if a user registers himself, admins receive the validation link.
Location:
extensions/UserAdvManager/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • extensions/UserAdvManager/trunk/changelog.txt.php

    r21075 r21084  
    378378-- 2.50.0 : Compliance with Piwigo 2.5 
    379379            Bug 2764 fixed - Code refactory : Change config variables to assoc array and $_POST vars control before writing conf in database - Thx to flop25 for his advices ;-) 
     380            Bug 2829 fixed - Workflow refactory if confirmation of registrations are done by admins : 
     381              - Admins add manually user *and* confirmation of registration for admins is set to OFF -> new added users are considered automatically as validated. 
     382              - Admins add manually user *and* confirmation of registration for admins is set to ON -> new added users receive the confirmation email. 
     383              - Finally, if a user registers himself, admins receive the validation link.  
    380384            Update fr_FR 
    381385            Update de_DE, thanks to : stephy 
  • extensions/UserAdvManager/trunk/include/functions.inc.php

    r21075 r21084  
    137137    $passwd = (isset($_POST['password'])) ? $_POST['password'] : ''; 
    138138 
    139     // No validation needed when admins add users - users are considered as valid by default 
    140     // ------------------------------------------------------------------------------------- 
    141     //Bug 2829 fix not working - if (isset($page['page']) and ($page['page'] != 'user_list')) 
    142     //{ 
    143       if (isset($conf_UAM['CONFIRM_MAIL']) and $conf_UAM['CONFIRM_MAIL'] == 'local') 
    144       { 
    145         // This is to set user to "waiting" group or status and without ConfirMail until admin validation 
    146         // ---------------------------------------------------------------------------------------------- 
    147         SetPermission($register_user['id']);// Set to "waiting" group or status until admin validation 
    148  
    149         // This is to set UAM_validated field to false in #_users table - Usefull if no "waiting" group or status is set 
    150         // ------------------------------------------------------------------------------------------------------------- 
    151         SetUnvalidated($register_user['id']); 
    152  
    153         // This is to send the validation key by email to admins for their manual validation without having to connect the gallery 
    154         // ----------------------------------------------------------------------------------------------------------------------- 
     139    // -------------------------------------------------------------------------------------------------------------------- 
     140    // Workflow when admins have to validate registrations (CONFIRM_MAIL = local) 
     141    // No validation needed when admins add users if ADMINCONFMAIL is set to OFF - users are considered as valid by default 
     142    // Else a notification email with validation link is send to admins 
     143    // Finally when a user registers himself, a notification email with validation link is send to admins 
     144    // -------------------------------------------------------------------------------------------------------------------- 
     145    if (isset($conf_UAM['CONFIRM_MAIL']) and $conf_UAM['CONFIRM_MAIL'] == 'local') 
     146    { 
     147      if (is_admin() and isset($conf_UAM['ADMINCONFMAIL']) and $conf_UAM['ADMINCONFMAIL'] == 'true') 
     148      { 
     149        SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true);  
     150      } 
     151      elseif (is_admin() and isset($conf_UAM['ADMINCONFMAIL']) and $conf_UAM['ADMINCONFMAIL'] == 'false') 
     152      { 
     153        SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false); 
     154      } 
     155      elseif (!is_admin()) 
     156      { 
    155157        SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true); 
    156158      } 
    157       // Sending registration confirmation by email 
    158       // ------------------------------------------ 
    159       elseif (isset($conf_UAM['CONFIRM_MAIL']) and $conf_UAM['CONFIRM_MAIL'] == 'true') 
    160       { 
    161         if (is_admin() and isset($conf_UAM['ADMINCONFMAIL']) and $conf_UAM['ADMINCONFMAIL'] == 'true') 
    162         { 
    163           SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true);  
    164         } 
    165         elseif (is_admin() and isset($conf_UAM['ADMINCONFMAIL']) and $conf_UAM['ADMINCONFMAIL'] == 'false') 
    166         { 
    167           SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false); 
    168         } 
    169         elseif (!is_admin()) 
    170         { 
    171           SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true); 
    172         } 
    173       } 
    174     //} 
     159    } 
     160    // -------------------------------------------------------------------------------------------------------------------- 
     161    // Workflow when users have to validate their registration (CONFIRM_MAIL = true) 
     162    // No validation needed when admins add users if ADMINCONFMAIL is set to OFF - users are considered as valid by default 
     163    // Else an email with validation link is send to user 
     164    // Finally when a user registers himself, an email with validation link is send to him 
     165    // -------------------------------------------------------------------------------------------------------------------- 
     166    elseif (isset($conf_UAM['CONFIRM_MAIL']) and $conf_UAM['CONFIRM_MAIL'] == 'true') 
     167    { 
     168      if (is_admin() and isset($conf_UAM['ADMINCONFMAIL']) and $conf_UAM['ADMINCONFMAIL'] == 'true') 
     169      { 
     170        SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true);  
     171      } 
     172      elseif (is_admin() and isset($conf_UAM['ADMINCONFMAIL']) and $conf_UAM['ADMINCONFMAIL'] == 'false') 
     173      { 
     174        SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], false); 
     175      } 
     176      elseif (!is_admin()) 
     177      { 
     178        SendMail2User(1, $register_user['id'], $register_user['username'], $passwd, $register_user['email'], true); 
     179      } 
     180    } 
    175181  } 
    176182} 
     
    13051311  } 
    13061312 
    1307   if (isset($conf_UAM['CONFIRM_MAIL']) and ($conf_UAM['CONFIRM_MAIL'] == 'true' or $conf_UAM['CONFIRM_MAIL'] == 'local') and $confirm) // Add confirmation link ? 
     1313  if ((isset($conf_UAM['CONFIRM_MAIL']) and ($conf_UAM['CONFIRM_MAIL'] == 'true' or $conf_UAM['CONFIRM_MAIL'] == 'local')) and $confirm) // Add confirmation link ? 
    13081314  { 
    13091315    $infos2 = array( 
     
    13391345// Sending the email with subject and contents 
    13401346// ------------------------------------------- 
    1341                 if (isset($conf_UAM['CONFIRM_MAIL']) and $conf_UAM['CONFIRM_MAIL'] == 'local') 
    1342                 { 
    1343                 switch_lang_to(get_default_language()); 
    1344  
    1345                 load_language('plugin.lang', UAM_PATH); 
    1346                 $subject = get_l10n_args('UAM_Subject admin validation for %s',$username); 
    1347  
    1348                   $content = array( 
    1349                   get_l10n_args('UAM_Manual_validation_needed_for %s', stripslashes($username)), 
    1350         get_l10n_args('', ''), 
    1351         get_l10n_args('UAM_Link: %s', AddConfirmMail($id, $email)), 
    1352       ); 
    1353  
    1354       UAM_mail_notification_admins($subject, $content); 
    1355                 } 
    1356                 else 
    1357                 { 
    1358                 pwg_mail($email, array( 
    1359                 'subject' => $subject, 
    1360                 'content' => (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "").get_absolute_root_url(), 
    1361                 )); 
    1362                 } 
     1347  if ((isset($conf_UAM['CONFIRM_MAIL']) and $conf_UAM['CONFIRM_MAIL'] == 'local') and $confirm) 
     1348        { 
     1349    switch_lang_to(get_default_language()); 
     1350 
     1351        load_language('plugin.lang', UAM_PATH); 
     1352        $subject = get_l10n_args('UAM_Subject admin validation for %s',$username); 
     1353 
     1354                $content = array( 
     1355        get_l10n_args('UAM_Manual_validation_needed_for %s', stripslashes($username)), 
     1356     get_l10n_args('', ''), 
     1357     get_l10n_args('UAM_Link: %s', AddConfirmMail($id, $email)), 
     1358    ); 
     1359 
     1360    UAM_mail_notification_admins($subject, $content); 
     1361  } 
     1362        elseif ((isset($conf_UAM['CONFIRM_MAIL']) and $conf_UAM['CONFIRM_MAIL'] == 'true') and $confirm) 
     1363        { 
     1364    pwg_mail($email, array( 
     1365      'subject' => $subject, 
     1366        'content' => (isset($infos1) ? $infos1_perso.l10n_args($infos1)."\n\n" : "").(isset($infos2) ? $infos2_perso.l10n_args($infos2)."\n\n" : "").get_absolute_root_url(), 
     1367    )); 
     1368        } 
    13631369// Switching back to default language 
    13641370// ---------------------------------- 
     
    13921398  $query = ' 
    13931399SELECT 
    1394     u.'.$conf['user_fields']['username'].' AS username, 
    1395     u.'.$conf['user_fields']['email'].' AS mail_address 
     1400    u.username AS username, 
     1401    u.mail_address AS mail_address 
    13961402  FROM '.USERS_TABLE.' AS u 
    1397     JOIN '.USER_INFOS_TABLE.' AS i ON i.user_id =  u.'.$conf['user_fields']['id'].' 
     1403    JOIN '.USER_INFOS_TABLE.' AS i ON i.user_id = id 
    13981404  WHERE i.status in (\'webmaster\',  \'admin\') 
    1399     AND '.$conf['user_fields']['email'].' IS NOT NULL 
    1400     AND i.user_id <> '.$user['id'].' 
     1405    AND mail_address IS NOT NULL 
     1406    AND i.user_id = id 
    14011407  ORDER BY username 
    14021408;'; 
     
    19301936  if (isset($Confirm_Mail_ID)) 
    19311937  { 
    1932     $query = ' 
    1933 SELECT status 
    1934   FROM '.USER_INFOS_TABLE.' 
    1935 WHERE user_id = '.$user_id.' 
    1936 ;'; 
    1937     list($status) = pwg_db_fetch_row(pwg_query($query)); 
    1938  
    1939     $query = ' 
    1940 INSERT INTO '.USER_CONFIRM_MAIL_TABLE.' 
    1941   (id, user_id, mail_address, status, date_check) 
    1942 VALUES 
    1943   ("'.$Confirm_Mail_ID.'", '.$user_id.', "'.$email.'", "'.$status.'", null) 
    1944 ;'; 
    1945  
    1946     pwg_query($query); 
    1947  
    1948     // Delete user from all groups 
    1949     // --------------------------- 
    1950     $query = ' 
    1951 DELETE FROM '.USER_GROUP_TABLE.' 
    1952 WHERE user_id = '.$user_id.' 
    1953   AND ( 
    1954     group_id = '.$conf_UAM['NO_CONFIRM_GROUP'].' 
    1955   OR  
    1956     group_id = '.$conf_UAM['VALIDATED_GROUP'].' 
    1957   ) 
    1958 ;'; 
    1959  
    1960     pwg_query($query); 
    1961  
    1962     // Set user unvalidated status 
    1963     // --------------------------- 
    1964     if (!is_admin() and $conf_UAM['NO_CONFIRM_STATUS'] <> -1) 
    1965     { 
    1966       $query = ' 
    1967 UPDATE '.USER_INFOS_TABLE.' 
    1968 SET status = "'.$conf_UAM['NO_CONFIRM_STATUS'].'" 
    1969 WHERE user_id = '.$user_id.' 
    1970 ;'; 
    1971  
    1972       pwg_query($query); 
    1973     } 
    1974  
    1975     // Set user unvalidated group 
    1976     // -------------------------- 
    1977     if (!is_admin() and $conf_UAM['NO_CONFIRM_GROUP'] <> -1) 
    1978     { 
    1979       $query = ' 
    1980 INSERT INTO '.USER_GROUP_TABLE.' 
    1981   (user_id, group_id) 
    1982 VALUES 
    1983   ('.$user_id.', '.$conf_UAM['NO_CONFIRM_GROUP'].') 
    1984 ;'; 
    1985  
    1986       pwg_query($query); 
    1987     } 
    1988  
    1989     // Set user unvalidated privacy level 
    1990     // ---------------------------------- 
    1991     if (!is_admin() and $conf_UAM['NO_VALID_LEVEL'] <> -1) 
    1992     { 
    1993       $query = ' 
    1994 UPDATE '.USER_INFOS_TABLE.' 
    1995 SET level = "'.$conf_UAM['NO_VALID_LEVEL'].'" 
    1996 WHERE user_id = '.$user_id.' 
    1997 ;'; 
    1998  
    1999       pwg_query($query); 
    2000     } 
     1938    // Set user permissions 
     1939    // -------------------- 
     1940    SetPermission($user_id); 
    20011941 
    20021942    // Set UAM_validated field to false in #_users table 
     
    20041944    SetUnvalidated($user_id); 
    20051945 
    2006     if ( $conf['guest_access'] ) 
     1946    if ($conf['guest_access']) 
    20071947    { 
    20081948      return(get_absolute_root_url().'?key='.$Confirm_Mail_ID.'&userid='.$user_id); 
     
    20431983  pwg_query($query); 
    20441984 
    2045   if (!is_admin() and $conf_UAM['NO_CONFIRM_STATUS'] <> -1) // Set status 
     1985  if ($conf_UAM['NO_CONFIRM_STATUS'] <> -1) // Set status 
    20461986  { 
    20471987    $query = ' 
     
    20541994  } 
    20551995 
    2056   if (!is_admin() and $conf_UAM['NO_CONFIRM_GROUP'] <> -1) // Set group 
     1996  if ($conf_UAM['NO_CONFIRM_GROUP'] <> -1) // Set group 
    20571997  { 
    20581998    $query = ' 
     
    20662006  } 
    20672007 
    2068   if (!is_admin() and $conf_UAM['NO_VALID_LEVEL'] <> -1) // Set privacy level 
     2008  if ($conf_UAM['NO_VALID_LEVEL'] <> -1) // Set privacy level 
    20692009  { 
    20702010    $query = ' 
Note: See TracChangeset for help on using the changeset viewer.