From d4d93cdc25968c2e5ce101b120890ba1b92d7431 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rytis=20Slatkevi=C4=8Dius?= Date: Thu, 16 Nov 2006 19:03:07 +0000 Subject: [PATCH] Show UOTD counter in the ops page (from Eric Myers) svn path=/trunk/boinc/; revision=11533 --- html/inc/uotd.inc | 49 ++++++++++++++++++++++++++++++++++++---------- html/ops/index.php | 14 +++++++++++++ 2 files changed, 53 insertions(+), 10 deletions(-) diff --git a/html/inc/uotd.inc b/html/inc/uotd.inc index 1e02bfe3b7..6b740b7550 100644 --- a/html/inc/uotd.inc +++ b/html/inc/uotd.inc @@ -58,17 +58,8 @@ function build_uotd_page() { // if (function_exists('uotd_candidates_query')) { $query = uotd_candidates_query(); - } else if (profile_screening()) { - $query = "SELECT * FROM profile,user WHERE profile.userid=user.id "; - $query .= " AND verification=1 "; - $query .= " AND expavg_credit>1 "; - $query .= " AND uotd_time IS NULL "; - $query .= "ORDER BY RAND()"; } else { - $query = "SELECT * FROM profile,user WHERE profile.userid=user.id "; - $query .= " AND verification=1 "; - $query .= " AND uotd_time IS NULL "; - $query .= "ORDER BY RAND()"; + $query = default_uotd_candidates_query(); } $result = mysql_query($query); @@ -113,4 +104,42 @@ function build_uotd_page() { echo "Chose user $user->id as UOTD\n"; } +// This is the default policy for choosing the UOTD on any BOINC project. +// To override this with your own policy, create a similar function in +// your own project.inc called uotd_candidates_query() +function default_uotd_candidates_query(){ + if (profile_screening()) { + $query = "SELECT * FROM profile,user WHERE profile.userid=user.id "; + $query .= " AND verification=1 "; + $query .= " AND expavg_credit>1 "; + $query .= " AND uotd_time IS NULL "; + $query .= "ORDER BY RAND()"; + } else { + $query = "SELECT * FROM profile,user WHERE profile.userid=user.id "; + $query .= " AND verification=1 "; + $query .= " AND uotd_time IS NULL "; + $query .= "ORDER BY RAND()"; + } + return $query; +} + +// get a list of profiles that have been 'approved' for UOTD, +// using a project-specific query if supplied in project.inc +function count_uotd_candidates(){ + $n = -1; // negative value returned on error + if (function_exists('uotd_candidates_query')) { + $query = uotd_candidates_query(); + } else { + $query = default_uotd_candidates_query(); + } + + $result = mysql_query($query); + if($result) { + $n = mysql_num_rows($result); + } + mysql_free_result($result); + + return $n; +} + ?> diff --git a/html/ops/index.php b/html/ops/index.php index 4ff2cb16a5..35f4231c77 100644 --- a/html/ops/index.php +++ b/html/ops/index.php @@ -3,6 +3,7 @@ $cvs_version_tracker[]="\$Id$"; //Generated automatically - do not edit require_once("../inc/db_ops.inc"); require_once("../inc/util_ops.inc"); +require_once("../inc/uotd.inc"); $config = get_config(); $cgi_url = parse_config($config, ""); @@ -30,6 +31,19 @@ if (defined('INVITE_CODES')) { invitation codes.\n"; } +$uotd_candidates = count_uotd_candidates(); +if ($uotd_candidates > 0) { + if ($uotd_candidates >= UOTD_THRESHOLD*2) { + $color = "#00aa00"; + } elseif ($uotd_candidates < UOTD_THRESHOLD) { + $color = "#ff0000"; + } else { + $color = "#ff9900"; + } + echo "
  • There are ".$uotd_candidates." remaining + candidates for User of the Day.
  • \n"; +} + echo "\n"; echo "