diff --git a/admin/adminMaintainers.php b/admin/adminMaintainers.php index c2588df..db9221c 100644 --- a/admin/adminMaintainers.php +++ b/admin/adminMaintainers.php @@ -16,99 +16,98 @@ if(!$_SESSION['current']->hasPriv("admin")) apidb_header("Admin Maintainers"); echo '
"; diff --git a/contact.php b/contact.php index 4635322..cafb40f 100644 --- a/contact.php +++ b/contact.php @@ -17,11 +17,40 @@ if(!$oUser->isLoggedIn()) exit; } +$oRecipient = null; +$sRecipientText = ''; +$iRecipientId = null; +$sRecipientGroup = getInput('sRecipientGroup', $aClean); +$sRecipients = ''; -$oRecipient = new User($aClean['iRecipientId']); +if($sRecipientGroup) +{ + if(!$oUser->hasPriv('admin')) + util_show_error_page_and_exit("Only admins can do this"); -if(!User::exists($oRecipient->sEmail)) - util_show_error_page_and_exit("User not found"); + switch($sRecipientGroup) + { + case 'maintainers': + $sRecipientText = 'all maintainers'; + $sRecipients = maintainer::getSubmitterEmails(); + if($sRecipients === FALSE) + util_show_error_page_and_exit("Failed to get list of maintainers"); + break; + + default: + util_show_error_page_and_exit("Invalid recipient group"); + } +} else +{ + $oRecipient = new User($aClean['iRecipientId']); + $iRecipientId = $oRecipient->iUserId; + $sRecipients = $oRecipient->sEmail; + + if(!User::exists($oRecipient->sEmail)) + util_show_error_page_and_exit("User not found"); + + $sRecipientText = $oRecipient->sRealname; +} /* Check for errors */ if((!$aClean['sMessage'] || !$aClean['sSubject']) && $aClean['sSubmit']) @@ -34,28 +63,29 @@ if((!$aClean['sMessage'] || !$aClean['sSubject']) && $aClean['sSubmit']) /* Display the feedback form if nothing else is specified */ if(!$aClean['sSubmit']) { - apidb_header("E-mail $oRecipient->sRealname"); - echo html_frame_start("Send us your suggestions",400,"",0); + apidb_header("E-mail $sRecipientText"); + echo ' '; + echo html_frame_start("Composer",400,"",0); echo $error; echo "\n"; @@ -91,19 +124,26 @@ if(!$aClean['sSubmit']) } else if ($aClean['sSubject'] && $aClean['sMessage']) { - $sSubjectRe = $aClean['sSubject']; - if(substr($sSubjectRe, 0, 4) != "Re: ") - $sSubjectRe = "Re: $sSubjectRe"; + if($oRecipient) + { + $sSubjectRe = $aClean['sSubject']; + if(substr($sSubjectRe, 0, 4) != "Re: ") + $sSubjectRe = "Re: $sSubjectRe"; - $sSubjectRe = urlencode($sSubjectRe); + $sSubjectRe = urlencode($sSubjectRe); - $sMsg = "The following message was sent to you from $oUser->sRealname "; - $sMsg .= "through the Wine AppDB contact form.\nTo Reply, visit "; - $sMsg .= APPDB_ROOT."contact.php?iRecipientId=$oUser->iUserId&sSubject="; - $sMsg .= $sSubjectRe."\n\n"; - $sMsg .= $aClean['sMessage']; + $sMsg = "The following message was sent to you from $oUser->sRealname "; + $sMsg .= "through the Wine AppDB contact form.\nTo Reply, visit "; + $sMsg .= APPDB_ROOT."contact.php?iRecipientId=$oUser->iUserId&sSubject="; + $sMsg .= $sSubjectRe."\n\n"; + $sMsg .= $aClean['sMessage']; + } else + { + $sMsg = "The following message was sent to you by the AppDB admins:\n\n"; + $sMsg .= $aClean['sMessage']; + } - mail_appdb($oRecipient->sEmail, $aClean['sSubject'], $sMsg); + mail_appdb($sRecipients, $aClean['sSubject'], $sMsg); util_redirect_and_exit(BASE."index.php"); } diff --git a/include/maintainer.php b/include/maintainer.php index 9a7e633..54a4b31 100644 --- a/include/maintainer.php +++ b/include/maintainer.php @@ -395,6 +395,25 @@ class maintainer return $hResult; } + function getSubmitterEmails() + { + $sRecipients = ''; + $sQuery = "SELECT DISTINCT(user_list.email) FROM appMaintainers, user_list WHERE + appMaintainers.userId = user_list.userId + AND + appMaintainers.state = 'accepted'"; + $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; + } + function ObjectGetEntries($sState, $iRows = 0, $iStart = 0, $sOrderBy = '', $bAscending = true) { /* Not implemented */