Merge pull request #37 from Programvareverkstedet/patch

Various patches; Fix admin groups, update deps
This commit is contained in:
Felix Albrigtsen 2023-01-19 13:58:10 +01:00 committed by GitHub
commit 31d9a955df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 17 additions and 7 deletions

View File

@ -2,6 +2,6 @@
FROM php:7.4-cli FROM php:7.4-cli
RUN apt-get update && \ RUN apt-get update && \
apt-get install -y \ apt-get install -y \
sqlite \ sqlite3 \
unzip \ unzip \
git git

View File

@ -5,5 +5,10 @@
}, },
"require-dev": { "require-dev": {
"ext-pdo_sqlite": "*" "ext-pdo_sqlite": "*"
},
"config": {
"allow-plugins": {
"simplesamlphp/composer-module-installer": true
}
} }
} }

View File

@ -51,17 +51,17 @@ function loginBar($sp = null, $pdo = null) {
$userManager = new \pvv\admin\UserManager($pdo); $userManager = new \pvv\admin\UserManager($pdo);
$isAdmin = $userManager->isAdmin($uname); $isAdmin = $userManager->isAdmin($uname);
} }
$result .= "\t<a id=\"login\" href=\"#usermenu\" aria-hidden=\"true\">${svg}" . htmlspecialchars($uname) . "</a>\n"; $result .= "\t<a id=\"login\" href=\"#usermenu\" aria-hidden=\"true\">{$svg}" . htmlspecialchars($uname) . "</a>\n";
$result .= "\n\t<ul id=\"usermenu\">\n"; $result .= "\n\t<ul id=\"usermenu\">\n";
$result .= "\n\t\t<li><a id=\"login\" href=\"#\">${svg}" . htmlspecialchars($uname) . "</a></li>\n"; $result .= "\n\t\t<li><a id=\"login\" href=\"#\">{$svg}" . htmlspecialchars($uname) . "</a></li>\n";
if ($isAdmin) { if ($isAdmin) {
$result .= "\n\t\t<li><a href=\"/admin/\">Admin</a></li>\n"; $result .= "\n\t\t<li><a href=\"/admin/\">Admin</a></li>\n";
} }
$result .= "\n\t\t<li><a href=\"" . htmlspecialchars($as->getLogoutURL()) . "\">Logg ut</a></li>\n"; $result .= "\n\t\t<li><a href=\"" . htmlspecialchars($as->getLogoutURL()) . "\">Logg ut</a></li>\n";
$result .= "\n\t</ul>\n"; $result .= "\n\t</ul>\n";
} else { } else {
$result .= "\t<a id=\"login\" href=\"" . htmlspecialchars($as->getLoginURL()) . "\">${svg}Logg inn</a>\n"; $result .= "\t<a id=\"login\" href=\"" . htmlspecialchars($as->getLoginURL()) . "\">{$svg}Logg inn</a>\n";
} }
$result .= "\n\t<a href=\"#menu\" id=\"menu_toggle\" aria-hidden=\"true\"><big>&#9776;&nbsp;</big>MENU</a>\n"; $result .= "\n\t<a href=\"#menu\" id=\"menu_toggle\" aria-hidden=\"true\"><big>&#9776;&nbsp;</big>MENU</a>\n";

View File

@ -32,7 +32,7 @@ class UserManager{
} }
public function addGroup($uname, $group){ public function addGroup($uname, $group){
$userFlags = $this->getUsergroups(); $userFlags = $this->getUsergroups($uname);
if($userFlags){ if($userFlags){
$newFlags = ($group | $userFlags); $newFlags = ($group | $userFlags);
@ -41,7 +41,7 @@ class UserManager{
} }
public function removeGroup($uname, $group){ public function removeGroup($uname, $group){
$userFlags = $this->getUsergroups(); $userFlags = $this->getUsergroups($uname);
if($userFlags){ if($userFlags){
$newFlags = ($userFlags & (~ $group)); $newFlags = ($userFlags & (~ $group));

View File

@ -111,6 +111,11 @@ $imageTemplate = '
]; ];
echo strtr($imageTemplate, $vars); echo strtr($imageTemplate, $vars);
} }
if (count($images) == 0) {
echo "<h3 class='no-images'>Det er dessverre ingen bilder å vise.</h3>";
}
?> ?>
</main> </main>
<div id="modal" class="modal"> <div id="modal" class="modal">