Issue #1820556: Don't show achievement popups if the overlay is active. 7.x-1.x
authorMorbus Iff
Tue, 23 Oct 2012 12:04:38 +0000 (08:04 -0400)
committerMorbus Iff
Tue, 23 Oct 2012 12:04:38 +0000 (08:04 -0400)
CHANGELOG.txt
achievements.api.php
achievements.module
achievements_recent/achievements_recent.module

index 62a5d94..11784d4 100644 (file)
@@ -9,6 +9,8 @@ Achievements 7.x-1.6, 2012-XX-XX
      100 points - 0.99 timestamp (later in life)
       90 points - 0.10 (the earliest sap, but not a winner)
 
+ * #1820556: Don't show achievement popups if the overlay is active.
+
 
 Achievements 7.x-1.5, 2012-05-01
 --------------------------------
index 1a65274..76796c1 100644 (file)
@@ -72,7 +72,7 @@ function hook_achievements_info() {
       'storage'     => 'comment-count',
       'points'      => 100,
       'images' => array(
-        'unlocked'  => '/sites/default/files/example1.png',
+        'unlocked'  => 'sites/default/files/example1.png',
         // 'secret' and 'locked' will use the defaults.
       ),
     ),
@@ -89,9 +89,9 @@ function hook_achievements_info() {
           'description' => t("Go back to bed: it's still the weekend!"),
           'points'      => 5,
           'images' => array(
-            'unlocked'  => '/sites/default/files/example1.png',
-            'locked'    => '/sites/default/files/example2.png',
-            'secret'    => '/sites/default/files/example3.png',
+            'unlocked'  => 'sites/default/files/example1.png',
+            'locked'    => 'sites/default/files/example2.png',
+            'secret'    => 'sites/default/files/example3.png',
             // all default images have been replaced.
           ),
         ),
index 43a6d98..b9344b5 100644 (file)
@@ -191,7 +191,7 @@ function achievements_template_shared_variables(&$variables) {
 function achievements_block_info() {
   return array(
     'achievements_leaderboard' => array(
-      'info'  => t('Achievements leaderboard'),
+      'info'  => t('Achievements: All-time leaderboard'),
       'cache' => DRUPAL_NO_CACHE,
     ),
   );
@@ -205,7 +205,7 @@ function achievements_block_view($delta = '') {
     include_once(drupal_get_path('module', 'achievements') . '/achievements.pages.inc');
     return array( // stupid file that I have to include. WHERE"S MY FUNCTION REGSITERYR.
       'content' => achievements_leaderboard_block(),
-      'subject' => t('Leaderboard'),
+      'subject' => t('All-time leaderboard'),
     );
   }
 }
@@ -348,7 +348,7 @@ function achievements_totals_user($nearby = 0, $uid = NULL, $days = NULL) {
   // we don't check for access as this is info grubbing only.
 
   $achievers = &drupal_static(__FUNCTION__);
-  $days = isset($days) && $days > 0 ? $days : 0;
+  $days = !empty($days) ? $days : 0; // used in array keys.
   $day_frame = module_exists('achievements_recent') && $days > 0;
   $leaderboard_table = $day_frame ? 'achievement_totals_days' : 'achievement_totals';
 
@@ -661,7 +661,9 @@ function achievements_user_delete($account) {
  * Implements hook_page_alter().
  */
 function achievements_page_alter(&$page) {
-  if (achievements_user_is_achiever()) {
+  // Achievement popups won't show if the overlay is active, so we'll defer until it isn't.
+  // See http://drupal.stackexchange.com/questions/35382/hide-module-when-path-is-overlay.
+  if (achievements_user_is_achiever() && !(module_exists('overlay') && path_is_admin($_GET['q']))) {
     $unlocks = db_select('achievement_unlocks', 'au')->fields('au', array('achievement_id', 'rank', 'timestamp')) // find everything we've yet to see.
       ->condition('uid', $GLOBALS['user']->uid)->condition('seen', 0)->orderBy('timestamp')->execute()->fetchAllAssoc('achievement_id', PDO::FETCH_ASSOC);
 
index c6f0d76..49a1529 100644 (file)
@@ -40,6 +40,24 @@ function achievements_recent_menu() {
 }
 
 /**
+ * Implements hook_block_info().
+ */
+function achievements_recent_block_info() {
+  $blocks = array();
+
+  foreach (achievements_recent_valid_days() as $days => $days_human) {
+    // Can't use '_recent_' as it'll be too long for DB delta column.
+    // Ease your mind: block deltas feel the same as the tabbed URLs.
+    $blocks['achievements_leaderboard_' . $days . '_day'] = array(
+      'info'  => t('Achievements: @days_human leaderboard', array('@days_human' => $days_human)),
+      'cache' => DRUPAL_NO_CACHE,
+    );
+  }
+
+  return $blocks;
+}
+
+/**
  * Recalculate a user's stats based on the number of days.
  *
  * @param $uid