[AppDB] Add function for admin-only emails
Rosanne DiMesio
dimesio at earthlink.net
Fri Aug 4 12:43:35 CDT 2017
Adds function getAdminEmails to handle emails meant specifically
for admins and removes the check for appId/versionId from
get_notify_email_address_list that was sending emails
to admins when it shouldn't. Fixes bug 28661.
Signed-off-by: Rosanne DiMesio <dimesio at earthlink.net>
---
cron/cleanup.php | 8 ++++----
include/error_log.php | 2 +-
include/user.php | 24 ++++++++++++++++++++----
3 files changed, 25 insertions(+), 9 deletions(-)
diff --git a/cron/cleanup.php b/cron/cleanup.php
index 4f44660..08ba100 100644
--- a/cron/cleanup.php
+++ b/cron/cleanup.php
@@ -41,7 +41,7 @@ function notifyAdminsOfCleanupStart()
$sSubject = $sEmailSubject."Cleanup script starting\r\n";
$sMsg = "Appdb cleanup cron script started.\r\n";
- $sEmail = User::get_notify_email_address_list(null, null); /* get list admins */
+ $sEmail = user::getAdminEmails(); /* get list admins */
if($sEmail)
mail_appdb($sEmail, $sSubject, $sMsg);
}
@@ -71,7 +71,7 @@ function orphanVersionCheck()
$sSubject = $sEmailSubject."Orphan version cleanup\r\n";
- $sEmail = User::get_notify_email_address_list(null, null); /* get list admins */
+ $sEmail = user::getAdminEmails(); /* get list admins */
if($sEmail)
mail_appdb($sEmail, $sSubject, $sMsg);
}
@@ -148,7 +148,7 @@ function removeScreenshotsWithMissingFiles()
$sSubject = $sEmailSubject."Missing screenshot cleanup\r\n";
- $sEmail = User::get_notify_email_address_list(null, null); /* get list admins */
+ $sEmail = user::getAdminEmails(); /* get list admins */
if($sEmail)
mail_appdb($sEmail, $sSubject, $sMsg);
@@ -200,7 +200,7 @@ function cleanupVotes()
$iFailed++;
}
- $sEmails = user::get_notify_email_address_list(null, null); // only admins
+ $sEmails = user::getAdminEmails(); // only admins
if($sEmails)
{
diff --git a/include/error_log.php b/include/error_log.php
index 1bbbd0f..73ea208 100644
--- a/include/error_log.php
+++ b/include/error_log.php
@@ -64,7 +64,7 @@ class error_log
function mail_admins_error_log($sSubject = "")
{
$sSubject .= "Database Error log\r\n";
- $sEmail = User::get_notify_email_address_list(null, null); /* get list admins */
+ $sEmail = user::getAdminEmails(); /* get list admins */
$sQuery = "SELECT * from error_log WHERE deleted='0' ORDER BY submitTime";
$hResult = query_parameters($sQuery);
diff --git a/include/user.php b/include/user.php
index 073f6e7..ff6b0fa 100644
--- a/include/user.php
+++ b/include/user.php
@@ -537,11 +537,8 @@ class User {
// if we didn't find this entry in the $aUserId
// array then we should add it if the admin has
// enabled global emails.
- // If both appId and versionId are null we are especially
- // requesting to email admins, so the mail should be sent
- // regardless of global emails setting
$oAdmin = new user($oRow->userid);
- if($i === false && ($oAdmin->getPref('disable_global_emails','no') == 'no' || (!$iAppId && !$iVersionId)))
+ if($i === false && $oAdmin->getPref('disable_global_emails','no') == 'no')
$aUserId[] = $oRow->userid;
}
}
@@ -560,6 +557,25 @@ class User {
return $sRetval;
}
+
+ public static function getAdminEmails()
+ {
+ $sRecipients = '';
+ $sQuery = "SELECT DISTINCT(user_list.email) FROM user_privs, user_list WHERE
+ user_privs.userid = user_list.userId
+ AND
+ user_privs.priv= 'admin'";
+ $hResult = query_parameters($sQuery);
+ if(!$hResult)
+ return FALSE;
+ for($i = 0; $oRow = query_fetch_object($hResult); $i++)
+ {
+ if($i)
+ $sRecipients .= ' ';
+ $sRecipients .= $oRow->email;
+ }
+ return $sRecipients;
+ }
/************************/
--
2.12.3
More information about the wine-patches
mailing list