diff --git a/drupal/sites/default/boinc/modules/boincuser/boincuser.module b/drupal/sites/default/boinc/modules/boincuser/boincuser.module index 672c9fa80a..2d68cfc051 100644 --- a/drupal/sites/default/boinc/modules/boincuser/boincuser.module +++ b/drupal/sites/default/boinc/modules/boincuser/boincuser.module @@ -1176,6 +1176,14 @@ function boincuser_home_page() { $active_users[] = $user_with_credit->id; } $active_users = implode(',', $active_users); + // Limit to users who have never been user of the day, if there are any + $never_been_picked = db_result(db_query(" + SELECT COUNT(*) + FROM {boincuser} + WHERE uotd_time = 0 + " . ($active_users ? " AND bu.boinc_id IN ({$active_users}) " : '') + )); + // Select a user of the day randomly from the pool $new_uotd_uid = db_result(db_query(" SELECT n.uid @@ -1184,6 +1192,7 @@ function boincuser_home_page() { WHERE n.type = 'profile' AND n.status = 1 AND n.moderate = 0 + " . ($never_been_picked ? " AND bu.uotd_time = 0 " : '') . " " . ($active_users ? " AND bu.boinc_id IN ({$active_users}) " : '') . " ORDER BY RAND() LIMIT 1"