summaryrefslogtreecommitdiffstats
path: root/modules-available/locationinfo/page.inc.php
diff options
context:
space:
mode:
authorSimon Rettberg2023-11-14 14:47:55 +0100
committerSimon Rettberg2023-11-14 14:47:55 +0100
commit06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0 (patch)
tree7e5493b102074672d8cfd8fe1a61e49f080edbe8 /modules-available/locationinfo/page.inc.php
parentUpdate phpstorm config (diff)
downloadslx-admin-06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0.tar.gz
slx-admin-06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0.tar.xz
slx-admin-06bff0b9b84d47c43f9bc8aff06a29d85ebb7ed0.zip
Add function param/return types, fix a lot more phpstorm complaints
Diffstat (limited to 'modules-available/locationinfo/page.inc.php')
-rw-r--r--modules-available/locationinfo/page.inc.php42
1 files changed, 26 insertions, 16 deletions
diff --git a/modules-available/locationinfo/page.inc.php b/modules-available/locationinfo/page.inc.php
index 91de0012..5e5b66f0 100644
--- a/modules-available/locationinfo/page.inc.php
+++ b/modules-available/locationinfo/page.inc.php
@@ -81,7 +81,7 @@ class Page_LocationInfo extends Page
$this->showLocationsTable();
break;
case 'backends':
- $this->showBackendsTable($backends);
+ $this->showBackendsTable($backends ?? []);
break;
case 'edit-panel':
$this->showPanelConfig();
@@ -130,11 +130,13 @@ class Page_LocationInfo extends Page
}
}
- private function getTime(string $str): int
+ private static function getTime(string $str): ?int
{
$str = explode(':', $str);
- if (count($str) !== 2) return false;
- if ($str[0] < 0 || $str[0] > 23 || $str[1] < 0 || $str[1] > 59) return false;
+ if (count($str) !== 2)
+ return null;
+ if ($str[0] < 0 || $str[0] > 23 || $str[1] < 0 || $str[1] > 59)
+ return null;
return $str[0] * 60 + $str[1];
}
@@ -247,7 +249,7 @@ class Page_LocationInfo extends Page
}
// Permission
- $this->assertPanelPermission($paneluuid, 'panel.edit', $params['locationids']);
+ $this->assertPanelPermission($paneluuid, 'panel.edit', $params['locationids'] ?? []);
if ($paneluuid === 'new') {
$paneluuid = Util::randomUuid();
@@ -270,6 +272,9 @@ class Page_LocationInfo extends Page
Util::redirect('?do=locationinfo');
}
+ /**
+ * @return array{config: array, locationids: array}
+ */
private function preparePanelConfigDefault(): array
{
// Check locations
@@ -325,6 +330,9 @@ class Page_LocationInfo extends Page
return array('config' => $conf, 'locationids' => $locationids);
}
+ /**
+ * @return array{config: array, locationids: array}
+ */
private function preparePanelConfigUrl(): array
{
$bookmarkNames = Request::post('bookmarkNames', [], 'array');
@@ -343,8 +351,8 @@ class Page_LocationInfo extends Page
'url' => Request::post('url', 'https://www.bwlehrpool.de/', 'string'),
'insecure-ssl' => Request::post('insecure-ssl', 0, 'int'),
'reload-minutes' => max(0, Request::post('reloadminutes', 0, 'int')),
- 'whitelist' => preg_replace("/[\r\n]+/ms", "\n", Request::post('whitelist', '', 'string')),
- 'blacklist' => preg_replace("/[\r\n]+/ms", "\n", Request::post('blacklist', '', 'string')),
+ 'whitelist' => preg_replace("/[\r\n]+/m", "\n", Request::post('whitelist', '', 'string')),
+ 'blacklist' => preg_replace("/[\r\n]+/m", "\n", Request::post('blacklist', '', 'string')),
'split-login' => Request::post('split-login', 0, 'bool'),
'browser' => Request::post('browser', 'slx-browser', 'string'),
'interactive' => Request::post('interactive', '0', 'bool'),
@@ -355,6 +363,9 @@ class Page_LocationInfo extends Page
return array('config' => $conf, 'locationids' => []);
}
+ /**
+ * @return array{config: array, locationids: array}
+ */
private function preparePanelConfigSummary(): array
{
// Build json structure
@@ -687,7 +698,7 @@ class Page_LocationInfo extends Page
} else {
$cred->initForRender();
}
- $cred->title = Dictionary::translateFile('backend-' . $s, $cred->property, true);
+ $cred->title = Dictionary::translateFile('backend-' . $s, $cred->property);
$cred->helptext = Dictionary::translateFile('backend-' . $s, $cred->property . "_helptext");
$cred->credentialsHtml = Render::parse('server-prop-' . $cred->template, (array)$cred);
}
@@ -776,9 +787,9 @@ class Page_LocationInfo extends Page
$DAYLIST = array_flip(['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday']);
$new = [];
foreach ($array as $row) {
- $s = $this->getTime($row['openingtime']);
- $e = $this->getTime($row['closingtime']);
- if ($s === false || $e === false || $e <= $s)
+ $s = Page_LocationInfo::getTime($row['openingtime']);
+ $e = Page_LocationInfo::getTime($row['closingtime']);
+ if ($s === null || $e === null || $e <= $s)
continue;
foreach ($row['days'] as $day) {
$day = $DAYLIST[$day] ?? -1;
@@ -833,10 +844,10 @@ class Page_LocationInfo extends Page
// Chain
$last++;
} else {
- $string = Dictionary::translate($DAYLIST[$first], true);
+ $string = Dictionary::translate($DAYLIST[$first]);
if ($first !== $last) {
$string .= ($first + 1 === $last ? ",\xe2\x80\x89" : "\xe2\x80\x89-\xe2\x80\x89")
- . Dictionary::translate($DAYLIST[$last], true);
+ . Dictionary::translate($DAYLIST[$last]);
}
$output[] = $string;
$first = $last = $day;
@@ -1034,7 +1045,7 @@ class Page_LocationInfo extends Page
die('Missing parameter uuid');
}
$type = InfoPanel::getConfig($uuid, $config);
- if ($type === false) {
+ if ($type === null) {
http_response_code(404);
die('Panel with given uuid not found');
}
@@ -1082,8 +1093,7 @@ class Page_LocationInfo extends Page
/**
* @param string|array $panelOrUuid UUID of panel, or array with keys paneltype and locationds
- * @param string $permission
- * @param int[]|null $additionalLocations
+ * @param int[] $additionalLocations
*/
private function assertPanelPermission($panelOrUuid, string $permission, array $additionalLocations = null): void
{