Module: appdb Branch: master Commit: 3abe0426ce6be3b6190a53ac4767150e3b9e4fe8 URL: http://source.winehq.org/git/appdb.git/?a=commit;h=3abe0426ce6be3b6190a53ac4...
Author: Rosanne DiMesio dimesio@earthlink.net Date: Wed Jul 5 13:30:29 2017 -0500
Remove inactive user check
Fixes bug 19201.
Signed-off-by: Rosanne DiMesio dimesio@earthlink.net Signed-off-by: Jeremy Newman jnewman@codeweavers.com
---
cron/cleanup.php | 121 +------------------------------------------------------ include/user.php | 44 -------------------- 2 files changed, 1 insertion(+), 164 deletions(-)
diff --git a/cron/cleanup.php b/cron/cleanup.php index 4be3b9b..4f44660 100644 --- a/cron/cleanup.php +++ b/cron/cleanup.php @@ -11,7 +11,7 @@ require_once(BASE."include/mail.php");
$sEmailSubject = "[Cron maintenance] - ";
-inactiveUserCheck(); +notifyAdminsOfCleanupStart();
/* check to see if there are orphaned versions in the database */ orphanVersionCheck(); @@ -34,102 +34,6 @@ cleanupVotes(); /* Updates the rating info for all versions based on test results */ //updateRatings();
-/* - * Warn users that have been inactive for some number of months - * If it has been some period of time since the user was warned - * the user is deleted if they don't have any pending appdb data - */ -function inactiveUserCheck() -{ - $usersWarned = 0; - $usersUnwarnedWithData = 0; /* users we would normally warn but who have data */ - $usersDeleted = 0; - $usersWithData = 0; /* users marked for deletion that have data */ - - notifyAdminsOfCleanupStart(); - - /* users inactive for 6 months that haven't been warned already */ - $hUsersToWarn = unwarnedAndInactiveSince(6); - if($hUsersToWarn) - { - while($oRow = query_fetch_object($hUsersToWarn)) - { - $oUser = new User($oRow->userid); - - /* if we get back true the user was warned and flagged as being warned */ - /* if we get back false we didn't warn the user and didn't flag the user as warned */ - /* because they have data associated with their account */ - if($oUser->warnForInactivity()) - { - $usersWarned++; - } else - { - $usersUnwarnedWithData++; - } - } - } - - /* warned >= 1 month ago */ - $hUsersToDelete = warnedSince(1); - if($hUsersToDelete) - { - while($oRow = query_fetch_object($hUsersToDelete)) - { - $oUser = new User($oRow->userid); - if(!$oUser->hasDataAssociated()) - { - $usersDeleted++; - deleteUser($oRow->userid); - } else - { - /* is the user a maintainer? if so remove their maintainer privileges */ - if($oUser->isMaintainer()) - { - Maintainer::deleteMaintainer($oUser); - } - - $usersWithData++; - } - } - } - - notifyAdminsOfCleanupExecution($usersWarned, $usersUnwarnedWithData, $usersDeleted, $usersWithData); -} - -/* Users that are unwarned and inactive since $iMonths */ -function unwarnedAndInactiveSince($iMonths) -{ - $sQuery = "SELECT userid FROM user_list WHERE DATE_SUB(CURDATE(),INTERVAL $iMonths MONTH) >= stamp AND inactivity_warned='false'"; - $hResult = query_appdb($sQuery); - return $hResult; -} - -/* users that were warned at least $iMonths ago */ -function warnedSince($iMonths) -{ - $sQuery = "SELECT userid FROM user_list WHERE DATE_SUB(CURDATE(),INTERVAL $iMonths MONTH) >= inactivity_warn_stamp "; - $sQuery .= "AND inactivity_warned='true'"; - $hResult = query_appdb($sQuery); - return $hResult; -} - -function deleteUser($iUserId) -{ - $oUser = new User($iUserId); - warnUserDeleted($oUser->sEmail); - $oUser->delete(); - echo "user ".$oUser->sEmail." deleted.\n"; -} - -function warnUserDeleted($sEmail) -{ - $sSubject = "Warning: account removed"; - $sMsg = "You didn't log in in the past seven months to the AppDB.\r\n"; - $sMsg .= "As you don't have any data associated to your account we have removed it.\r\n"; - $sMsg .= "Please feel free to recreate an account anytime.\r\n"; - - mail_appdb($sEmail, $sSubject, $sMsg); -}
function notifyAdminsOfCleanupStart() { @@ -142,29 +46,6 @@ function notifyAdminsOfCleanupStart() mail_appdb($sEmail, $sSubject, $sMsg); }
-/* email all admins that the appdb cleanup script is executing */ -/* so we admins have some visibility into the background cleanup */ -/* events of the appdb */ -function notifyAdminsOfCleanupExecution($usersWarned, $usersUnwarnedWithData, $usersDeleted, $usersWithData) -{ - global $sEmailSubject; - - $warnedUsers = User::get_inactive_users_pending_deletion(); - - $sSubject = $sEmailSubject."Inactive users\r\n"; - $sMsg = "Appdb inactive users cleanup executed.\r\n"; - $sMsg .= "Status\r\n"; - $sMsg .= "--------------------------\r\n"; - $sMsg .= "Users warned:".$usersWarned."\r\n"; - $sMsg .= "Users we would warn, but don't because they have data associated:".$usersUnwarnedWithData."\r\n"; - $sMsg .= "Warned users pending deletion:".$warnedUsers."\r\n"; - $sMsg .= "Users deleted:".$usersDeleted."\r\n"; - $sMsg .= "Users pending deletion but have appdb data:".$usersWithData."\r\n"; - $sEmail = User::get_notify_email_address_list(null, null); /* get list admins */ - if($sEmail) - mail_appdb($sEmail, $sSubject, $sMsg); -} - /* check for and report orphaned versions in the database */ /* we don't report anything if no orphans are found */ function orphanVersionCheck() diff --git a/include/user.php b/include/user.php index 2d62ea5..073f6e7 100644 --- a/include/user.php +++ b/include/user.php @@ -413,38 +413,6 @@ class User { return false; }
- /* warn the user that their account has been marked as inactive */ - function warnForInactivity() - { - /* we don't want to warn users that have data associated with them */ - if($this->hasDataAssociated()) - { - return false; - } - - if($this->isMaintainer()) - { - $sSubject = "Warning: inactivity detected"; - $sMsg = "You didn't log in in the past six months to the AppDB.\r\n"; - $sMsg .= "As a maintainer we would be pleased to see you once in a while.\r\n"; - $sMsg .= "Please log in or you will lose your maintainer's abilities in one month.\r\n"; - } else - { - $sSubject = "Warning: inactivity detected"; - $sMsg = "You didn't log in in the past six months to the AppDB.\r\n"; - $sMsg .= "Please log in or your account will automatically be deleted in one month.\r\n"; - } - $sMsg .= APPDB_ROOT."account.php?sCmd=login\r\n"; - - mail_appdb($this->sEmail, $sSubject, $sMsg); - - /* mark this user as being inactive and set the appropriate timestamp */ - $sQuery = "update user_list set inactivity_warned='true', inactivity_warn_stamp=NOW() where userid='?'"; - query_parameters($sQuery, $this->iUserId); - - return true; - } -
/** * Creates a new random password. @@ -502,18 +470,6 @@ class User { }
/** - * Get the count of users who have been warned for inactivity and are - * pending deletion after the X month grace period - */ - public static function get_inactive_users_pending_deletion() - { - /* retrieve the number of users that have been warned and are pending deletion */ - $hResult = query_parameters("select count(*) as count from user_list where inactivity_warned = 'true'"); - $oRow = query_fetch_object($hResult); - return $oRow->count; - } - - /** * Get the email address of people to notify for this appId and versionId. */ public static function get_notify_email_address_list($iAppId = null, $iVersionId = null)