Domainadmin patch
This commit is contained in:
@@ -222,6 +222,8 @@ class DBEngine {
|
||||
return $return;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// User methods -------------------------------------------
|
||||
|
||||
/**
|
||||
@@ -229,7 +231,7 @@ class DBEngine {
|
||||
* @param string full email address
|
||||
* @return array of the 5 counts
|
||||
*/
|
||||
function get_user_summary($emailaddresses) {
|
||||
function get_user_summary($emailaddresses,$domainsonly=false) {
|
||||
|
||||
global $conf;
|
||||
|
||||
@@ -237,7 +239,7 @@ class DBEngine {
|
||||
$total = array('spam' => 0, 'banned' => 0, 'virus' => 0, 'header' => 0, 'pending' => 0, 'total' => 0);
|
||||
|
||||
// Get where clause for recipient email address(es)
|
||||
$recipEmailClause = $this->convertEmailaddresses2SQL($emailaddresses);
|
||||
$recipEmailClause = $this->convertEmailaddresses2SQL($emailaddresses,$domainsonly);
|
||||
|
||||
# mysql seems to run faster with a left join
|
||||
if ($conf['db']['dbtype'] == 'mysql') {
|
||||
@@ -361,7 +363,7 @@ class DBEngine {
|
||||
* @param boolean $get_all, if true get all messages. False by default.
|
||||
* @return array of messages in quarantine
|
||||
*/
|
||||
function get_user_messages($content_type, $emailaddresses, $order = 'msgs.time_num', $vert = 'DESC', $search_array = '', $msgs_all = false, $rs_option = 0, $page = 0, $get_all = false) {
|
||||
function get_user_messages($content_type, $emailaddresses, $order = 'msgs.time_num', $vert = 'DESC', $search_array = '', $msgs_all = false, $rs_option = 0, $page = 0, $get_all = false, $domainsonly = false) {
|
||||
|
||||
global $conf;
|
||||
|
||||
@@ -385,10 +387,10 @@ class DBEngine {
|
||||
}
|
||||
}
|
||||
|
||||
if ( ! $msgs_all ) {
|
||||
if ( ! $msgs_all) {
|
||||
// Get where clause for recipient email address(es)
|
||||
$emailaddr_clause = ( ! empty($emailaddresses) ?
|
||||
' AND ' . $this->convertEmailaddresses2SQL($emailaddresses) :
|
||||
' AND ' . $this->convertEmailaddresses2SQL($emailaddresses, $domainsonly) :
|
||||
'' );
|
||||
}
|
||||
|
||||
@@ -406,7 +408,7 @@ class DBEngine {
|
||||
$rs_clause = '';
|
||||
}
|
||||
|
||||
if ( Auth::isMailAdmin() ) {
|
||||
if ( Auth::isMailAdmin() || Auth::isDomainAdmin() ) {
|
||||
$type_clause = ($content_type == 'A' ? ' msgs.content in (\'S\', \'B\', \'V\', \'H\')'
|
||||
: ' msgs.content=?');
|
||||
} else {
|
||||
@@ -433,7 +435,6 @@ class DBEngine {
|
||||
$search_clause
|
||||
AND msgs.quar_type <> ''
|
||||
ORDER BY $order $vert ";
|
||||
|
||||
// Prepare query
|
||||
$q = $this->db->prepare($query);
|
||||
|
||||
@@ -737,7 +738,7 @@ class DBEngine {
|
||||
* @param array $emailaddresses list of email address(es)
|
||||
* @return string containing SQL code
|
||||
*/
|
||||
function convertEmailaddresses2SQL($emailaddresses) {
|
||||
function convertEmailaddresses2SQL($emailaddresses, $domainsonly=false) {
|
||||
|
||||
global $conf;
|
||||
$result = '';
|
||||
@@ -746,18 +747,23 @@ class DBEngine {
|
||||
if ( is_array($emailaddresses) && !empty($emailaddresses) ) {
|
||||
foreach ( $emailaddresses as $value ) {
|
||||
// Append an address to lookup
|
||||
$emailtuple .= ( $emailtuple != '' ? ", '$value'" : "'$value'" );
|
||||
}
|
||||
$result = " recip.email in ($emailtuple) ";
|
||||
|
||||
// Configured to support recipient delimiters?
|
||||
if(!empty($conf['recipient_delimiter']) ) {
|
||||
$delimiter = $conf['recipient_delimiter'];
|
||||
foreach ( $emailaddresses as $value ) {
|
||||
// separate localpart and domain
|
||||
if ($domainsonly) {
|
||||
list($localpart, $domain) = explode("@", $value);
|
||||
// Append any recipient delimited addresses
|
||||
$result .= "OR recip.email LIKE '$localpart$delimiter%@$domain' ";
|
||||
$value = "%@".$domain;
|
||||
}
|
||||
$emailtuple .= ( $emailtuple != '' ? " OR recip.email LIKE '$value'" : "'$value'" );
|
||||
}
|
||||
$result = " recip.email LIKE $emailtuple ";
|
||||
if (!$domainsonly) {
|
||||
// Configured to support recipient delimiters?
|
||||
if(!empty($conf['recipient_delimiter']) ) {
|
||||
$delimiter = $conf['recipient_delimiter'];
|
||||
foreach ( $emailaddresses as $value ) {
|
||||
// separate localpart and domain
|
||||
list($localpart, $domain) = explode("@", $value);
|
||||
// Append any recipient delimited addresses
|
||||
$result .= "OR recip.email LIKE '$localpart$delimiter%@$domain' ";
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user