[eTCG] show_massmasters

Here's a mod you can use to sort your masteries on your massdeck pages or group collections.
This can be used with the Show Mastered Cards Mod. (You replace the same line)

First step : Install

This goes into your func.php, custom function page, or any pages that you will use the function on.
// Show all mastered decks from a defined group.
// This uses the filler and pending field to define the groups.
// $tcg = the name of the TCG as defined in the database; $worth = card worth; $massf = group name in the filler field; $massp = group name in the pending field.

function show_massmasters($tcg, $worth = '', $massf = '', $massp = '') {
$database = new Database;
$sanitize = new Sanitize;
$tcg = $sanitize->for_db($tcg);

$tcginfo = $database->get_assoc("SELECT * FROM `tcgs` WHERE `name`='$tcg' LIMIT 1");
$tcgid = $tcginfo['id'];
$cardsurl = $tcginfo['cardsurl'];
$format = $tcginfo['format'];

if ( $worth !== '' ) { $worth = intval($worth); }
if ( $massf !== '' ) { $massf =  $sanitize->for_db($massf); }
if ( $massp !== '' ) { $massp =  $sanitize->for_db($massp); }

if ( $massf !== '' && $massp !== '' ) { if ( $worth !== '' ) { $result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '$tcgid' AND `mastered` = '1' AND `worth` = '$worth' AND `filler` = '$massf' AND `pending` = '$massp' ORDER BY `mastereddate`, `id`"); } else { $result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '$tcgid' AND `mastered` = '1' AND `filler` = '$massf' AND `pending` = '$massp' ORDER BY `mastereddate`, `id`"); } }
else if ( $massf !== '' && $massp == '' ) { if ( $worth !== '' ) { $result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '$tcgid' AND `mastered` = '1' AND `worth` = '$worth' AND `filler` = '$massf' ORDER BY `mastereddate`, `id`"); } else { $result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '$tcgid' AND `mastered` = '1' AND `filler` = '$massf' ORDER BY `mastereddate`, `id`"); } }
else if ( $massf == '' && $massp !== '' ) { if ( $worth !== '' ) { $result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '$tcgid' AND `mastered` = '1' AND `worth` = '$worth' AND `pending` = '$massp' ORDER BY `mastereddate`, `id`"); } else { $result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '$tcgid' AND `mastered` = '1' AND `pending` = '$massp' ORDER BY `mastereddate`, `id`"); } }	
else { $result = $database->query("SELECT * FROM `collecting` WHERE `tcg` = '$tcgid' AND `mastered` = '1' ORDER BY `mastereddate`, `id`"); }

while ( $row = mysqli_fetch_assoc($result) ) { 		
$mastered = date('F d, Y', strtotime($row['mastereddate']));
if ( $row['badge'] !== '' ) { echo '<img src="'.$tcginfo['cardsurl'].''.$row['badge'].'" alt="" title="Mastered '.$mastered.'" /> '; }
else { echo ''.$row['deck'].' '; } } 
}

Second step : Define the groups

Go to the mastered pages on eTCG and select the deck you want to add to the group. On the deck page, you'll need to define the name of the group in the filler or pending field.
If you use the filler field, all the decks from that group will have to use the same name in that field.

Third step : Use it

Place this wherever you want the list to go.
show_massmasters($tcg, $worth, $massf, $massp);
  • Replace $tcg with the TCG you're using it on.
  • You only need one of these to make this work.
    • Replace $massf with the group name in the filler field.
    • Replace $massp with the group name in the pending field.
  • Change $worth to show only decks with that worth in the group (optional).

Examples

These are all the decks I mastered on 'Himitsu TCG'. Hover each deck to see their defined values.

"I want to show my masteries on my massdecks pages for Kuroko no Basket and Zero escape".
show_massmasters('Himitsu TCG', '', 'kurokonobasket'); 
echo '<br />'; /// just to separate the decks
show_massmasters('Himitsu TCG', '', 'zeroescape');

Result:

"Wait. I want to show only my Zero escape decks that are worth 2."
show_massmasters('Himitsu TCG', '2', 'zeroescape'); 

Result:

"I also want to show all the decks that are part of my 1st box set."
show_massmasters('Himitsu TCG', '', '', 'boxset1'); 

Result:

"Oh. How many worth 1 decks are on my 1st box set?"
show_massmasters('Himitsu TCG', '1', '', 'boxset1'); 

Result:

"And, are there any Zero escape decks that are worth 2 on my 1st box set?"
show_massmasters('Himitsu TCG', '2', 'zeroescape', 'boxset1'); 

Result:

That's all. If you need help or find some mistake, please let me know :D