From 29aca5c21898ad71bbb537bf533a8adf0e74978d Mon Sep 17 00:00:00 2001 From: pb1dft Date: Thu, 9 Nov 2006 01:37:19 +0000 Subject: Fixed mail threshold and added user ability to change it --- admin/mail.php | 7 ++++--- lib/class/stats.class.php | 10 +++++++--- templates/show_mail_users.inc.php | 7 +++++++ 3 files changed, 18 insertions(+), 6 deletions(-) diff --git a/admin/mail.php b/admin/mail.php index df48b5b2..cdab5c36 100644 --- a/admin/mail.php +++ b/admin/mail.php @@ -34,6 +34,7 @@ if (isset ($_POST['cat_stats'])){$cat_stats = scrub_in($_POST['cat_stats']);} if (isset ($_POST['pop_albums'])){$pop_albums = scrub_in($_POST['pop_albums']);} if (isset ($_POST['pop_artists'])){$pop_artists = scrub_in($_POST['pop_artists']);} if (isset ($_POST['pop_songs'])){$pop_songs = scrub_in($_POST['pop_songs']);} +if (isset ($_POST['threshold'])){$threshold = scrub_in($_POST['threshold']);} else { $threshold = conf($stats_threshold); }; if (isset ($_POST['new_artists'])){$new_artists = scrub_in($_POST['new_artists']);} if (isset ($_POST['new_albums'])){$new_albums = scrub_in($_POST['new_albums']);} $subject = stripslashes(scrub_in($_POST['subject'])); @@ -142,7 +143,7 @@ switch ($action) { if (isset ($pop_albums)){ $message .= "\n\nMost Popular Albums\n\n"; $stats = new Stats(); - $stats = $stats->get_top('10','album'); + $stats = $stats->get_top('10','album',$threshold); foreach( $stats as $r){ $album = new Album($r[object_id]); @@ -154,7 +155,7 @@ switch ($action) { if (isset ($pop_artists)){ $message .= "\n\nMost Popular Artists\n\n"; $stats = new Stats(); - $stats = $stats->get_top('10','artist'); + $stats = $stats->get_top('10','artist',$threshold); foreach( $stats as $r){ $artist = new Artist($r[object_id]); @@ -167,7 +168,7 @@ switch ($action) { $message .= "\n\nMost Popular Songs\n\n"; $stats = new Stats(); - $stats = $stats->get_top('10','song'); + $stats = $stats->get_top('10','song',$threshold); foreach( $stats as $r){ $song = new Song($r[object_id]); diff --git a/lib/class/stats.class.php b/lib/class/stats.class.php index ee4fb3aa..7ccb3d60 100644 --- a/lib/class/stats.class.php +++ b/lib/class/stats.class.php @@ -73,12 +73,16 @@ class Stats { * This returns the top X for type Y from the * last conf('stats_threshold') days */ - function get_top($count,$type) { + function get_top($count,$type,$threshold = '') { $count = intval($count); $type = $this->validate_type($type); - $date = time() - (86400*conf('stats_threshold')); - + if (empty($threshold)){ + $date = time() - (86400*conf('stats_threshold')); + } + else { + $date = time() - (86400*$threshold); + } /* Select Top objects counting by # of rows */ $sql = "SELECT object_id,COUNT(id) AS `count` FROM object_count" . " WHERE object_type='$type' AND date >= '$date'" . diff --git a/templates/show_mail_users.inc.php b/templates/show_mail_users.inc.php index ff9740c0..a8157d21 100644 --- a/templates/show_mail_users.inc.php +++ b/templates/show_mail_users.inc.php @@ -69,6 +69,13 @@ + + : + + + + + -- cgit