web: fix chart generation for anonymous and private users

This commit is contained in:
Bart Van Der Meerssche 2010-02-19 10:29:03 +00:00
parent 48fae8ebe4
commit 6a9d4d3f62
1 changed files with 8 additions and 5 deletions

View File

@ -273,20 +273,20 @@ function _logger_dashboard($type, $function, $interval) {
$i = 0; $i = 0;
$string->line = ' COMMENT:"\s"'; $string->line = ' COMMENT:"\s"';
if (!$meter_sub = db_fetch_object($result_sub)) { if (user_access('logger') && ((!$meter_sub = db_fetch_object($result_sub)) || $meter_me->private)) {
do { do {
$string->def .= _logger_chart_def($i, $data_path, $meter_me->meter, $factor); $string->def .= _logger_chart_def($i, $data_path, $meter_me->meter, $factor);
$string->line .= _logger_chart_line($i, $color[$i], $meter_me->function); $string->line .= _logger_chart_line($i, $color[$i], $meter_me->function);
$i++; $i++;
} while ($meter_me = db_fetch_object($result_me)); } while ($meter_me = db_fetch_object($result_me));
} }
elseif (user_access('logger') && !$meter_me->private) { elseif (user_access('logger')) {
$string->def .= _logger_chart_def($i, $data_path, $meter_me->meter, $factor); $string->def .= _logger_chart_def($i, $data_path, $meter_me->meter, $factor);
$string->line .= _logger_chart_line($i, $color[$i], $user->name); $string->line .= _logger_chart_line($i, $color[$i], $user->name);
$i++;
do { do {
// check whether the person who's datastream you'd like to superimpose on the graph is in private mode $i++;
// check whether the person who's datastream you'd like to superimpose on the graph is in private mode
if ($meter_sub->private) { if ($meter_sub->private) {
// shift the data left by 1 year = 31556926 seconds to prevent the datastream from being displayed // shift the data left by 1 year = 31556926 seconds to prevent the datastream from being displayed
$string->def .= ' DEF:data'. $i .'='. $data_path . $meter_sub->meter .'.rrd:meter:AVERAGE'. $string->def .= ' DEF:data'. $i .'='. $data_path . $meter_sub->meter .'.rrd:meter:AVERAGE'.
@ -306,9 +306,12 @@ function _logger_dashboard($type, $function, $interval) {
$string->def .= _logger_chart_def($i, $data_path, $meter_sub->meter, $factor); $string->def .= _logger_chart_def($i, $data_path, $meter_sub->meter, $factor);
$string->line .= _logger_chart_line($i, $color[$i], $meter_sub->name); $string->line .= _logger_chart_line($i, $color[$i], $meter_sub->name);
} }
$i++;
} while($meter_sub = db_fetch_object($result_sub)); } while($meter_sub = db_fetch_object($result_sub));
} }
else {
$string->def .= _logger_chart_def($i, $data_path, $meter_me->meter, $factor);
$string->line .= _logger_chart_line($i, $color[$i], $user->name);
}
//construct the TZ=GMT-02:00 format from the $user->timezone object updated by the autotimezone module //construct the TZ=GMT-02:00 format from the $user->timezone object updated by the autotimezone module
if ($user->timezone >= 0) if ($user->timezone >= 0)