Changeset 17846


Ignore:
Timestamp:
Sep 10, 2012, 10:00:14 PM (8 years ago)
Author:
Eric
Message:

bug 2744 fixed
Small code refactory

Location:
extensions/UserAdvManager/trunk
Files:
2 edited

Legend:

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

    r17807 r17846  
    300300            Bug 2740 fixed - Loggin rejection on unvalidated user connection does not work
    301301
     302-- 2.30.9 : Bug 2744 fixed - User connexion rejection does not work if no group/status/privacy is set
     303
    302304**************************************************************
    303305***** Plugin history (branch 2.40 - Piwigo 2.4 compliant)*****
     
    337339            Update es_ES, thanks to : jpr928
    338340            Update it_IT, thanks to : Ericnet and virgigiole
     341
     342-- 2.40.6 : Bug 2744 fixed - User connexion rejection does not work if no group/status/privacy is set
    339343*/
    340344?>
  • extensions/UserAdvManager/trunk/include/functions.inc.php

    r17804 r17846  
    3636{
    3737  global $conf, $page;
     38 
     39  $conf_UAM = unserialize($conf['UserAdvManager']);
    3840 
    3941  // Check mandatory email address for email exclusion
    40   $conf_UAM = unserialize($conf['UserAdvManager']);
    4142  if (!$conf['obligatory_user_mail_address'] and $conf_UAM[10] = 'true')
    4243  {
     
    104105
    105106  // Perform user logout after registration if not validated
    106   if ((isset($conf_UAM[39]) and $conf_UAM[39] == 'true') and !UAM_UsrReg_Verif($user['id']))
     107  if ((isset($conf_UAM[39]) and $conf_UAM[39] == 'true') and !UAM_UsrReg_Verif($user['id']) and !is_admin())
    107108  {
    108109    invalidate_user_cache();
     
    512513  }
    513514
    514   // GhostTracker auto group, status or privacy level downgrade with or without information email sending and autodeletion if user already reminded
    515   // ----------------------------------------------------------------------------------------------------------------------------------------------
     515  // Auto group, status or privacy level downgrade and autodeletion if user already reminded
     516  // ---------------------------------------------------------------------------------------
    516517  if ((isset($conf_UAM[21]) and $conf_UAM[21] == 'true') and ((isset($conf_UAM[25]) and $conf_UAM[25] <> -1) or (isset($conf_UAM[26]) and $conf_UAM[26] <> -1) or (isset($conf_UAM[37]) and $conf_UAM[37] <> -1)))
    517518  {
     
    21282129;";
    21292130    pwg_query($query);
    2130              
    2131                 if ($conf_UAM[2] <> -1)
    2132                 {
    2133                         $query = "
     2131  }
     2132
     2133  if ($conf_UAM[2] <> -1) // Delete user from waiting group
     2134        {
     2135    $query = "
    21342136DELETE FROM ".USER_GROUP_TABLE."
    21352137WHERE user_id = '".$id."'
    21362138  AND group_id = '".$conf_UAM[2]."'
    21372139;";
    2138                         pwg_query($query);
    2139                 }
    2140  
    2141                 if ($conf_UAM[3] <> -1) // Change user's group
    2142                 {
    2143                         $query = "
     2140                pwg_query($query);
     2141  }
     2142 
     2143        if ($conf_UAM[3] <> -1) // Set user's valid group
     2144        {
     2145    $query = "
    21442146DELETE FROM ".USER_GROUP_TABLE."
    21452147WHERE user_id = '".$id."'
    21462148  AND group_id = '".$conf_UAM[3]."'
    21472149;";
    2148       pwg_query($query);
     2150    pwg_query($query);
    21492151       
    2150                         $query = "
     2152                $query = "
    21512153INSERT INTO ".USER_GROUP_TABLE."
    21522154  (user_id, group_id)
     
    21542156  ('".$id."', '".$conf_UAM[3]."')
    21552157;";
    2156                         pwg_query($query);
    2157     }
    2158 
    2159                 if ($conf_UAM[4] <> -1) // Change user's status
    2160                 {
    2161                         $query = "
     2158                pwg_query($query);
     2159  }
     2160
     2161        if ($conf_UAM[4] <> -1) // Set user's valid status
     2162        {
     2163    $query = "
    21622164UPDATE ".USER_INFOS_TABLE."
    21632165SET status = '".$conf_UAM[4]."'
    21642166WHERE user_id = '".$id."'
    21652167;";
    2166                         pwg_query($query);
    2167                 }
    2168 
    2169                 if ($conf_UAM[36] <> -1) // Change user's privacy level
    2170                 {
    2171                         $query = "
     2168                pwg_query($query);
     2169  }
     2170
     2171        if ($conf_UAM[36] <> -1) // Set user's valid privacy level
     2172        {
     2173    $query = "
    21722174UPDATE ".USER_INFOS_TABLE."
    21732175SET level = '".$conf_UAM[36]."'
    21742176WHERE user_id = '".$id."'
    21752177;";
    2176                         pwg_query($query);
    2177                 }
    2178   }
    2179   elseif (isset($conf_UAM[1]) and $conf_UAM[1] == 'local')
    2180   {
    2181     list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
    2182 
    2183     if ($conf_UAM[2] <> -1) // Delete user's from waiting group
    2184     {
    2185                   $query = "
    2186 DELETE FROM ".USER_GROUP_TABLE."
    2187 WHERE user_id = '".$id."'
    2188   AND group_id = '".$conf_UAM[2]."'
    2189 ;";
    2190                   pwg_query($query);
    2191     }
    2192 
    2193     if ($conf_UAM[3] <> -1) // Change user's group
    2194     {
    2195       $query = "
    2196 DELETE FROM ".USER_GROUP_TABLE."
    2197 WHERE user_id = '".$id."'
    2198   AND group_id = '".$conf_UAM[3]."'
    2199 ;";
    2200       pwg_query($query);
    2201        
    2202                   $query = "
    2203 INSERT INTO ".USER_GROUP_TABLE."
    2204   (user_id, group_id)
    2205 VALUES
    2206   ('".$id."', '".$conf_UAM[3]."')
    2207 ;";
    2208                   pwg_query($query);
    2209     }
    2210 
    2211     if ($conf_UAM[4] <> -1) // Change user's status
    2212     {
    2213                   $query = "
    2214 UPDATE ".USER_INFOS_TABLE."
    2215 SET status = '".$conf_UAM[4]."'
    2216 WHERE user_id = '".$id."'
    2217 ;";
    2218       pwg_query($query);
    2219     }
    2220 
    2221     if ($conf_UAM[36] <> -1) // Change user's privacy level
    2222     {
    2223                   $query = "
    2224 UPDATE ".USER_INFOS_TABLE."
    2225 SET level = '".$conf_UAM[36]."'
    2226 WHERE user_id = '".$id."'
    2227 ;";
    2228       pwg_query($query);
    2229     }
     2178                pwg_query($query);
    22302179  }
    22312180}
     
    28032752  $conf_UAM = unserialize($conf['UserAdvManager']);
    28042753
     2754  // Check for user groups
    28052755  $query = '
    28062756SELECT group_id
     
    28102760;';
    28112761
    2812   $count = pwg_db_num_rows(pwg_query($query));
    2813  
     2762  $count1 = pwg_db_num_rows(pwg_query($query));
     2763
     2764  // Check for user status
     2765  $query = '
     2766SELECT group_id
     2767  FROM '.USER_INFOS_TABLE.'
     2768WHERE user_id = '.$user_id.'
     2769  AND status = '.$conf_UAM[7].'
     2770;';
     2771
     2772  $count2 = pwg_db_num_rows(pwg_query($query));
     2773
     2774  // Check for user privacy level
     2775  $query = '
     2776SELECT group_id
     2777  FROM '.USER_INFOS_TABLE.'
     2778WHERE user_id = '.$user_id.'
     2779  AND level = '.$conf_UAM[35].'
     2780;';
     2781
     2782  $count3 = pwg_db_num_rows(pwg_query($query));
     2783
     2784  $count = $count1 + $count2 + $count3; // Summary of counts
     2785
    28142786  if ($count == 0)
    28152787  {
    2816     return true; // User is not in a "Waiting" group
     2788    return true; // User has validated his registration
    28172789  }
    28182790  else
    28192791  {
    2820     return false; // User is still in a "Waiting" group
     2792    return false; // User has not validated his registration
    28212793  }
    28222794}
Note: See TracChangeset for help on using the changeset viewer.