Changeset 8087


Ignore:
Timestamp:
Dec 12, 2010, 12:02:15 AM (13 years ago)
Author:
Eric
Message:

Pre Branch 2.16 modifications in trunk:

  • Automation of user cleanup and downgrade tasks step 2
Location:
extensions/NBC_UserAdvManager/trunk
Files:
3 edited

Legend:

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

    r8072 r8087  
    211211***** Plugin history (branch 2.16)*****
    212212***************************************
    213 -- 2.16.0 : Bug 1430 and 1840 fixed - Automated tasks are available to delete or downgrade ghost users with or without email notification
    214             Bug 1585 fixed - UAM version is set in database to improve future upgrades
     213-- 2.16.0 : Bug 1585 fixed - UAM version is set in database to improve future upgrades
    215214            Bug 2011 fixed - Text fields are no longer locked if related option button is not set and saved. Now this fields and unused options are hidden
    216215            Bug 2046 fixed - Using Piwigo's $conf['insensitive_case_logon'] = true option works again with UAM
    217216            Bug 2053 fixed - Manual validation by admins wasn't working correctly
     217            Bug 2054
     218            Bug 2056 fixed - Automated tasks are available to delete or downgrade ghost users with or without email notification
     219            Add of Latvian (lv_LV) translation (Thx to Aivars Baldone)
    218220
    219221*/
  • extensions/NBC_UserAdvManager/trunk/include/functions.inc.php

    r8072 r8087  
    322322  $conf_UAM = unserialize($conf['UserAdvManager']);
    323323 
    324   // Performing scheduled tasks 
     324  // Performing scheduled tasks
     325  if ((isset($conf_UAM[22]) and $conf_UAM[22] == 'true'))
     326  {
     327    UAM_ScheduledTasks();
     328  }
     329
    325330  if ((isset($conf_UAM[21]) and $conf_UAM[21] == 'true'))
    326331  {
    327     if ((isset($conf_UAM[22]) and $conf_UAM[22] == 'true'))
    328     {
    329       UAM_ScheduledTasks();
    330     }
    331   }
    332 
    333   // Performing redirection 
    334   $query ='
     332    // Performing redirection 
     333    $query ='
    335334SELECT user_id, status
    336335FROM '.USER_INFOS_TABLE.'
    337336WHERE user_id = '.$user['id'].'
    338337;';
    339   $data = pwg_db_fetch_assoc(pwg_query($query));
    340 
    341   if ($data['status'] <> "admin" and $data['status'] <> "webmaster" and $data['status'] <> "generic")
    342   {
    343     $user_idsOK = array();
    344     if (!UAM_check_profile($user['id'], $user_idsOK))
    345       redirect(PHPWG_ROOT_PATH.'profile.php');
     338    $data = pwg_db_fetch_assoc(pwg_query($query));
     339
     340    if ($data['status'] <> "admin" and $data['status'] <> "webmaster" and $data['status'] <> "generic")
     341    {
     342      $user_idsOK = array();
     343      if (!UAM_check_profile($user['id'], $user_idsOK))
     344        redirect(PHPWG_ROOT_PATH.'profile.php');
     345    }
    346346  }
    347347}
     
    360360 
    361361  $collection = array();
     362  $reminder = false;
    362363 
    363364  $page['filtered_users'] = get_ghosts_autotasks();
    364365
    365   {       
    366                 foreach($page['filtered_users'] as $listed_user)
    367     {
    368       array_push($collection, $listed_user['id']);
    369     }
    370 
     366  foreach($page['filtered_users'] as $listed_user)
     367  {
     368    array_push($collection, $listed_user['id']);
     369  }
     370
     371  // Ghost accounts auto deletion
     372  if ((isset($conf_UAM[22]) and $conf_UAM[22] == 'true') and (isset($conf_UAM[23]) and $conf_UAM[23] == 'true'))
     373  {
    371374    if (count($collection) > 0)
    372375        {
     
    377380        foreach ($collection as $user_id)
    378381        {
    379           //delete_user($user_id);
     382          delete_user($user_id);
    380383        }
    381384        logout_user();
     
    386389        foreach ($collection as $user_id)
    387390        {
    388           //delete_user($user_id);
     391          delete_user($user_id);
    389392        }
    390393      }
     
    392395  }
    393396
    394   // Ghost accounts auto group or status downgrade with or without information email sending
     397  // Ghost accounts auto group or status downgrade with or without information email sending and autodeletion if user already reminded
    395398  if ((isset($conf_UAM[22]) and $conf_UAM[22] == 'true') and (isset($conf_UAM[23]) and $conf_UAM[23] == 'false') and ((isset($conf_UAM[27]) and $conf_UAM[27] <> -1) or (isset($conf_UAM[28]) and $conf_UAM[28] <> -1)))
    396   {
    397                 foreach($page['filtered_users'] as $listed_user)
    398     {
    399       array_push($collection, $listed_user['id']);
    400     }
    401 
     399  {
    402400    if (count($collection) > 0)
    403401        {
    404         if (in_array($user['id'], $collection))
    405         {
     402      // Process if a non-admin nor webmaster user is logged
     403      if (in_array($user['id'], $collection))
     404        {
    406405        foreach ($collection as $user_id)
    407406        {
     407          // Check lastvisit reminder state
     408          $query = '
     409SELECT reminder
     410FROM '.USER_LASTVISIT_TABLE.'
     411WHERE user_id = '.$user_id.';';
     412
     413          $result = pwg_db_fetch_assoc(pwg_query($query));
     414
     415          if (isset($result['reminder']) and $result['reminder'] == 'true')
     416          {
     417            $reminder = true;
     418          }
     419          else
     420          {
     421            $reminder = false;
     422          }
     423
     424          // If never reminded before, set reminder True
     425          if (!$reminder)
     426          {
     427            // Reset of lastvisit date
     428            list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
     429
     430                        $query = "
     431UPDATE ".USER_LASTVISIT_TABLE."
     432SET lastvisit='".$dbnow."'
     433WHERE user_id = '".$user_id."'
     434;";
     435            pwg_query($query);
     436
    408437          // Auto change group and / or status
    409           // Delete user from all groups
    410           $query = "
     438            // Delete user from all groups
     439            $query = "
    411440DELETE FROM ".USER_GROUP_TABLE."
    412441WHERE user_id = '".$user_id."'
     
    418447;";
    419448
    420           pwg_query($query);
    421 
    422           // Change user status
    423           if (!is_admin() and $conf_UAM[28] <> -1)
    424           {
    425             $query = "
     449            pwg_query($query);
     450
     451            // Change user status
     452            if ($conf_UAM[28] <> -1)
     453            {
     454              $query = "
    426455UPDATE ".USER_INFOS_TABLE."
    427456SET status = '".$conf_UAM[28]."'
    428457WHERE user_id = '".$user_id."'
    429458;";
    430             pwg_query($query);
    431           }
    432 
    433           // Change user group
    434           if (!is_admin() and $conf_UAM[27] <> -1)
    435           {
    436             $query = "
     459              pwg_query($query);
     460            }
     461
     462            // Change user group
     463            if ($conf_UAM[27] <> -1)
     464            {
     465              $query = "
    437466INSERT INTO ".USER_GROUP_TABLE."
    438467  (user_id, group_id)
     
    440469  ('".$user_id."', '".$conf_UAM[27]."')
    441470;";
    442             pwg_query($query);
    443           }
     471              pwg_query($query);
     472            }
    444473         
    445           // Auto send email notification on group / status downgrade
    446           if ((isset($conf_UAM[24]) and $conf_UAM[24] == 'true'))
    447           {
    448             // Reset confirmed user status to unvalidated
    449                                                 $query = '
     474            // Auto send email notification on group / status downgrade only if never reminded before
     475            if (isset($conf_UAM[24]) and $conf_UAM[24] == 'true')
     476            {
     477              // Set reminder true
     478              $query = "
     479UPDATE ".USER_LASTVISIT_TABLE."
     480SET reminder = 'true'
     481WHERE user_id = '".$user_id."'
     482;";
     483              pwg_query($query);
     484
     485              // Reset confirmed user date_check
     486              $query = '
    450487UPDATE '.USER_CONFIRM_MAIL_TABLE.'
    451488SET date_check = NULL
    452489WHERE user_id = "'.$user_id.'"
    453490;';
    454                                                 pwg_query($query);
    455 
    456             // Get users information for email notification
    457                                                 $query = '
    458 SELECT id, username, mail_address
     491                                                  pwg_query($query);
     492
     493              // Get users information for email notification
     494                                                  $query = '
     495SELECT username, mail_address
    459496FROM '.USERS_TABLE.'
    460497WHERE id = '.$user_id.'
    461498;';
    462                                                 $data = pwg_db_fetch_assoc(pwg_query($query));
     499                                                  $data = pwg_db_fetch_assoc(pwg_query($query));
    463500           
    464             demotion_mail($user_id, $data['username'], $data['mail_address']);
     501              demotion_mail($user_id, $data['username'], $data['mail_address']);
     502            }
     503          }
     504          elseif ($reminder) // If user already reminded for ghost account
     505          {
     506            // delete account
     507            delete_user($user_id);
    465508          }
    466509        }
     510        // Logged-in user cleanup
    467511        invalidate_user_cache();
    468512        log_user($user['id'], false);
    469513        redirect(make_index_url());
    470514        }
    471       else
     515      else // Process if an admin or webmaster user is logged
    472516      {
    473517        foreach ($collection as $user_id)
    474518        {
     519          // Check lastvisit reminder state
     520          $query = '
     521SELECT reminder
     522FROM '.USER_LASTVISIT_TABLE.'
     523WHERE user_id = '.$user_id.';';
     524
     525          $result = pwg_db_fetch_assoc(pwg_query($query));
     526
     527          if (isset($result['reminder']) and $result['reminder'] == 'true')
     528          {
     529            $reminder = true;
     530          }
     531          else
     532          {
     533            $reminder = false;
     534          }
     535
     536          // If never reminded before
     537          if (!$reminder)
     538          {
     539            // Reset of lastvisit date
     540            list($dbnow) = pwg_db_fetch_row(pwg_query('SELECT NOW();'));
     541
     542                        $query = "
     543UPDATE ".USER_LASTVISIT_TABLE."
     544SET lastvisit='".$dbnow."'
     545WHERE user_id = '".$user_id."'
     546;";
     547            pwg_query($query);
     548
    475549          // Auto change group and / or status
    476           // Delete user from all groups
    477           $query = "
     550            // Delete user from all groups
     551            $query = "
    478552DELETE FROM ".USER_GROUP_TABLE."
    479553WHERE user_id = '".$user_id."'
     
    484558  )
    485559;";
    486 
    487           pwg_query($query);
    488 
    489           // Change user status
    490           if (!is_admin() and $conf_UAM[28] <> -1)
    491           {
    492             $query = "
     560            pwg_query($query);
     561
     562            // Change user status
     563            if ($conf_UAM[28] <> -1)
     564            {
     565              $query = "
    493566UPDATE ".USER_INFOS_TABLE."
    494567SET status = '".$conf_UAM[28]."'
    495568WHERE user_id = '".$user_id."'
    496569;";
    497             pwg_query($query);
    498           }
    499 
    500           // Change user group
    501           if (!is_admin() and $conf_UAM[27] <> -1)
    502           {
    503             $query = "
     570              pwg_query($query);
     571            }
     572
     573            // Change user group
     574            if ($conf_UAM[27] <> -1)
     575            {
     576              $query = "
    504577INSERT INTO ".USER_GROUP_TABLE."
    505578  (user_id, group_id)
     
    507580  ('".$user_id."', '".$conf_UAM[27]."')
    508581;";
    509             pwg_query($query);
    510           }
    511 
    512           // Auto send email notification on group / status downgrade
    513           if ((isset($conf_UAM[24]) and $conf_UAM[24] == 'true'))
    514           {
    515             // Reset confirmed user status to unvalidated
    516                                                 $query = '
     582              pwg_query($query);
     583            }
     584
     585            // Auto send email notification on group / status downgrade
     586            if (isset($conf_UAM[24]) and $conf_UAM[24] == 'true')
     587            {
     588              // Set reminder true
     589              $query = "
     590UPDATE ".USER_LASTVISIT_TABLE."
     591SET reminder = 'true'
     592WHERE user_id = '".$user_id."'
     593;";
     594              pwg_query($query);
     595           
     596              // Reset confirmed user status to unvalidated
     597                                                  $query = '
    517598UPDATE '.USER_CONFIRM_MAIL_TABLE.'
    518599SET date_check = NULL
    519600WHERE user_id = "'.$user_id.'"
    520601;';
    521                                                 pwg_query($query);
    522 
    523             // Get users information for email notification
    524                                                 $query = '
     602                                                  pwg_query($query);
     603
     604              // Get users information for email notification
     605                                                  $query = '
    525606SELECT id, username, mail_address
    526607FROM '.USERS_TABLE.'
    527608WHERE id = '.$user_id.'
    528609;';
    529                                                 $data = pwg_db_fetch_assoc(pwg_query($query));
     610                                                  $data = pwg_db_fetch_assoc(pwg_query($query));
    530611           
    531             demotion_mail($user_id, $data['username'], $data['mail_address']);
     612              demotion_mail($user_id, $data['username'], $data['mail_address']);
     613            }
     614          }
     615          elseif ($reminder) // If user already reminded for ghost account
     616          {
     617            // delete account
     618            delete_user($user_id);
    532619          }
    533620        }
     
    14291516  global $conf;
    14301517
    1431   include_once(PHPWG_ROOT_PATH.'admin/include/functions.php');
    1432 
    14331518  $conf_UAM = unserialize($conf['UserAdvManager']);
    14341519
     
    17521837  $query = '
    17531838SELECT DISTINCT u.'.$conf['user_fields']['id'].' AS id,
    1754                 lv.lastvisit,
    1755                 lv.reminder
     1839                lv.lastvisit
    17561840FROM '.USERS_TABLE.' AS u
    17571841  INNER JOIN '.USER_LASTVISIT_TABLE.' AS lv
    17581842    ON u.'.$conf['user_fields']['id'].' = lv.user_id
    17591843WHERE (TO_DAYS(NOW()) - TO_DAYS(lv.lastvisit) >= "'.$conf_UAM[17].'")
    1760   AND lv.reminder = "true"
    17611844ORDER BY lv.lastvisit ASC;';
    17621845
  • extensions/NBC_UserAdvManager/trunk/language/fr_FR/help/plugin.lang.php

    r8065 r8087  
    190190Note : Lorsque cette option est active, les autres règles automatiques ne sont pas accessibles.';
    191191$lang['UAM_GTAutoGpTitle'] = 'Changement automatique de groupe / statut';
    192 $lang['UAM_GTAutoGpTitle_d'] = 'Le changement automatique de groupe ou de statut équivaut à une rétrogradation des comptes concernés et fonctionne sur le même principe que le groupe ou le statut de validation (voir &quot;Paramétrage des confirmations et validations d\'inscriptions&quot;). Il conviendra donc de définir un groupe et/ou un statut rétrogradant l\'accès à la galerie. Si cela a déjà été défini avec l\'utilisation de la fonction Confirmation d\'inscription, on peut utiliser ces mêmes groupe / statut.';
     192$lang['UAM_GTAutoGpTitle_d'] = 'Le changement automatique de groupe ou de statut équivaut à une rétrogradation des comptes concernés et fonctionne sur le même principe que le groupe ou le statut de validation (voir &quot;Paramétrage des confirmations et validations d\'inscriptions&quot;). Il conviendra donc de définir un groupe et/ou un statut rétrogradant l\'accès à la galerie. Si cela a déjà été défini avec l\'utilisation de la fonction Confirmation d\'inscription, on peut utiliser ces mêmes groupe / statut.<br><br>
     193<b style=&quot;color: red;&quot;>Point important :</b> Si un utilisateur fantôme n\'a toujours pas donné signe de vie après le délai imparti malgré la notification par mail, il est automatiquement supprimé de la base de données.';
    193194$lang['UAM_GTAutoMailTitle'] = 'Email automatique sur changement de groupe / statut';
    194195$lang['UAM_GTAutoMailTitle_d'] = 'Lorsqu\'un compte est expiré (changement de groupe / statut rétrogradant le visiteur), un email d\'information peut être envoyé pour préciser les raisons de ce changement et le moyen de recouvrer l\'accès initial à la galerie.
Note: See TracChangeset for help on using the changeset viewer.