With regards to badges:
There's no "standard" BOINC code for badges. As far as I know, every
project that has badges implemented it independently
.
Here's the applicable php code from PrimeGrid (this is from project.inc in
html/project):
if (!function_exists('project_get_badge_icons')) {
>
> function project_get_badge_icons($userid, $style='badge') {
>
> mysql_select_db('boinc'); // weird
>
> $query = 'SELECT * FROM work_user WHERE id='.$userid.';';
>
> $query = mysql_query($query);
>
> $query = mysql_fetch_assoc($query);
>
>
>> $query['tps_credit'] = $query['tps_195000_credit'] +
>> $query['tps_333333_credit'];
>
>
>> $html = '';
>
>
>> if ($userid == 7989) {
>
> $html .= '<img class="'.$style.'"
>> src="/img/badges/tdp_2009_yellow.png" alt="Tour de Primes 2009" />';
>
> $html .= '<img class="'.$style.'"
>> src="/img/badges/tdp_2009_polkadot.png" alt="Tour de Primes 2009" />';
>
> $html .= '<img class="'.$style.'"
>> src="/img/badges/tdp_2010_yellow.png" alt="Tour de Primes 2010" />';
>
> $html .= '<img class="'.$style.'"
>> src="/img/badges/tdp_2010_green.png" alt="Tour de Primes 2010" />';
>
> } elseif ($userid == 3993) {
>
> $html .= '<img class="'.$style.'"
>> src="/img/badges/tdp_2009_green.png" alt="Tour de Primes 2009" />';
>
> } elseif ($userid == 6903) {
>
> $html .= '<img class="'.$style.'"
>> src="/img/badges/tdp_2010_polkadot.png" alt="Tour de Primes 2010" />';
>
> } elseif ($userid == 10347) {
>
> $html .= '<img class="'.$style.'"
>> src="/img/badges/tdp_2011_polkadot.png" alt="Tour de Primes 2011" />';
>
> } elseif ($userid == 32478) {
>
> $html .= '<img class="'.$style.'"
>> src="/img/badges/tdp_2011_green.png" alt="Tour de Primes 2011" />';
>
> } elseif ($userid == 46308) {
>
> $html .= '<img class="'.$style.'"
>> src="/img/badges/tdp_2011_yellow.png" alt="Tour de Primes 2011" />';
>
> } elseif ($userid == 1178) {
>
> $html .= '<img class="'.$style.'"
>> src="/img/badges/tdp_2012_yellow.png" alt="Tour de Primes 2012" />';
>
> $html .= '<img class="'.$style.'"
>> src="/img/badges/tdp_2012_polkadot.png" alt="Tour de Primes 2012" />';
>
> } elseif ($userid == 59072) {
>
> $html .= '<img class="'.$style.'"
>> src="/img/badges/tdp_2012_green.png" alt="Tour de Primes 2012" />';
>
> } elseif ($userid == 168978) {
>
> $html .= '<img class="'.$style.'"
>> src="/img/badges/tdp_2013_yellow.png" alt="Tour de Primes 2013" />';
>
> $html .= '<img class="'.$style.'"
>> src="/img/badges/tdp_2013_green.png" alt="Tour de Primes 2013" />';
>
> } elseif ($userid == 33838) {
>
> $html .= '<img class="'.$style.'"
>> src="/img/badges/tdp_2013_polkadot.png" alt="Tour de Primes 2013" />';
>
> }
>
>
>> $html .= project_subproject_badge($query, '321', '321 LLR', 1,
>> $style);
>
> $html .= project_subproject_badge($query, 'cul', 'Cullen LLR', 1,
>> $style);
>
> $html .= project_subproject_badge($query, 'pps_llr', 'PPS LLR', 1,
>> $style);
>
> $html .= project_subproject_badge($query, 'psp_llr', 'PSP LLR', 1,
>> $style);
>
> $html .= project_subproject_badge($query, 'sob_llr', 'SoB LLR', 1,
>> $style);
>
> $html .= project_subproject_badge($query, 'sr5', 'SR5 LLR', 1, $style);
>
> $html .= project_subproject_badge($query, 'sgs', 'SGS LLR', 1, $style);
>
> $html .= project_subproject_badge($query, 'tps', 'TPS LLR (retired)',
>> 1, $style);
>
> $html .= project_subproject_badge($query, 'trp_llr', 'TRP LLR', 1,
>> $style);
>
> $html .= project_subproject_badge($query, 'woo', 'Woodall LLR', 1,
>> $style);
>
> $html .= project_subproject_badge($query, 'sr2sieve_321', '321 Sieve
>> (suspended)', 2, $style);
>
> $html .= project_subproject_badge($query, 'gcwsieve', 'Cullen/Woodall
>> Sieve (suspended)', 2, $style);
>
> $html .= project_subproject_badge($query, 'sr2sieve_pps', 'PPS Sieve',
>> 2, $style);
>
> $html .= project_subproject_badge($query, 'sr2sieve_psp', 'PSP Sieve
>> (suspended)', 2, $style);
>
> $html .= project_subproject_badge($query, 'sr2sieve_trp', 'TRP Sieve',
>> 2, $style);
>
> $html .= project_subproject_badge($query, 'ap26', 'AP26 (retired)', 2,
>> $style);
>
> $html .= project_subproject_badge($query, 'genefer', 'GFN', 2, $style);
>
> $html .= project_subproject_badge($query, 'manual', 'PSA', 2, $style);
>
>
>> return $html;
>
> }
>
> }
>
>
>> if (!function_exists('project_subproject_badge')) {
>
> function project_subproject_badge($work, $subproject, $name, $method,
>> $style='badge') {
>
> if (!isset($work[$subproject.'_credit'])) return;
>
>
>> $badges[] = array('badge'=>'Double Emerald', 'file'=>'emerald2',
>> 'llr'=>50000000000, 'sieve'=>100000000000);
>
> $badges[] = array('badge'=>'Double Sapphire', 'file'=>'sapphire2',
>> 'llr'=>20000000000, 'sieve'=>40000000000);
>
> $badges[] = array('badge'=>'Double Jade', 'file'=>'jade2',
>> 'llr'=>10000000000, 'sieve'=>20000000000);
>
> $badges[] = array('badge'=>'Double Turquoise', 'file'=>'turquoise2',
>> 'llr'=>5000000000, 'sieve'=>10000000000);
>
> $badges[] = array('badge'=>'Double Ruby', 'file'=>'ruby2',
>> 'llr'=>2000000000, 'sieve'=>4000000000);
>
> $badges[] = array('badge'=>'Double Amethyst', 'file'=>'amethyst2',
>> 'llr'=>1000000000, 'sieve'=>2000000000);
>
> $badges[] = array('badge'=>'Double Gold', 'file'=>'gold2',
>> 'llr'=>500000000, 'sieve'=>1000000000);
>
> $badges[] = array('badge'=>'Double Silver', 'file'=>'silver2',
>> 'llr'=>200000000, 'sieve'=>400000000);
>
> $badges[] = array('badge'=>'Double Bronze', 'file'=>'bronze2',
>> 'llr'=>100000000, 'sieve'=>200000000);
>
> $badges[] = array('badge'=>'Emerald', 'file'=>'emerald',
>> 'llr'=>50000000, 'sieve'=>100000000);
>
> $badges[] = array('badge'=>'Sapphire', 'file'=>'sapphire',
>> 'llr'=>20000000, 'sieve'=>40000000);
>
> $badges[] = array('badge'=>'Jade', 'file'=>'jade', 'llr'=>10000000,
>> 'sieve'=>20000000);
>
> $badges[] = array('badge'=>'Turquoise', 'file'=>'turquoise',
>> 'llr'=>5000000, 'sieve'=>10000000);
>
> $badges[] = array('badge'=>'Ruby', 'file'=>'ruby', 'llr'=>2000000,
>> 'sieve'=>4000000);
>
> $badges[] = array('badge'=>'Amethyst', 'file'=>'amethyst',
>> 'llr'=>1000000, 'sieve'=>2000000);
>
> $badges[] = array('badge'=>'Gold', 'file'=>'gold', 'llr'=>500000,
>> 'sieve'=>1000000);
>
> $badges[] = array('badge'=>'Silver', 'file'=>'silver', 'llr'=>100000,
>> 'sieve'=>200000);
>
> $badges[] = array('badge'=>'Bronze', 'file'=>'bronze', 'llr'=>10000,
>> 'sieve'=>20000);
>
>
>> foreach ($badges as $badge) {
>
> $limit = ($method == 1) ? $badge['llr'] : $badge['sieve'];
>
> if ($work[$subproject.'_credit'] > $limit) {
>
> $text = $name.' '.$badge['badge'].': More than
>> '.number_format($limit).' credits
>> ('.number_format(round($work[$subproject.'_credit'])).')';
>
> return '<a
>> href="/show_badges.php?userid='.$work['id'].'"><img class="'.$style.'"
>> src="/img/badges/'.$subproject.'_'.$badge['file'].'.png" alt="'.$text.'"
>> title="'.$text.'" /></a>';
>
> }
>
> }
>
>
>> return '';
>
> }
>
> }
>
>
This routine is used on several webpages to display badges, including the
user account page, team member lists, forum posts, and a page that lists
all your badges (and what you need for the next badge.) That's the
"show_badges.php" that's linked in the badge display.
project_get_badge_icons() should be called with a a userid and returns a
text string which is the html to display that user's badge icons. The
badge icons must exist in the appropriate directory (they're not generated
dynamically.) An optional second parameter can be used to set a style; I
use this for an alternate badge display where the spacing between the
badges is narrower.
The first section of the routine displays special badges that are awarded
for winning our annual "Tour de Primes" challenge. It's not database
driven and those are all hard coded.
Following that is the code which displays badges for each of our
sub-projects, based on credit. The per-sub-project credit is read from the
table "work_user".
We have different badge credit thresholds for our LLR projects and Sieve
projects, so each entry in the table has two different numbers.
If you don't have sub-projects, you could user the column "total_credit"
from the "user" table.
I hope this helps get you started.
Mike
On Wed, Sep 25, 2013 at 4:11 PM, Matthew Newby <[email protected]> wrote:
> Hello,
>
> I'm the latest guy to be tasked with implementing a voluntary "green
> star" donor badge system on MilkyWay@home, and I'm wondering how to go
> about this. I found a message in the archive by someone else,
> (http://lists.ssl.berkeley.edu/pipermail/boinc_dev/2012-July/018641.html)
> but I don't see a "donations.inc" in our "project" folder.
>
> Additionally, our home institution wants us to handle donations
> through their donation system. So what I need to know is the best way
> for our server to receive information that will get the green star to
> show up. My thinking is that it would be easiest for us to add a
> donation element to our database, which would be updated by a script
> when our server receives data from the donations server. The "green
> star" would then be generated by querying the database.
>
> I'm also trying to figure out how credit milestone badges are
> generated, and maybe I'll be able to use that system to manage donor
> badges? Any suggestions will be useful!
>
> Cheers,
> Matthew Newby
>
> _______________________________________________
> boinc_dev mailing list
> [email protected]
> http://lists.ssl.berkeley.edu/mailman/listinfo/boinc_dev
> To unsubscribe, visit the above URL and
> (near bottom of page) enter your email address.
>
_______________________________________________
boinc_dev mailing list
[email protected]
http://lists.ssl.berkeley.edu/mailman/listinfo/boinc_dev
To unsubscribe, visit the above URL and
(near bottom of page) enter your email address.