From ead74789ff41bda0cb6c3ba16883082a84db7ef8 Mon Sep 17 00:00:00 2001 From: Searo Date: Wed, 13 Apr 2022 16:19:12 -0400 Subject: [PATCH] Recent masteries (#571) --- lib/database/mastery.php | 41 ++++++++++ lib/functions.php | 1 + lib/render/layout.php | 1 + public/recentMastery.php | 166 +++++++++++++++++++++++++++++++++++++++ 4 files changed, 209 insertions(+) create mode 100644 lib/database/mastery.php create mode 100644 public/recentMastery.php diff --git a/lib/database/mastery.php b/lib/database/mastery.php new file mode 100644 index 0000000000..1dc60f97db --- /dev/null +++ b/lib/database/mastery.php @@ -0,0 +1,41 @@ + 0 AND AwardDataExtra IS NOT NULL $friendCondAward + AND saw.AwardDate BETWEEN TIMESTAMP('$date') AND DATE_ADD('$date', INTERVAL 24 * 60 * 60 - 1 SECOND) + ORDER BY AwardedAt DESC + LIMIT $offset, $count"; + + $dbResult = s_mysql_query($query); + if ($dbResult !== false) { + while ($db_entry = mysqli_fetch_assoc($dbResult)) { + $retVal[] = $db_entry; + } + } + return $retVal; +} diff --git a/lib/functions.php b/lib/functions.php index c6bd57beed..8728b7e66d 100644 --- a/lib/functions.php +++ b/lib/functions.php @@ -10,6 +10,7 @@ require_once __DIR__ . '/database/game.php'; require_once __DIR__ . '/database/history.php'; require_once __DIR__ . '/database/leaderboard.php'; +require_once __DIR__ . '/database/mastery.php'; require_once __DIR__ . '/database/message.php'; require_once __DIR__ . '/database/news.php'; require_once __DIR__ . '/database/playlist.php'; diff --git a/lib/render/layout.php b/lib/render/layout.php index 6e4090e5fb..d893736469 100644 --- a/lib/render/layout.php +++ b/lib/render/layout.php @@ -272,6 +272,7 @@ function RenderToolbar($user, $permissions = 0) echo "
  • Developers
  • "; // echo "
  • Leaderboards
  • "; echo "
  • Global Ranking
  • "; + echo "
  • Recent Masteries
  • "; echo "
  • "; echo "
  • User Documentation
  • "; echo "
  • Developer Documentation
  • "; diff --git a/public/recentMastery.php b/public/recentMastery.php new file mode 100644 index 0000000000..e9c21509c6 --- /dev/null +++ b/public/recentMastery.php @@ -0,0 +1,166 @@ + + + +
    +
    + Recent " . $lbUsers . " Masteries"; + + // Add the leaderboard filters + echo "
    "; + + // Create the Users filters only if a user is logged in + if ($user !== null) { + echo "
    "; + echo "Users: "; + if ($friends == 0) { + echo "*All Users | "; + } else { + echo "All Users | "; + } + if ($friends == 1) { + echo "*Friends Only"; + } else { + echo "Friends Only"; + } + echo "
    "; + } + + // Create the custom date filter + echo "
    "; + echo ""; + echo ""; + echo " "; + echo ""; + echo ""; + echo "
    "; + + // Clear filter + if ($date != date("Y-m-d") || $friends != 0) { + echo "
    "; + echo "Clear Filter"; + echo "
    "; + } + echo "
    "; + + echo ""; + + // Headers + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + echo ""; + + $userCount = 0; + $skip = false; + // Create the table rows + foreach ($data as $dataPoint) { + // Break if we have hit the maxCount + 1 user + if ($userCount == $maxCount) { + $userCount++; + $skip = true; + } + + if (!$skip) { + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + + echo ""; + $userCount++; + } + } + echo "
    UserTypeGameDate
    "; + echo GetUserAndTooltipDiv($dataPoint['User'], true); + echo GetUserAndTooltipDiv($dataPoint['User'], false); + echo ""; + if ($dataPoint['AwardDataExtra'] == 1) { + echo "Mastered"; + } else { + echo "Completed"; + } + echo ""; + echo GetGameAndTooltipDiv($dataPoint['GameID'], $dataPoint['GameTitle'], $dataPoint['GameIcon'], $dataPoint['ConsoleName']); + echo ""; + echo $dataPoint['AwardedAt']; + echo "
    "; + + // Add page traversal + echo "
    "; + if ($date > $minDate) { + $prevDate = date('Y-m-d', strtotime($date . "-1 days")); + echo "< Prev Day "; + if ($date < date("Y-m-d")) { + echo " | "; + } + } + if ($offset > 0) { + $prevOffset = $offset - $maxCount; + echo "< Prev $maxCount "; + } + if ($userCount > $maxCount) { + if ($offset > 0) { + echo " - "; + } + $nextOffset = $offset + $maxCount; + echo "Next $maxCount >"; + } + if ($date < date("Y-m-d")) { + $nextDate = date('Y-m-d', strtotime($date . "+1 days")); + echo " | Next Day >"; + } + echo "
    "; + ?> +
    +
    + + +