Fixes for absent ext-user and misleading data removed
[mailer.git] / inc / modules / guest / what-stats.php
index 34ea36f1fd5e3350679123e9cb4d9677f62288c8..ca20611192b8a1b766402a26b5d71c8bef11a9b9 100644 (file)
  * $Date::                                                            $ *
  * $Tag:: 0.2.1-FINAL                                                 $ *
  * $Author::                                                          $ *
- * Needs to be in all Files and every File needs "svn propset           *
- * svn:keywords Date Revision" (autoprobset!) at least!!!!!!            *
  * -------------------------------------------------------------------- *
  * Copyright (c) 2003 - 2009 by Roland Haeder                           *
- * Copyright (c) 2009, 2010 by Mailer Developer Team                    *
+ * Copyright (c) 2009 - 2011 by Mailer Developer Team                   *
  * For more information visit: http://www.mxchange.org                  *
  *                                                                      *
  * This program is free software; you can redistribute it and/or modify *
@@ -43,10 +41,18 @@ if (!defined('__SECURITY')) {
 } // END - if
 
 // Add description as navigation point
-addMenuDescription('guest', __FILE__);
+addYouAreHereLink('guest', __FILE__);
 
-// Derterminate which stats we want and set mode and title for the link below stats block
-if (!isGetRequestParameterSet('mode')) setGetRequestParameter('mode', strtolower(getConfig('guest_stats')));
+// This part only works if ext-user is active
+if ((!isExtensionActive('user')) && (!isAdmin())) {
+       displayMessage(generateExtensionInactiveNotInstalledMessage('user'));
+       return;
+} // END - if
+
+// Determine which stats we want and set mode and title for the link below stats block
+if (!isGetRequestParameterSet('mode')) {
+       setGetRequestParameter('mode', strtolower(getConfig('guest_stats')));
+} // END - if
 
 // Set config temporarily
 setConfigEntry('guest_stats', strtoupper(getRequestParameter('mode')));
@@ -125,7 +131,7 @@ switch (getConfig('guest_stats')) {
 
                // Generate monthly stats
                $SW = 2; $r2 = ' right'; $l = 'll'; $r = 'lr'; $OUT = '';
-               foreach ($months as $month => $cnt) {
+               foreach ($months as $month => $count) {
                        if ($SW == 2) $OUT .= '<tr>';
 
                        // Prepare data for template
@@ -134,7 +140,7 @@ switch (getConfig('guest_stats')) {
                                'm_descr'  => $GLOBALS['month_descr'][$month],
                                'r_class'  => $r,
                                'r2_class' => $r2,
-                               'cnt'      => $cnt
+                               'cnt'      => $count
                        );
 
                        // Load row template
@@ -154,11 +160,11 @@ switch (getConfig('guest_stats')) {
 
                // Generate category stats
                $OUT = '';
-               foreach ($cat_cnt as $id => $cnt) {
+               foreach ($cat_cnt as $id => $count) {
                        // Prepare data for the template
                        $data = array(
                                'cat' => $cats[$id],
-                               'cnt' => $cnt,
+                               'cnt' => $count,
                        );
 
                        // Load row template and switch colors
@@ -210,12 +216,12 @@ switch (getConfig('guest_stats')) {
                        loadTemplate('guest_stats_table', false, $content);
                } else {
                        // No clicks detected
-                       loadTemplate('admin_settings_saved', false, '{--GUEST_STATS_NO_CLICKS--}');
+                       displayMessage('{--GUEST_STATS_NO_CLICKS--}');
                }
                break;
 
        case 'INACTIVE': // Deactivated stats
-               loadTemplate('admin_settings_saved', false, '{--GUEST_STATS_DEACTIVATED--}');
+               displayMessage('{--GUEST_STATS_DEACTIVATED--}');
                break;
 } // END - switch