This commit is contained in:
Mario Fetka 2014-04-16 11:25:38 +02:00
parent d21230a2ed
commit 401edac1a7
2 changed files with 24 additions and 25 deletions

View File

@ -132,35 +132,35 @@ class DBEngine {
MAX(stattable.pending) AS pending
FROM (
SELECT CAST(time_iso AS DATE) AS date,
COUNT(content) AS spam,
COUNT(msgs.content) AS spam,
0 AS banned,
0 AS viruses,
0 AS badheaders,
0 AS pending
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
WHERE content='S' AND NOT (msgs.quar_type = '')
WHERE msgs.content='S' AND NOT (msgs.quar_type = '')
AND msgrcpt.rs IN ('','v')
GROUP BY CAST(time_iso AS DATE)
UNION
SELECT CAST(time_iso AS DATE) AS date,
0 AS spam,
COUNT(content) AS banned,
COUNT(msgs.content) AS banned,
0 AS viruses,
0 AS badheaders,
0 AS pending
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
WHERE content='B' AND NOT (msgs.quar_type = '')
WHERE msgs.content='B' AND NOT (msgs.quar_type = '')
AND msgrcpt.rs IN ('','v')
GROUP BY CAST(time_iso AS DATE)
UNION
SELECT CAST(time_iso AS DATE) AS date,
0 AS spam,
0 AS banned,
COUNT(content) AS viruses,
COUNT(msgs.content) AS viruses,
0 AS badheaders,
0 AS pending
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
WHERE content='V' AND NOT (msgs.quar_type = '')
WHERE msgs.content='V' AND NOT (msgs.quar_type = '')
AND msgrcpt.rs IN ('','v')
GROUP BY CAST(time_iso AS DATE)
UNION
@ -168,10 +168,10 @@ class DBEngine {
0 AS spam,
0 AS banned,
0 AS viruses,
COUNT(content) AS badheaders,
COUNT(msgs.content) AS badheaders,
0 AS pending
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
WHERE content='H' AND NOT (msgs.quar_type = '')
WHERE msgs.content='H' AND NOT (msgs.quar_type = '')
AND msgrcpt.rs IN ('','v')
GROUP BY CAST(time_iso AS DATE)
UNION
@ -180,7 +180,7 @@ class DBEngine {
0 AS banned,
0 AS viruses,
0 AS badheaders,
COUNT(content) AS pending
COUNT(msgs.content) AS pending
FROM msgs JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
WHERE msgrcpt.rs='p' AND NOT (msgs.quar_type = '')
GROUP BY CAST(time_iso AS DATE)
@ -188,7 +188,6 @@ class DBEngine {
GROUP BY date
ORDER BY date";
// Prepare query
$q = $this->db->prepare($query);
// Execute query
@ -253,38 +252,38 @@ class DBEngine {
MAX(stattable.pending) AS pending
FROM (
SELECT CAST(time_iso AS DATE) AS date,
COUNT(content) AS spam,
COUNT(msgs.content) AS spam,
0 AS banned,
0 AS viruses,
0 AS badheaders,
0 AS pending
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
$join_type maddr AS recip ON msgrcpt.rid=recip.id
WHERE content='S' AND NOT (msgs.quar_type = '') AND msgrcpt.rs IN ('','v')
WHERE msgs.content='S' AND NOT (msgs.quar_type = '') AND msgrcpt.rs IN ('','v')
AND $recipEmailClause
GROUP BY CAST(time_iso AS DATE)
UNION
SELECT CAST(time_iso AS DATE) AS date,
0 AS spam,
COUNT(content) AS banned,
COUNT(msgs.content) AS banned,
0 AS viruses,
0 AS badheaders,
0 AS pending
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
$join_type maddr AS recip ON msgrcpt.rid=recip.id
WHERE content='B' AND NOT (msgs.quar_type = '') AND msgrcpt.rs IN ('','v')
WHERE msgs.content='B' AND NOT (msgs.quar_type = '') AND msgrcpt.rs IN ('','v')
AND $recipEmailClause
GROUP BY CAST(time_iso AS DATE)
UNION
SELECT CAST(time_iso AS DATE) AS date,
0 AS spam,
0 AS banned,
COUNT(content) AS viruses,
COUNT(msgs.content) AS viruses,
0 AS badheaders,
0 AS pending
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
$join_type maddr AS recip ON msgrcpt.rid=recip.id
WHERE content='V' AND NOT (msgs.quar_type = '') AND msgrcpt.rs IN ('','v')
WHERE msgs.content='V' AND NOT (msgs.quar_type = '') AND msgrcpt.rs IN ('','v')
AND $recipEmailClause
GROUP BY CAST(time_iso AS DATE)
UNION
@ -292,11 +291,11 @@ class DBEngine {
0 AS spam,
0 AS banned,
0 AS viruses,
COUNT(content) AS badheaders,
COUNT(msgs.content) AS badheaders,
0 AS pending
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
$join_type maddr AS recip ON msgrcpt.rid=recip.id
WHERE content='H' AND NOT (msgs.quar_type = '') AND msgrcpt.rs IN ('','v')
WHERE msgs.content='H' AND NOT (msgs.quar_type = '') AND msgrcpt.rs IN ('','v')
AND $recipEmailClause
GROUP BY CAST(time_iso AS DATE)
UNION
@ -305,7 +304,7 @@ class DBEngine {
0 AS banned,
0 AS viruses,
0 AS badheaders,
COUNT(content) AS pending
COUNT(msgs.content) AS pending
FROM msgs INNER JOIN msgrcpt ON msgs.mail_id=msgrcpt.mail_id
$join_type maddr AS recip ON msgrcpt.rid=recip.id
WHERE msgrcpt.rs='p' AND NOT (msgs.quar_type = '')

View File

@ -65,9 +65,9 @@ function releaseMessages($emailaddresses, $mail_id_array) {
foreach ($mail_id_array as $mail_id_recip) {
// Get mail_id and recipient email address
$temp = preg_split('/_/', $mail_id_recip, 2);
$mail_id = $temp[0];
$recip_email = $temp[1];
$temp = preg_split('/_/', $mail_id_recip);
$mail_id = str_replace("_" . $temp[(sizeof($temp) - 1)], "", $mail_id_recip);
$recip_email = $temp[(sizeof($temp) - 1)];
// Check if logged in user is admin or logged in user is trying to release his own messages
if ( Auth::isMailAdmin() || Auth::isDomainAdmin() || in_array($recip_email, $emailaddresses) )
@ -258,9 +258,9 @@ function updateMessages($flag, $content_type, $emailaddresses, $mail_id_array, $
foreach ($mail_id_array as $mail_id_recip) {
// Get mail_id and recipient email address
$temp = preg_split('/_/', $mail_id_recip, 2);
$mail_id = $temp[0];
$recip_email = $temp[1];
$temp = preg_split('/_/', $mail_id_recip);
$mail_id = str_replace("_" . $temp[(sizeof($temp) - 1)], "", $mail_id_recip);
$recip_email = $temp[(sizeof($temp) - 1)];
// Check if logged in user is admin or logged in user is trying to delete his own messages
if ( Auth::isMailAdmin() || Auth::isDomainAdmin() || in_array($recip_email, $emailaddresses) ) {