summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorpb1dft <pb1dft@ampache>2006-11-09 01:37:19 +0000
committerpb1dft <pb1dft@ampache>2006-11-09 01:37:19 +0000
commit29aca5c21898ad71bbb537bf533a8adf0e74978d (patch)
tree0b94d25c1816de63096fd52b04ba14abf9451069
parent70853913cf0d21bd44643c7333dd5810fe5a81d3 (diff)
downloadampache-29aca5c21898ad71bbb537bf533a8adf0e74978d.tar.gz
ampache-29aca5c21898ad71bbb537bf533a8adf0e74978d.tar.bz2
ampache-29aca5c21898ad71bbb537bf533a8adf0e74978d.zip
Fixed mail threshold and added user ability to change it
-rw-r--r--admin/mail.php7
-rw-r--r--lib/class/stats.class.php10
-rw-r--r--templates/show_mail_users.inc.php7
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 @@
<input type="checkbox" name="pop_songs" value="yes" />
</td>
</tr>
+ <tr>
+ <td colspan = "2"><?php echo _('Most Popular Threshold in days'); ?>:</td>
+ <td>
+ <input type="text" name="threshold" value="<?php echo conf('popular_threshold'); ?>" />
+ </td>
+ </tr>
+
</table>
</td>
</tr>