summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--CHANGELOG.txt5
-rw-r--r--achievements.css25
-rw-r--r--achievements.module6
-rw-r--r--achievements.pages.inc19
4 files changed, 41 insertions, 14 deletions
diff --git a/CHANGELOG.txt b/CHANGELOG.txt
index 6690e24..2030f99 100644
--- a/CHANGELOG.txt
+++ b/CHANGELOG.txt
@@ -1,9 +1,9 @@
Achievements 7.x-1.3, 2011-xx-xx
--------------------------------
-* (todo) Add a "get latest badge" thing for lookups, add to leaderboard?
* (todo) Make some new screenshots for the latest additions
* New relative leaderboards. Picture of the popup fadein? Latest badge?
+ * Write up a blog post. Mention on Twitter, G+.
* The following hooks have been added. See achievements.api.php for details:
* hook_achievements_info_alter() - modify the achievement information.
@@ -15,8 +15,9 @@ Achievements 7.x-1.3, 2011-xx-xx
* "Nearby" users are a number of ranks before and after the current user.
* The number of nearby ranks shown can be 0 through 10.
* The block and global leaderboard can be configured separately.
+ * The global leaderboard now shows a user's latest achievement.
* New leaderboard CSS class added: achievements-leaderboard-current-user.
- * The achievements/leaderboard is now a paged view instead of a set limit.
+ * The global leaderboard is now a paged view instead of a set limit.
* Control number of ranks per page at admin/config/people/achievements/.
* achievements_totals() no longer exists; moved inline to leaderboard page.
* achievements_totals_user() has been rewritten with different parameters.
diff --git a/achievements.css b/achievements.css
index ea91f84..eb6d019 100644
--- a/achievements.css
+++ b/achievements.css
@@ -102,17 +102,32 @@
width: 12px;
}
+.achievement-leaderboard .achievement-leaderboard-points,
+.achievement-leaderboard .achievement-leaderboard-unlocks {
+ width: 50px;
+}
+
+.achievement-leaderboard .achievement-leaderboard-latest {
+ width: 275px;
+}
+
.achievement-leaderboard-current-user {
font-weight: bold;
}
-.achievement-leaderboard .achievement-leaderboard-points,
-.achievement-leaderboard .achievement-leaderboard-unlocks {
- width: 50px;
+.achievement-leaderboard .achievement-latest-image img {
+ float: left;
+ height: 35px;
+ padding-right: 5px;
+ width: 35px;
+}
+
+.achievement-leaderboard .achievement-latest-title {
+ font-weight: bold;
}
-.achievement-leaderboard .achievement-leaderboard-when {
- width: 175px;
+.achievement-leaderboard .achievement-latest-when {
+ font-size: smaller;
}
#block-achievements-achievements-leaderboard .achievement-leaderboard-points {
diff --git a/achievements.module b/achievements.module
index f9d6f00..4f55426 100644
--- a/achievements.module
+++ b/achievements.module
@@ -90,14 +90,14 @@ function achievements_theme() {
* Process variables for achievement.tpl.php.
*/
function template_preprocess_achievement(&$variables) {
- achievement_template_shared_variables($variables);
+ achievements_template_shared_variables($variables);
}
/**
* Process variables for achievement-notification.tpl.php.
*/
function template_preprocess_achievement_notification(&$variables) {
- achievement_template_shared_variables($variables);
+ achievements_template_shared_variables($variables);
$variables['classes_array'][] = 'element-hidden';
}
@@ -108,7 +108,7 @@ function template_preprocess_achievement_notification(&$variables) {
* some or all of the data in different ways. This is a centralized collection
* of the various helper $variables needed for theme display.
*/
-function achievement_template_shared_variables(&$variables) {
+function achievements_template_shared_variables(&$variables) {
$variables['state'] = isset($variables['unlock']) ? 'unlocked' : 'locked';
if (isset($variables['achievement']['hidden']) && !achievements_unlocked_already($variables['achievement']['id'])) {
diff --git a/achievements.pages.inc b/achievements.pages.inc
index aa52e04..46e8407 100644
--- a/achievements.pages.inc
+++ b/achievements.pages.inc
@@ -12,7 +12,7 @@
*/
function achievements_leaderboard_totals() {
// force no sorting on # so it doesn't get the 'active' CSS, which screws up relative non-header display.
- $header = array(array('data' => t('#'), 'sort' => NULL), t('Who'), t('Points'), t('Unlocks'), t('When'));
+ $header = array(array('data' => t('#'), 'sort' => NULL), t('Who'), t('Points'), t('Unlocks'), t('Latest achievement'));
$achievers = $rows = array('top' => array(), 'relative' => array());
// load up all our achievers for the page.
@@ -38,6 +38,14 @@ function achievements_leaderboard_totals() {
$rank = 1 + ($GLOBALS['pager_page_array'][0] * variable_get('achievements_leaderboard_count_per_page', 25));
foreach (array('top', 'relative') as $type) {
foreach ($achievers[$type] as $achiever) {
+ // since we're showing the "latest achievement" for a user, we have to
+ // determine what image to use and respect 'hidden' status. we already
+ // do this in achievements_template_shared_variables(), so reuse it. we
+ // fake an $unlock so the 'unlocked' image is returned; the POV for this
+ // achievement display is the ranked user/row, NOT the current user.
+ $variables = array('achievement' => achievements_load($achiever->achievement_id), 'unlock' => array());
+ achievements_template_shared_variables($variables); // generate image, munge for hidden, etc.
+
$rows[$type][] = array( // give a special class if its the current user.
'class' => ($achiever->uid == $GLOBALS['user']->uid) ? array('achievement-leaderboard-current-user') : array(),
'data' => array(
@@ -58,8 +66,11 @@ function achievements_leaderboard_totals() {
'class' => array('achievement-leaderboard-unlocks')
),
array(
- 'data' => format_date($achiever->timestamp, 'small'),
- 'class' => array('achievement-leaderboard-when')
+ 'data' =>
+ '<div class="achievement-latest-image">' . $variables['image'] . '</div>' .
+ '<div class="achievement-latest-title">' . $variables['achievement']['title'] . '</div>' .
+ '<div class="achievement-latest-when">' . format_date($achiever->timestamp, 'small') . '</div>',
+ 'class' => array('achievement-leaderboard-latest')
),
),
);
@@ -161,7 +172,7 @@ function achievements_leaderboard_for($achievement) {
$query = db_select('achievement_unlocks', 'au');
$query->join('achievement_totals', 'at', 'at.uid = au.uid');
$query->join('users', 'u', 'u.uid = au.uid'); // same basic start for both queries.
- $query->condition('achievement_id', $achievement['id']); // ... with a slight tweak.
+ $query->condition('au.achievement_id', $achievement['id']); // ... with a slight tweak.
$query->fields('au', array('uid', 'rank', 'timestamp'))->fields('at', array('points', 'unlocks'))->fields('u', array('name'));
$query2 = clone $query; // allows us to save a few lines of duplicate query building. never used clone before. awesome.
$stats['first'] = $query->orderBy('rank')->range(0, 10)->execute()->fetchAllAssoc('rank'); // FI... sigh.