summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMorbus Iff2011-07-15 14:03:04 (GMT)
committer Morbus Iff2011-07-15 14:03:04 (GMT)
commit73908d19c4de98171d0f5c5448d3bf2e14b8fa6e (patch)
tree70b7a3aa03206af97cf19ca43623c61b7f38c84f
parent512d77197e72dca84e569115ace2334bed2ec38b (diff)
Fixes for underlying group code.
-rw-r--r--achievements.module6
-rw-r--r--achievements.pages.inc8
2 files changed, 10 insertions, 4 deletions
diff --git a/achievements.module b/achievements.module
index f9ce394..8f63d55 100644
--- a/achievements.module
+++ b/achievements.module
@@ -176,9 +176,9 @@ function achievements_load($achievement_id = NULL, $grouped = FALSE, $reset = FA
if (isset($value['achievements']) && is_array($value['achievements'])) {
$achievements['grouped'][$key] = $value; // copy the whole shebang into realz.
foreach ($achievements['grouped'][$key]['achievements'] as $id => $achievement) {
- $achievement[$id]['id'] = $id;
- $achievement[$id]['group_id'] = $key;
- $achievement[$id]['group_title'] = $value['title'];
+ $achievements['grouped'][$key]['achievements'][$id]['id'] = $id;
+ $achievements['grouped'][$key]['achievements'][$id]['group_id'] = $key;
+ $achievements['grouped'][$key]['achievements'][$id]['group_title'] = $value['title'];
$achievements['flat'][$id] = &$achievements['grouped'][$key]['achievements'][$id];
}
}
diff --git a/achievements.pages.inc b/achievements.pages.inc
index 4b3f91f..3535b9c 100644
--- a/achievements.pages.inc
+++ b/achievements.pages.inc
@@ -154,6 +154,7 @@ function achievements_user_page($account) {
);
foreach ($achievements as $group_id => $group) {
+ $locked_weight = 0; // we can't use definition order.
foreach ($group['achievements'] as $achievement_id => $achievement) {
$build['achievements'][$group_id][$achievement_id]['#theme'] = 'achievement';
$build['achievements'][$group_id][$achievement_id]['#achievement'] = $achievement;
@@ -161,7 +162,12 @@ function achievements_user_page($account) {
if (isset($unlocks[$achievement_id])) {
$build['achievements'][$group_id][$achievement_id]['#unlock'] = (array) $unlocks[$achievement_id];
$build['achievements'][$group_id][$achievement_id]['#weight'] = -$unlocks[$achievement_id]->timestamp;
- // by setting the weight to the timestamp, the latest unlocks are always shown at the top.
+ // by setting the negative weight to the timestamp, the latest unlocks are always shown at the top.
+ }
+ else {
+ // since we're forcing unlocked achievements to the top with #weight,
+ // locked achievements can no longer depend on "definition order".
+ $build['achievements'][$group_id][$achievement_id]['#weight'] = $locked_weight++;
}
}
}