summaryrefslogtreecommitdiffstats
path: root/modules-available/statistics_reporting/inc/getdata.inc.php
diff options
context:
space:
mode:
Diffstat (limited to 'modules-available/statistics_reporting/inc/getdata.inc.php')
-rw-r--r--modules-available/statistics_reporting/inc/getdata.inc.php25
1 files changed, 15 insertions, 10 deletions
diff --git a/modules-available/statistics_reporting/inc/getdata.inc.php b/modules-available/statistics_reporting/inc/getdata.inc.php
index 13d39502..75db119d 100644
--- a/modules-available/statistics_reporting/inc/getdata.inc.php
+++ b/modules-available/statistics_reporting/inc/getdata.inc.php
@@ -24,7 +24,7 @@ class GetData
return $carry . sprintf("%04d", $item);
}) . sprintf("%04d", $entry['locationid']);
} else {
- $entry['locationname'] = Dictionary::translate('notAssigned', true);
+ $entry['locationname'] = Dictionary::translate('notAssigned');
}
if ($anonymize) {
unset($entry['locationid']);
@@ -56,7 +56,8 @@ class GetData
}
// total
- public static function total($flags = 0) {
+ public static function total(int $flags = 0): array
+ {
$printable = 0 !== ($flags & GETDATA_PRINTABLE);
// total time online, average time online, total number of logins
$data = Queries::getOverallStatistics(self::$from, self::$to, self::$lowerTimeBound, self::$upperTimeBound);
@@ -70,7 +71,8 @@ class GetData
}
// per location
- public static function perLocation($flags = 0) {
+ public static function perLocation(int $flags = 0): array
+ {
$anonymize = 0 !== ($flags & GETDATA_ANONYMOUS);
$printable = 0 !== ($flags & GETDATA_PRINTABLE);
$data = Queries::getLocationStatistics(self::$from, self::$to, self::$lowerTimeBound, self::$upperTimeBound);
@@ -85,7 +87,8 @@ class GetData
}
// per client
- public static function perClient($flags = 0, $new = false) {
+ public static function perClient(int $flags = 0): array
+ {
$anonymize = 0 !== ($flags & GETDATA_ANONYMOUS);
$printable = 0 !== ($flags & GETDATA_PRINTABLE);
$data = Queries::getClientStatistics(self::$from, self::$to, self::$lowerTimeBound, self::$upperTimeBound);
@@ -101,11 +104,12 @@ class GetData
}
// per user
- public static function perUser($flags = 0) {
+ public static function perUser(int $flags = 0): array
+ {
$anonymize = 0 !== ($flags & GETDATA_ANONYMOUS);
$res = Queries::getUserStatistics(self::$from, self::$to, self::$lowerTimeBound, self::$upperTimeBound);
$data = array();
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ foreach ($res as $row) {
if ($anonymize && $row['name'] !== 'anonymous') {
$row['name'] = md5($row['name'] . self::$salt);
}
@@ -116,11 +120,12 @@ class GetData
// per vm
- public static function perVM($flags = 0) {
+ public static function perVM(int $flags = 0): array
+ {
$anonymize = 0 !== ($flags & GETDATA_ANONYMOUS);
$res = Queries::getVMStatistics(self::$from, self::$to, self::$lowerTimeBound, self::$upperTimeBound);
$data = array();
- while ($row = $res->fetch(PDO::FETCH_ASSOC)) {
+ foreach ($res as $row) {
self::nullToZero($row);
if ($anonymize) {
$row['name'] = md5($row['name'] . self::$salt);
@@ -130,7 +135,7 @@ class GetData
return $data;
}
- private static function nullToZero(&$row)
+ private static function nullToZero(array &$row): void
{
foreach ($row as &$field) {
if (is_null($field)) {
@@ -140,7 +145,7 @@ class GetData
}
// Format $seconds into ".d .h .m .s" format (day, hour, minute, second)
- private static function formatSeconds($seconds)
+ private static function formatSeconds(int $seconds): string
{
return sprintf('%dd, %02d:%02d:%02d', $seconds / (3600*24), ($seconds % (3600*24)) / 3600, ($seconds%3600) / 60, $seconds%60);
}