|
@@ -149,43 +149,47 @@ function DisplayStats()
|
|
|
$context['latest_member'] = &$context['common_stats']['latest_member'];
|
|
|
|
|
|
// Male vs. female ratio - let's calculate this only every four minutes.
|
|
|
- if (($context['gender'] = cache_get_data('stats_gender', 240)) == null)
|
|
|
+ $disabled_fields = isset($modSettings['disabled_profile_fields']) ? explode(',', $modSettings['disabled_profile_fields']) : array();
|
|
|
+ if (!in_array('gender', $disabled_fields))
|
|
|
{
|
|
|
- $result = $smcFunc['db_query']('', '
|
|
|
- SELECT COUNT(*) AS total_members, gender
|
|
|
- FROM {db_prefix}members
|
|
|
- GROUP BY gender',
|
|
|
- array(
|
|
|
- )
|
|
|
- );
|
|
|
- $context['gender'] = array();
|
|
|
- while ($row = $smcFunc['db_fetch_assoc']($result))
|
|
|
+ if (($context['gender'] = cache_get_data('stats_gender', 240)) == null)
|
|
|
{
|
|
|
- // Assuming we're telling... male or female?
|
|
|
- if (!empty($row['gender']))
|
|
|
- $context['gender'][$row['gender'] == 2 ? 'females' : 'males'] = $row['total_members'];
|
|
|
+ $result = $smcFunc['db_query']('', '
|
|
|
+ SELECT COUNT(*) AS total_members, gender
|
|
|
+ FROM {db_prefix}members
|
|
|
+ GROUP BY gender',
|
|
|
+ array(
|
|
|
+ )
|
|
|
+ );
|
|
|
+ $context['gender'] = array();
|
|
|
+ while ($row = $smcFunc['db_fetch_assoc']($result))
|
|
|
+ {
|
|
|
+ // Assuming we're telling... male or female?
|
|
|
+ if (!empty($row['gender']))
|
|
|
+ $context['gender'][$row['gender'] == 2 ? 'females' : 'males'] = $row['total_members'];
|
|
|
+ }
|
|
|
+ $smcFunc['db_free_result']($result);
|
|
|
+
|
|
|
+ // Set these two zero if the didn't get set at all.
|
|
|
+ if (empty($context['gender']['males']))
|
|
|
+ $context['gender']['males'] = 0;
|
|
|
+ if (empty($context['gender']['females']))
|
|
|
+ $context['gender']['females'] = 0;
|
|
|
+
|
|
|
+ // Try and come up with some "sensible" default states in case of a non-mixed board.
|
|
|
+ if ($context['gender']['males'] == $context['gender']['females'])
|
|
|
+ $context['gender']['ratio'] = '1:1';
|
|
|
+ elseif ($context['gender']['males'] == 0)
|
|
|
+ $context['gender']['ratio'] = '0:1';
|
|
|
+ elseif ($context['gender']['females'] == 0)
|
|
|
+ $context['gender']['ratio'] = '1:0';
|
|
|
+ elseif ($context['gender']['males'] > $context['gender']['females'])
|
|
|
+ $context['gender']['ratio'] = round($context['gender']['males'] / $context['gender']['females'], 1) . ':1';
|
|
|
+ elseif ($context['gender']['females'] > $context['gender']['males'])
|
|
|
+ $context['gender']['ratio'] = '1:' . round($context['gender']['females'] / $context['gender']['males'], 1);
|
|
|
+
|
|
|
+ cache_put_data('stats_gender', $context['gender'], 240);
|
|
|
}
|
|
|
- $smcFunc['db_free_result']($result);
|
|
|
-
|
|
|
- // Set these two zero if the didn't get set at all.
|
|
|
- if (empty($context['gender']['males']))
|
|
|
- $context['gender']['males'] = 0;
|
|
|
- if (empty($context['gender']['females']))
|
|
|
- $context['gender']['females'] = 0;
|
|
|
-
|
|
|
- // Try and come up with some "sensible" default states in case of a non-mixed board.
|
|
|
- if ($context['gender']['males'] == $context['gender']['females'])
|
|
|
- $context['gender']['ratio'] = '1:1';
|
|
|
- elseif ($context['gender']['males'] == 0)
|
|
|
- $context['gender']['ratio'] = '0:1';
|
|
|
- elseif ($context['gender']['females'] == 0)
|
|
|
- $context['gender']['ratio'] = '1:0';
|
|
|
- elseif ($context['gender']['males'] > $context['gender']['females'])
|
|
|
- $context['gender']['ratio'] = round($context['gender']['males'] / $context['gender']['females'], 1) . ':1';
|
|
|
- elseif ($context['gender']['females'] > $context['gender']['males'])
|
|
|
- $context['gender']['ratio'] = '1:' . round($context['gender']['females'] / $context['gender']['males'], 1);
|
|
|
-
|
|
|
- cache_put_data('stats_gender', $context['gender'], 240);
|
|
|
}
|
|
|
|
|
|
$date = strftime('%Y-%m-%d', forum_time(false));
|