Cleanup User class. Move user related functions into class as static member functions
This commit is contained in:
@@ -152,8 +152,8 @@ function cmd_send_passwd()
|
|||||||
$note = '(<b>Note</b>: accounts for <b>appdb</b>.winehq.org and <b>bugs</b>.winehq.org '
|
$note = '(<b>Note</b>: accounts for <b>appdb</b>.winehq.org and <b>bugs</b>.winehq.org '
|
||||||
.'are separated, so You might need to <b>create second</b> account for appdb.)';
|
.'are separated, so You might need to <b>create second</b> account for appdb.)';
|
||||||
|
|
||||||
$userid = user_exists($aClean['ext_email']);
|
$userid = User::exists($aClean['ext_email']);
|
||||||
$passwd = generate_passwd();
|
$passwd = User::generate_passwd();
|
||||||
$user = new User($userid);
|
$user = new User($userid);
|
||||||
if ($userid)
|
if ($userid)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -123,7 +123,7 @@ if (!$aClean['id'])
|
|||||||
echo '<td>';
|
echo '<td>';
|
||||||
$imgSRC = '<img width="'.$oScreenshot->oThumbnailImage->width.'" height="'.$oScreenshot->oThumbnailImage->height.'" src="../appimage.php?queued=true&id='.$obj_row->id.'" />';
|
$imgSRC = '<img width="'.$oScreenshot->oThumbnailImage->width.'" height="'.$oScreenshot->oThumbnailImage->height.'" src="../appimage.php?queued=true&id='.$obj_row->id.'" />';
|
||||||
// generate random tag for popup window
|
// generate random tag for popup window
|
||||||
$randName = generate_passwd(5);
|
$randName = User::generate_passwd(5);
|
||||||
// set image link based on user pref
|
// set image link based on user pref
|
||||||
$img = '<a href="javascript:openWin(\'../appimage.php?queued=true&id='.$obj_row->id.'\',\''.$randName.'\','.$oScreenshot->oScreenshotImage->width.','.($oScreenshot->oScreenshotImage->height+4).');">'.$imgSRC.'</a>';
|
$img = '<a href="javascript:openWin(\'../appimage.php?queued=true&id='.$obj_row->id.'\',\''.$randName.'\','.$oScreenshot->oScreenshotImage->width.','.($oScreenshot->oScreenshotImage->height+4).');">'.$imgSRC.'</a>';
|
||||||
if ($_SESSION['current']->isLoggedIn())
|
if ($_SESSION['current']->isLoggedIn())
|
||||||
|
|||||||
@@ -15,37 +15,37 @@ echo "<table width='100%' border=1 cellpadding=3 cellspacing=0>\n\n";
|
|||||||
/* Display the number of users */
|
/* Display the number of users */
|
||||||
echo "<tr class=color4>\n";
|
echo "<tr class=color4>\n";
|
||||||
echo " <td>Users:</td>\n";
|
echo " <td>Users:</td>\n";
|
||||||
echo " <td>".get_number_of_users()."</td>\n";
|
echo " <td>".User::count()."</td>\n";
|
||||||
echo "</tr>\n\n";
|
echo "</tr>\n\n";
|
||||||
|
|
||||||
/* Display the active users in the last 30 days */
|
/* Display the active users in the last 30 days */
|
||||||
echo "<tr class=color4>\n";
|
echo "<tr class=color4>\n";
|
||||||
echo " <td>Users active within the last 30 days:</td>\n";
|
echo " <td>Users active within the last 30 days:</td>\n";
|
||||||
echo " <td>".get_active_users_within_days(30)."</td>\n";
|
echo " <td>".User::active_users_within_days(30)."</td>\n";
|
||||||
echo "</tr>\n\n";
|
echo "</tr>\n\n";
|
||||||
|
|
||||||
/* Display the active users in the last 60 days */
|
/* Display the active users in the last 60 days */
|
||||||
echo "<tr class=color4>\n";
|
echo "<tr class=color4>\n";
|
||||||
echo " <td>Users active within the last 60 days:</td>\n";
|
echo " <td>Users active within the last 60 days:</td>\n";
|
||||||
echo " <td>".get_active_users_within_days(60)."</td>\n";
|
echo " <td>".User::active_users_within_days(60)."</td>\n";
|
||||||
echo "</tr>\n\n";
|
echo "</tr>\n\n";
|
||||||
|
|
||||||
/* Display the active users in the last 90 days */
|
/* Display the active users in the last 90 days */
|
||||||
echo "<tr class=color4>\n";
|
echo "<tr class=color4>\n";
|
||||||
echo " <td>Users active within the last 90 days:</td>\n";
|
echo " <td>Users active within the last 90 days:</td>\n";
|
||||||
echo " <td>".get_active_users_within_days(90)."</td>\n";
|
echo " <td>".User::active_users_within_days(90)."</td>\n";
|
||||||
echo "</tr>\n\n";
|
echo "</tr>\n\n";
|
||||||
|
|
||||||
/* Display the inactive users */
|
/* Display the inactive users */
|
||||||
echo "<tr class=color4>\n";
|
echo "<tr class=color4>\n";
|
||||||
echo " <td>Inactive users (not logged in since six months):</td>\n";
|
echo " <td>Inactive users (not logged in since six months):</td>\n";
|
||||||
echo " <td>".(get_number_of_users()-get_active_users_within_days(183))."</td>\n";
|
echo " <td>".(User::count()-User::active_users_within_days(183))."</td>\n";
|
||||||
echo "</tr>\n\n";
|
echo "</tr>\n\n";
|
||||||
|
|
||||||
/* Display the users who were warned and pending deletion */
|
/* Display the users who were warned and pending deletion */
|
||||||
echo "<tr class=color4>\n";
|
echo "<tr class=color4>\n";
|
||||||
echo " <td>Inactive users pending deletion:</td>\n";
|
echo " <td>Inactive users pending deletion:</td>\n";
|
||||||
echo " <td>".get_inactive_users_pending_deletion()."</td>\n";
|
echo " <td>".User::get_inactive_users_pending_deletion()."</td>\n";
|
||||||
echo "</tr>\n\n";
|
echo "</tr>\n\n";
|
||||||
|
|
||||||
/* Display the number of comments */
|
/* Display the number of comments */
|
||||||
|
|||||||
@@ -114,7 +114,7 @@ function notifyAdminsOfCleanupStart()
|
|||||||
{
|
{
|
||||||
$sSubject = "Cleanup script starting\r\n";
|
$sSubject = "Cleanup script starting\r\n";
|
||||||
$sMsg = "Appdb cleanup cron script started.\r\n";
|
$sMsg = "Appdb cleanup cron script started.\r\n";
|
||||||
$sEmail = get_notify_email_address_list(null, null); /* get list admins */
|
$sEmail = User::get_notify_email_address_list(null, null); /* get list admins */
|
||||||
if($sEmail)
|
if($sEmail)
|
||||||
mail_appdb($sEmail, $sSubject, $sMsg);
|
mail_appdb($sEmail, $sSubject, $sMsg);
|
||||||
}
|
}
|
||||||
@@ -124,7 +124,7 @@ function notifyAdminsOfCleanupStart()
|
|||||||
/* events of the appdb */
|
/* events of the appdb */
|
||||||
function notifyAdminsOfCleanupExecution($usersWarned, $usersUnwarnedWithData, $usersDeleted, $usersWithData)
|
function notifyAdminsOfCleanupExecution($usersWarned, $usersUnwarnedWithData, $usersDeleted, $usersWithData)
|
||||||
{
|
{
|
||||||
$warnedUsers = get_inactive_users_pending_deletion();
|
$warnedUsers = User::get_inactive_users_pending_deletion();
|
||||||
|
|
||||||
$sSubject = "Cleanup script summary\r\n";
|
$sSubject = "Cleanup script summary\r\n";
|
||||||
$sMsg = "Appdb cleanup cron script executed.\r\n";
|
$sMsg = "Appdb cleanup cron script executed.\r\n";
|
||||||
@@ -135,7 +135,7 @@ function notifyAdminsOfCleanupExecution($usersWarned, $usersUnwarnedWithData, $u
|
|||||||
$sMsg .= "Warned users pending deletion:".$warnedUsers."\r\n";
|
$sMsg .= "Warned users pending deletion:".$warnedUsers."\r\n";
|
||||||
$sMsg .= "Users deleted:".$usersDeleted."\r\n";
|
$sMsg .= "Users deleted:".$usersDeleted."\r\n";
|
||||||
$sMsg .= "Users pending deletion but have appdb data:".$usersWithData."\r\n";
|
$sMsg .= "Users pending deletion but have appdb data:".$usersWithData."\r\n";
|
||||||
$sEmail = get_notify_email_address_list(null, null); /* get list admins */
|
$sEmail = User::get_notify_email_address_list(null, null); /* get list admins */
|
||||||
if($sEmail)
|
if($sEmail)
|
||||||
mail_appdb($sEmail, $sSubject, $sMsg);
|
mail_appdb($sEmail, $sSubject, $sMsg);
|
||||||
}
|
}
|
||||||
@@ -163,7 +163,7 @@ function orphanVersionCheck()
|
|||||||
|
|
||||||
$sSubject = "Versions orphaned in the database\r\n";
|
$sSubject = "Versions orphaned in the database\r\n";
|
||||||
|
|
||||||
$sEmail = get_notify_email_address_list(null, null); /* get list admins */
|
$sEmail = User::get_notify_email_address_list(null, null); /* get list admins */
|
||||||
if($sEmail)
|
if($sEmail)
|
||||||
mail_appdb($sEmail, $sSubject, $sMsg);
|
mail_appdb($sEmail, $sSubject, $sMsg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ class Application {
|
|||||||
addmsg("Application rejected.", "green");
|
addmsg("Application rejected.", "green");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$sEmail = get_notify_email_address_list($this->iAppId);
|
$sEmail = User::get_notify_email_address_list($this->iAppId);
|
||||||
if($sEmail)
|
if($sEmail)
|
||||||
mail_appdb($sEmail, $sSubject ,$sMsg);
|
mail_appdb($sEmail, $sSubject ,$sMsg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,7 +245,7 @@ class Bug {
|
|||||||
addmsg("Bug Link deleted.", "green");
|
addmsg("Bug Link deleted.", "green");
|
||||||
}
|
}
|
||||||
|
|
||||||
$sEmail = get_notify_email_address_list(null, $this->iVersionId);
|
$sEmail = User::get_notify_email_address_list(null, $this->iVersionId);
|
||||||
if($sEmail)
|
if($sEmail)
|
||||||
{
|
{
|
||||||
mail_appdb($sEmail, $sSubject ,$sMsg);
|
mail_appdb($sEmail, $sSubject ,$sMsg);
|
||||||
|
|||||||
@@ -61,7 +61,7 @@ class Comment {
|
|||||||
if($hResult)
|
if($hResult)
|
||||||
{
|
{
|
||||||
$this->comment(mysql_insert_id());
|
$this->comment(mysql_insert_id());
|
||||||
$sEmail = get_notify_email_address_list($this->iAppId, $this->iVersionId);
|
$sEmail = User::get_notify_email_address_list($this->iAppId, $this->iVersionId);
|
||||||
$sEmail .= $this->oOwner->sEmail." ";
|
$sEmail .= $this->oOwner->sEmail." ";
|
||||||
|
|
||||||
// fetches e-mails from parent comments, all parents are notified that a
|
// fetches e-mails from parent comments, all parents are notified that a
|
||||||
@@ -161,7 +161,7 @@ class Comment {
|
|||||||
/* fixup the child comments so the parentId points to a valid parent comment */
|
/* fixup the child comments so the parentId points to a valid parent comment */
|
||||||
$hResult = query_parameters("UPDATE appComments set parentId = '?' WHERE parentId = '?'",
|
$hResult = query_parameters("UPDATE appComments set parentId = '?' WHERE parentId = '?'",
|
||||||
$this->iParentId, $this->iCommentId);
|
$this->iParentId, $this->iCommentId);
|
||||||
$sEmail = get_notify_email_address_list($this->iAppId, $this->iVersionId);
|
$sEmail = User::get_notify_email_address_list($this->iAppId, $this->iVersionId);
|
||||||
$sEmail .= $this->oOwner->sEmail;
|
$sEmail .= $this->oOwner->sEmail;
|
||||||
if($sEmail)
|
if($sEmail)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -356,7 +356,7 @@ class distribution{
|
|||||||
addmsg("Distribution rejected.", "green");
|
addmsg("Distribution rejected.", "green");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$sEmail = get_notify_email_address_list(null, null);
|
$sEmail = User::get_notify_email_address_list(null, null);
|
||||||
if($sEmail)
|
if($sEmail)
|
||||||
mail_appdb($sEmail, $sSubject ,$sMsg);
|
mail_appdb($sEmail, $sSubject ,$sMsg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -126,7 +126,7 @@ class Monitor {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$sEmail = get_notify_email_address_list(null, $this->iVersionId);
|
$sEmail = User::get_notify_email_address_list(null, $this->iVersionId);
|
||||||
if($sEmail)
|
if($sEmail)
|
||||||
mail_appdb($sEmail, $sSubject ,$sMsg);
|
mail_appdb($sEmail, $sSubject ,$sMsg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -153,7 +153,7 @@ class Note {
|
|||||||
addmsg("Note deleted.", "green");
|
addmsg("Note deleted.", "green");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$sEmail = get_notify_email_address_list(null, $this->iVersionId);
|
$sEmail = User::get_notify_email_address_list(null, $this->iVersionId);
|
||||||
if($sEmail)
|
if($sEmail)
|
||||||
mail_appdb($sEmail, $sSubject ,$sMsg);
|
mail_appdb($sEmail, $sSubject ,$sMsg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -288,7 +288,7 @@ class Screenshot {
|
|||||||
addmsg("Screenshot deleted.", "green");
|
addmsg("Screenshot deleted.", "green");
|
||||||
}
|
}
|
||||||
|
|
||||||
$sEmail = get_notify_email_address_list(null, $this->iVersionId);
|
$sEmail = User::get_notify_email_address_list(null, $this->iVersionId);
|
||||||
if($sEmail)
|
if($sEmail)
|
||||||
mail_appdb($sEmail, $sSubject ,$sMsg);
|
mail_appdb($sEmail, $sSubject ,$sMsg);
|
||||||
}
|
}
|
||||||
@@ -404,7 +404,7 @@ function get_thumbnail($id)
|
|||||||
$oScreenshot = new Screenshot($id);
|
$oScreenshot = new Screenshot($id);
|
||||||
|
|
||||||
// generate random tag for popup window
|
// generate random tag for popup window
|
||||||
$randName = generate_passwd(5);
|
$randName = User::generate_passwd(5);
|
||||||
// set img tag
|
// set img tag
|
||||||
$imgSRC = '<img src="'.apidb_fullurl("appimage.php").
|
$imgSRC = '<img src="'.apidb_fullurl("appimage.php").
|
||||||
'?thumbnail=true&id='.$id.'" alt="'.$oScreenshot->sDescription.
|
'?thumbnail=true&id='.$id.'" alt="'.$oScreenshot->sDescription.
|
||||||
|
|||||||
@@ -330,7 +330,7 @@ class testData{
|
|||||||
addmsg("testing data rejected.", "green");
|
addmsg("testing data rejected.", "green");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$sEmail = get_notify_email_address_list(null, $this->iVersionId);
|
$sEmail = User::get_notify_email_address_list(null, $this->iVersionId);
|
||||||
if($sEmail)
|
if($sEmail)
|
||||||
mail_appdb($sEmail, $sSubject ,$sMsg);
|
mail_appdb($sEmail, $sSubject ,$sMsg);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -233,7 +233,7 @@ class Url {
|
|||||||
addmsg("Url deleted.", "green");
|
addmsg("Url deleted.", "green");
|
||||||
}
|
}
|
||||||
|
|
||||||
$sEmail = get_notify_email_address_list(null, $this->iVersionId);
|
$sEmail = User::get_notify_email_address_list(null, $this->iVersionId);
|
||||||
if($sEmail)
|
if($sEmail)
|
||||||
mail_appdb($sEmail, $sSubject ,$sMsg);
|
mail_appdb($sEmail, $sSubject ,$sMsg);
|
||||||
}
|
}
|
||||||
|
|||||||
361
include/user.php
361
include/user.php
@@ -87,7 +87,7 @@ class User {
|
|||||||
*/
|
*/
|
||||||
function create($sEmail, $sPassword, $sRealname, $sWineRelease)
|
function create($sEmail, $sPassword, $sRealname, $sWineRelease)
|
||||||
{
|
{
|
||||||
if(user_exists($sEmail))
|
if(User::exists($sEmail))
|
||||||
{
|
{
|
||||||
return USER_CREATE_EXISTS;
|
return USER_CREATE_EXISTS;
|
||||||
} else
|
} else
|
||||||
@@ -120,7 +120,7 @@ class User {
|
|||||||
if($this->sEmail && ($this->sEmail != $oUser->sEmail))
|
if($this->sEmail && ($this->sEmail != $oUser->sEmail))
|
||||||
{
|
{
|
||||||
/* make sure this email isn't already in use */
|
/* make sure this email isn't already in use */
|
||||||
if(user_exists($this->sEmail))
|
if(User::exists($this->sEmail))
|
||||||
{
|
{
|
||||||
addMsg("An account with this e-mail exists already.","red");
|
addMsg("An account with this e-mail exists already.","red");
|
||||||
return USER_UPDATE_FAILED_EMAIL_EXISTS;
|
return USER_UPDATE_FAILED_EMAIL_EXISTS;
|
||||||
@@ -725,8 +725,181 @@ class User {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Creates a new random password.
|
||||||
|
*/
|
||||||
|
function generate_passwd($pass_len = 10)
|
||||||
|
{
|
||||||
|
$nps = "";
|
||||||
|
mt_srand ((double) microtime() * 1000000);
|
||||||
|
while (strlen($nps)<$pass_len)
|
||||||
|
{
|
||||||
|
$c = chr(mt_rand (0,255));
|
||||||
|
if (eregi("^[a-z0-9]$", $c)) $nps = $nps.$c;
|
||||||
|
}
|
||||||
|
return ($nps);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Check if a user exists.
|
||||||
|
* returns the userid if the user exists
|
||||||
|
*/
|
||||||
|
function exists($sEmail)
|
||||||
|
{
|
||||||
|
$hResult = query_parameters("SELECT userid FROM user_list WHERE email = '?'",
|
||||||
|
$sEmail);
|
||||||
|
if(!$hResult || mysql_num_rows($hResult) != 1)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
} else
|
||||||
|
{
|
||||||
|
$oRow = mysql_fetch_object($hResult);
|
||||||
|
return $oRow->userid;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the number of users in the database
|
||||||
|
*/
|
||||||
|
function count()
|
||||||
|
{
|
||||||
|
$hResult = query_parameters("SELECT count(*) as num_users FROM user_list;");
|
||||||
|
$oRow = mysql_fetch_object($hResult);
|
||||||
|
return $oRow->num_users;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the number of active users within $days of the current day
|
||||||
|
*/
|
||||||
|
function active_users_within_days($days)
|
||||||
|
{
|
||||||
|
$hResult = query_parameters("SELECT count(*) as num_users FROM user_list WHERE stamp >= DATE_SUB(CURDATE(), interval '?' day);",
|
||||||
|
$days);
|
||||||
|
$oRow = mysql_fetch_object($hResult);
|
||||||
|
return $oRow->num_users;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the count of users who have been warned for inactivity and are
|
||||||
|
* pending deletion after the X month grace period
|
||||||
|
*/
|
||||||
|
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 = mysql_fetch_object($hResult);
|
||||||
|
return $oRow->count;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the email address of people to notify for this appId and versionId.
|
||||||
|
*/
|
||||||
|
function get_notify_email_address_list($iAppId = null, $iVersionId = null)
|
||||||
|
{
|
||||||
|
$aUserId = array();
|
||||||
|
$c = 0;
|
||||||
|
$retval = "";
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve version maintainers.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* If versionId was supplied we fetch supermaintainers of application and maintainer of version.
|
||||||
|
*/
|
||||||
|
if($iVersionId)
|
||||||
|
{
|
||||||
|
$hResult = query_parameters("SELECT appMaintainers.userId
|
||||||
|
FROM appMaintainers, appVersion
|
||||||
|
WHERE appVersion.appId = appMaintainers.appId
|
||||||
|
AND appVersion.versionId = '?'",
|
||||||
|
$iVersionId);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* If versionId was not supplied we fetch supermaintainers of application and maintainer of all versions.
|
||||||
|
*/
|
||||||
|
elseif($iAppId)
|
||||||
|
{
|
||||||
|
$hResult = query_parameters("SELECT userId
|
||||||
|
FROM appMaintainers
|
||||||
|
WHERE appId = '?'",
|
||||||
|
$iAppId);
|
||||||
|
}
|
||||||
|
|
||||||
|
if($hResult)
|
||||||
|
{
|
||||||
|
if(mysql_num_rows($hResult) > 0)
|
||||||
|
{
|
||||||
|
while($oRow = mysql_fetch_object($hResult))
|
||||||
|
{
|
||||||
|
$aUserId[$c] = array($oRow->userId);
|
||||||
|
$c++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve version Monitors.
|
||||||
|
*/
|
||||||
|
/*
|
||||||
|
* If versionId was supplied we fetch superMonitors of application and Monitors of version.
|
||||||
|
*/
|
||||||
|
if($iVersionId)
|
||||||
|
{
|
||||||
|
$hResult = query_parameters("SELECT appMonitors.userId
|
||||||
|
FROM appMonitors, appVersion
|
||||||
|
WHERE appVersion.appId = appMonitors.appId
|
||||||
|
AND appVersion.versionId = '?'",
|
||||||
|
$iVersionId);
|
||||||
|
}
|
||||||
|
/*
|
||||||
|
* If versionId was not supplied we fetch superMonitors of application and Monitors of all versions.
|
||||||
|
*/
|
||||||
|
elseif($iAppId)
|
||||||
|
{
|
||||||
|
$hResult = query_parameters("SELECT userId
|
||||||
|
FROM appMonitors
|
||||||
|
WHERE appId = '?'",
|
||||||
|
$iAppId);
|
||||||
|
}
|
||||||
|
if($hResult)
|
||||||
|
{
|
||||||
|
if(mysql_num_rows($hResult) > 0)
|
||||||
|
{
|
||||||
|
while($oRow = mysql_fetch_object($hResult))
|
||||||
|
{
|
||||||
|
$aUserId[$c] = array($oRow->userId);
|
||||||
|
$c++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Retrieve administrators.
|
||||||
|
*/
|
||||||
|
$hResult = query_parameters("SELECT * FROM user_privs WHERE priv = 'admin'");
|
||||||
|
if(mysql_num_rows($hResult) > 0)
|
||||||
|
{
|
||||||
|
while($oRow = mysql_fetch_object($hResult))
|
||||||
|
{
|
||||||
|
$i = array_search($oRow->userid, $aUserId);
|
||||||
|
if ($aUserId[$i] != array($oRow->userid))
|
||||||
|
{
|
||||||
|
$aUserId[$c] = array($oRow->userid);
|
||||||
|
$c++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if ($c > 0)
|
||||||
|
{
|
||||||
|
while(list($index, list($userIdValue)) = each($aUserId))
|
||||||
|
{
|
||||||
|
$oUser = new User($userIdValue);
|
||||||
|
if ($oUser->wantsEmail())
|
||||||
|
$retval .= $oUser->sEmail." ";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return $retval;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/************************/
|
/************************/
|
||||||
@@ -1019,188 +1192,4 @@ class User {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* User functions that are not part of the class
|
|
||||||
*/
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Creates a new random password.
|
|
||||||
*/
|
|
||||||
function generate_passwd($pass_len = 10)
|
|
||||||
{
|
|
||||||
$nps = "";
|
|
||||||
mt_srand ((double) microtime() * 1000000);
|
|
||||||
while (strlen($nps)<$pass_len)
|
|
||||||
{
|
|
||||||
$c = chr(mt_rand (0,255));
|
|
||||||
if (eregi("^[a-z0-9]$", $c)) $nps = $nps.$c;
|
|
||||||
}
|
|
||||||
return ($nps);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the email address of people to notify for this appId and versionId.
|
|
||||||
*/
|
|
||||||
function get_notify_email_address_list($iAppId = null, $iVersionId = null)
|
|
||||||
{
|
|
||||||
$aUserId = array();
|
|
||||||
$c = 0;
|
|
||||||
$retval = "";
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Retrieve version maintainers.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* If versionId was supplied we fetch supermaintainers of application and maintainer of version.
|
|
||||||
*/
|
|
||||||
if($iVersionId)
|
|
||||||
{
|
|
||||||
$hResult = query_parameters("SELECT appMaintainers.userId
|
|
||||||
FROM appMaintainers, appVersion
|
|
||||||
WHERE appVersion.appId = appMaintainers.appId
|
|
||||||
AND appVersion.versionId = '?'",
|
|
||||||
$iVersionId);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* If versionId was not supplied we fetch supermaintainers of application and maintainer of all versions.
|
|
||||||
*/
|
|
||||||
elseif($iAppId)
|
|
||||||
{
|
|
||||||
$hResult = query_parameters("SELECT userId
|
|
||||||
FROM appMaintainers
|
|
||||||
WHERE appId = '?'",
|
|
||||||
$iAppId);
|
|
||||||
}
|
|
||||||
|
|
||||||
if($hResult)
|
|
||||||
{
|
|
||||||
if(mysql_num_rows($hResult) > 0)
|
|
||||||
{
|
|
||||||
while($oRow = mysql_fetch_object($hResult))
|
|
||||||
{
|
|
||||||
$aUserId[$c] = array($oRow->userId);
|
|
||||||
$c++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Retrieve version Monitors.
|
|
||||||
*/
|
|
||||||
/*
|
|
||||||
* If versionId was supplied we fetch superMonitors of application and Monitors of version.
|
|
||||||
*/
|
|
||||||
if($iVersionId)
|
|
||||||
{
|
|
||||||
$hResult = query_parameters("SELECT appMonitors.userId
|
|
||||||
FROM appMonitors, appVersion
|
|
||||||
WHERE appVersion.appId = appMonitors.appId
|
|
||||||
AND appVersion.versionId = '?'",
|
|
||||||
$iVersionId);
|
|
||||||
}
|
|
||||||
/*
|
|
||||||
* If versionId was not supplied we fetch superMonitors of application and Monitors of all versions.
|
|
||||||
*/
|
|
||||||
elseif($iAppId)
|
|
||||||
{
|
|
||||||
$hResult = query_parameters("SELECT userId
|
|
||||||
FROM appMonitors
|
|
||||||
WHERE appId = '?'",
|
|
||||||
$iAppId);
|
|
||||||
}
|
|
||||||
if($hResult)
|
|
||||||
{
|
|
||||||
if(mysql_num_rows($hResult) > 0)
|
|
||||||
{
|
|
||||||
while($oRow = mysql_fetch_object($hResult))
|
|
||||||
{
|
|
||||||
$aUserId[$c] = array($oRow->userId);
|
|
||||||
$c++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
|
||||||
* Retrieve administrators.
|
|
||||||
*/
|
|
||||||
$hResult = query_parameters("SELECT * FROM user_privs WHERE priv = 'admin'");
|
|
||||||
if(mysql_num_rows($hResult) > 0)
|
|
||||||
{
|
|
||||||
while($oRow = mysql_fetch_object($hResult))
|
|
||||||
{
|
|
||||||
$i = array_search($oRow->userid, $aUserId);
|
|
||||||
if ($aUserId[$i] != array($oRow->userid))
|
|
||||||
{
|
|
||||||
$aUserId[$c] = array($oRow->userid);
|
|
||||||
$c++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if ($c > 0)
|
|
||||||
{
|
|
||||||
while(list($index, list($userIdValue)) = each($aUserId))
|
|
||||||
{
|
|
||||||
$oUser = new User($userIdValue);
|
|
||||||
if ($oUser->wantsEmail())
|
|
||||||
$retval .= $oUser->sEmail." ";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return $retval;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the number of users in the database
|
|
||||||
*/
|
|
||||||
function get_number_of_users()
|
|
||||||
{
|
|
||||||
$hResult = query_parameters("SELECT count(*) as num_users FROM user_list;");
|
|
||||||
$oRow = mysql_fetch_object($hResult);
|
|
||||||
return $oRow->num_users;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the number of active users within $days of the current day
|
|
||||||
*/
|
|
||||||
function get_active_users_within_days($days)
|
|
||||||
{
|
|
||||||
$hResult = query_parameters("SELECT count(*) as num_users FROM user_list WHERE stamp >= DATE_SUB(CURDATE(), interval '?' day);",
|
|
||||||
$days);
|
|
||||||
$oRow = mysql_fetch_object($hResult);
|
|
||||||
return $oRow->num_users;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the count of users who have been warned for inactivity and are
|
|
||||||
* pending deletion after the X month grace period
|
|
||||||
*/
|
|
||||||
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 = mysql_fetch_object($hResult);
|
|
||||||
return $oRow->count;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Check if a user exists.
|
|
||||||
* returns the userid if the user exists
|
|
||||||
*/
|
|
||||||
function user_exists($sEmail)
|
|
||||||
{
|
|
||||||
$hResult = query_parameters("SELECT userid FROM user_list WHERE email = '?'",
|
|
||||||
$sEmail);
|
|
||||||
if(!$hResult || mysql_num_rows($hResult) != 1)
|
|
||||||
{
|
|
||||||
return 0;
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
$oRow = mysql_fetch_object($hResult);
|
|
||||||
return $oRow->userid;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
?>
|
?>
|
||||||
|
|||||||
@@ -649,7 +649,7 @@ function process_app_version_changes($isVersion)
|
|||||||
}
|
}
|
||||||
if ($bAppChanged)
|
if ($bAppChanged)
|
||||||
{
|
{
|
||||||
$sEmail = get_notify_email_address_list($_REQUEST['appId']);
|
$sEmail = User::get_notify_email_address_list($_REQUEST['appId']);
|
||||||
$oApp = new Application($_REQUEST['appId']);
|
$oApp = new Application($_REQUEST['appId']);
|
||||||
if($sEmail)
|
if($sEmail)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -514,7 +514,7 @@ class Version {
|
|||||||
addmsg("Version rejected.", "green");
|
addmsg("Version rejected.", "green");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
$sEmail = get_notify_email_address_list(null, $this->iVersionId);
|
$sEmail = User::get_notify_email_address_list(null, $this->iVersionId);
|
||||||
if($sEmail)
|
if($sEmail)
|
||||||
mail_appdb($sEmail, $sSubject ,$sMsg);
|
mail_appdb($sEmail, $sSubject ,$sMsg);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user