fix(wiki): Betriebsrat-UI vollständig korrigiert

- categories_posts_listform.php: brCategoryFilter entfernt, Betriebsrat
  sieht alle Kategorien (nur "Beitrag erstellen"-Button gefiltert)
- post_cardform_article.php: Bearbeiten- und "Neue Version"-Button jetzt
  über \$canEditPost gesteuert statt hart auf r-wiki geprüft
- post_cardform.php: Settings-Tab-Link und -Inhalt ebenfalls über
  \$canEditPost freigegeben
- post_cardform_settings.php: Kategorie-Whitelist wird für Betriebsrat
  auf freigegebene Kategorien gefiltert (inkl. Vererbung);
  Speichern-Button und JS-Handler über \$canEditPost gesteuert

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-06-29 08:09:19 +02:00
parent 4d6cc807c9
commit 3aa523870f
4 changed files with 29 additions and 37 deletions

View File

@@ -27,9 +27,7 @@ if (empty($GLOBALS['allowedRoles'])) {
// Standard-Redirect-URL (zum Beispiel für Navigation) // Standard-Redirect-URL (zum Beispiel für Navigation)
$redirectURL = isset($_GET['redirectURL']) ? $_GET['redirectURL'] : '?action=List'; $redirectURL = isset($_GET['redirectURL']) ? $_GET['redirectURL'] : '?action=List';
// Betriebsrat sieht nur Kategorien, die für ihn freigegeben sind
$_kcBrOnly = !is_wiki_redakteur() && is_wiki_betriebsrat(); $_kcBrOnly = !is_wiki_redakteur() && is_wiki_betriebsrat();
$brCategoryFilter = $_kcBrOnly ? 'AND c.betriebsrat_editable = 1' : '';
?> ?>
<script> <script>
(function () { (function () {
@@ -54,14 +52,12 @@ $brCategoryFilter = $_kcBrOnly ? 'AND c.betriebsrat_editable = 1' : '';
<div class="titlebar-actions"> <div class="titlebar-actions">
<?php <?php
// "Beitrag erstellen" für Redakteur immer, für Betriebsrat nur in freigegebenen Kategorien // "Beitrag erstellen" für Redakteur immer, für Betriebsrat nur in freigegebenen Kategorien
// (inkl. Vererbung: Unterkategorien einer freigegebenen Kategorie gelten ebenfalls)
$showCreateBtn = false; $showCreateBtn = false;
if (is_wiki_redakteur()) { if (is_wiki_redakteur()) {
$showCreateBtn = true; $showCreateBtn = true;
} elseif ($_kcBrOnly && isset($_GET['detail'])) { } elseif ($_kcBrOnly && isset($_GET['detail'])) {
$brCatRes = mysqli_query($GLOBALS['mysql_con'], $showCreateBtn = is_category_betriebsrat_editable((int)$_GET['detail']);
"SELECT betriebsrat_editable FROM knowledgecenter_categories_update WHERE id = " . (int)$_GET['detail'] . " LIMIT 1");
$brCatRow = mysqli_fetch_assoc($brCatRes);
$showCreateBtn = $brCatRow && (int)$brCatRow['betriebsrat_editable'];
} }
if ($showCreateBtn) { ?> if ($showCreateBtn) { ?>
<a href="?action=NewPost&InitialCategory=<?= (int)($_GET["detail"] ?? 0) ?>" <a href="?action=NewPost&InitialCategory=<?= (int)($_GET["detail"] ?? 0) ?>"
@@ -160,7 +156,6 @@ $brCategoryFilter = $_kcBrOnly ? 'AND c.betriebsrat_editable = 1' : '';
AND ( cr.role_id IS NULL OR cr.role_id IN ($allowedRoles) ) AND ( cr.role_id IS NULL OR cr.role_id IN ($allowedRoles) )
AND ( ce.einricht_id IS NULL OR ce.einricht_id IN ($allowedEinrichts) ) AND ( ce.einricht_id IS NULL OR ce.einricht_id IN ($allowedEinrichts) )
AND ( cf.fachbereich_id IS NULL OR cf.fachbereich_id IN ($allowedFachbereiche) ) AND ( cf.fachbereich_id IS NULL OR cf.fachbereich_id IN ($allowedFachbereiche) )
$brCategoryFilter
GROUP BY GROUP BY
c.id c.id
ORDER BY ORDER BY
@@ -314,7 +309,6 @@ $brCategoryFilter = $_kcBrOnly ? 'AND c.betriebsrat_editable = 1' : '';
AND ( cr.role_id IS NULL OR cr.role_id IN ($allowedRoles) ) AND ( cr.role_id IS NULL OR cr.role_id IN ($allowedRoles) )
AND ( ce.einricht_id IS NULL OR ce.einricht_id IN ($allowedEinrichts) ) AND ( ce.einricht_id IS NULL OR ce.einricht_id IN ($allowedEinrichts) )
AND ( cf.fachbereich_id IS NULL OR cf.fachbereich_id IN ($allowedFachbereiche) ) AND ( cf.fachbereich_id IS NULL OR cf.fachbereich_id IN ($allowedFachbereiche) )
$brCategoryFilter
GROUP BY GROUP BY
c.id c.id
ORDER BY ORDER BY

View File

@@ -150,12 +150,9 @@ $InitialProduct = isset($_GET['InitialProduct']) ? (int) $_GET['InitialProduct']
if ($isNew) { if ($isNew) {
require_wiki_edit_permission(); require_wiki_edit_permission();
// Betriebsrat darf nur in Kategorien erstellen, die als betriebsrat_editable markiert sind // Betriebsrat darf nur in Kategorien erstellen, die für ihn freigegeben sind (inkl. Vererbung)
if (!is_wiki_redakteur() && $initialCategoryId > 0) { if (!is_wiki_redakteur() && $initialCategoryId > 0) {
$brCatRes = mysqli_query($GLOBALS['mysql_con'], if (!is_category_betriebsrat_editable($initialCategoryId)) {
"SELECT betriebsrat_editable FROM knowledgecenter_categories_update WHERE id = $initialCategoryId LIMIT 1");
$brCatRow = mysqli_fetch_assoc($brCatRes);
if (!$brCatRow || !(int)$brCatRow['betriebsrat_editable']) {
echo "<p>Sie haben nicht die Berechtigung, in dieser Kategorie zu erstellen.</p>"; echo "<p>Sie haben nicht die Berechtigung, in dieser Kategorie zu erstellen.</p>";
exit; exit;
} }
@@ -187,16 +184,18 @@ if ($isNew) {
exit; exit;
} }
// Schreibrechte: Redakteur darf alles; Betriebsrat nur in freigegebenen Kategorien // Schreibrechte: Redakteur darf alles; Betriebsrat nur in freigegebenen Kategorien (inkl. Vererbung)
$canEditPost = is_wiki_redakteur(); $canEditPost = is_wiki_redakteur();
if (!$canEditPost && is_wiki_betriebsrat()) { if (!$canEditPost && is_wiki_betriebsrat()) {
$brEditRes = mysqli_query($GLOBALS['mysql_con'], $brCatRes = mysqli_query($GLOBALS['mysql_con'],
"SELECT COUNT(*) AS cnt "SELECT category_id FROM knowledgecenter_category_post WHERE post_id = $postId");
FROM knowledgecenter_category_post kcp $canEditPost = false;
JOIN knowledgecenter_categories_update kcu ON kcu.id = kcp.category_id while ($brCatRow = mysqli_fetch_assoc($brCatRes)) {
WHERE kcp.post_id = $postId AND kcu.betriebsrat_editable = 1"); if (is_category_betriebsrat_editable((int)$brCatRow['category_id'])) {
$brEditRow = mysqli_fetch_assoc($brEditRes); $canEditPost = true;
$canEditPost = ($brEditRow && (int)$brEditRow['cnt'] > 0); break;
}
}
} }
// Beitrag aus der Haupttabelle abrufen // Beitrag aus der Haupttabelle abrufen
$sqlPost = "SELECT * FROM knowledgecenter_posts WHERE id = $postId LIMIT 1"; $sqlPost = "SELECT * FROM knowledgecenter_posts WHERE id = $postId LIMIT 1";
@@ -383,7 +382,7 @@ if ($resLinkedForm && mysqli_num_rows($resLinkedForm) > 0) {
<a href="#tab-files"><?= $translation->get("files") ?> (<?php echo $fileCount; ?>)</a> <a href="#tab-files"><?= $translation->get("files") ?> (<?php echo $fileCount; ?>)</a>
<a href="#tab-contacts"><?= $translation->get("Ansprechpartner") ?> (<?php echo $contactCount; ?>)</a> <a href="#tab-contacts"><?= $translation->get("Ansprechpartner") ?> (<?php echo $contactCount; ?>)</a>
<a href="#tab-versions"><?= $translation->get("version_history") ?> (<?php echo $versionCount; ?>)</a> <a href="#tab-versions"><?= $translation->get("version_history") ?> (<?php echo $versionCount; ?>)</a>
<?php if (is_wiki_redakteur()) { ?> <?php if ($canEditPost ?? false) { ?>
<a href="#tab-settings"><?= $translation->get("settings") ?></a> <a href="#tab-settings"><?= $translation->get("settings") ?></a>
<?php } ?> <?php } ?>
</div> </div>
@@ -451,7 +450,7 @@ if ($resLinkedForm && mysqli_num_rows($resLinkedForm) > 0) {
require_once 'post_cardform_version_history.php'; require_once 'post_cardform_version_history.php';
?> ?>
</div> </div>
<?php if (is_wiki_redakteur()) { ?> <?php if ($canEditPost ?? false) { ?>
<div id="tab-settings" class="tab-content"> <div id="tab-settings" class="tab-content">
<?php <?php
require_once 'post_cardform_settings.php'; require_once 'post_cardform_settings.php';

View File

@@ -121,14 +121,9 @@
<h1 id="displayTitle"><?php echo htmlspecialchars($currentVersion['title']); ?></h1> <h1 id="displayTitle"><?php echo htmlspecialchars($currentVersion['title']); ?></h1>
<?php endif; ?> <?php endif; ?>
<div> <div>
<?php if (!empty($postId) && $postId > 0): ?> <?php if (!empty($postId) && $postId > 0 && ($canEditPost ?? false)): ?>
<?php if (get_permission_state('r-wiki', $GLOBALS['main_contact']['master_mandant_id'], $GLOBALS['main_contact']['id']) == 1): ?> <span id="editBtn" class="post-action-btn grey" title="Aktuelle Version bearbeiten">✎</span>
<span id="editBtn" class="post-action-btn grey" title="Aktuelle Version bearbeiten">✎</span> <span id="createBtn" class="green" title="Neue Version erstellen">Neue Version erstellen +</span>
<?php endif; ?>
<?php if (get_permission_state('r-wiki', $GLOBALS['main_contact']['master_mandant_id'], $GLOBALS['main_contact']['id']) == 1): ?>
<span id="createBtn" class="green" title="Neue Version erstellen">Neue Version erstellen +</span>
<?php endif; ?>
<?php endif; ?> <?php endif; ?>
</div> </div>
</div> </div>

View File

@@ -36,6 +36,7 @@ while ($row = mysqli_fetch_assoc($result)) {
// -------------------- Kategorien -------------------- // -------------------- Kategorien --------------------
// Erzeuge die Whitelist für alle verfügbaren Kategorien (mit Übersetzung) // Erzeuge die Whitelist für alle verfügbaren Kategorien (mit Übersetzung)
// Betriebsrat sieht nur Kategorien, die für ihn freigegeben sind (direkt oder über Elternkategorie)
$categoriesData = []; $categoriesData = [];
$query = "SELECT c.id, t.title, c.enable_post_color_pickers $query = "SELECT c.id, t.title, c.enable_post_color_pickers
FROM knowledgecenter_categories_update AS c FROM knowledgecenter_categories_update AS c
@@ -43,8 +44,11 @@ $query = "SELECT c.id, t.title, c.enable_post_color_pickers
ON c.id = t.category_id ON c.id = t.category_id
WHERE t.language_id = $languageId"; WHERE t.language_id = $languageId";
$result = mysqli_query($GLOBALS['mysql_con'], $query); $result = mysqli_query($GLOBALS['mysql_con'], $query);
$isBrOnly = !is_wiki_redakteur() && is_wiki_betriebsrat();
while ($row = mysqli_fetch_assoc($result)) { while ($row = mysqli_fetch_assoc($result)) {
// Hier wird der in der Übersetzungstabelle gespeicherte Titel als 'name' verwendet. if ($isBrOnly && !is_category_betriebsrat_editable((int)$row['id'])) {
continue;
}
$categoriesData[] = [ $categoriesData[] = [
'value' => $row['id'], 'value' => $row['id'],
'name' => $row['title'], 'name' => $row['title'],
@@ -185,7 +189,7 @@ if (!empty($post['text_color'])) {
<button id="message" style="opacity:0; position: absolute;"></button> <button id="message" style="opacity:0; position: absolute;"></button>
<div class="titlebar_small"> <div class="titlebar_small">
<h2><?=$translation->get("settings")?></h2> <h2><?=$translation->get("settings")?></h2>
<?php if (get_permission_state('r-wiki', $GLOBALS['main_contact']['master_mandant_id'], $GLOBALS['main_contact']['id']) == 1) { ?> <?php if ($canEditPost ?? false) { ?>
<span id="saveAllBtn" class="post-action-btn-small green"><?= $saveIcon ?></span> <span id="saveAllBtn" class="post-action-btn-small green"><?= $saveIcon ?></span>
<?php } ?> <?php } ?>
</div> </div>
@@ -424,7 +428,7 @@ if (!empty($post['text_color'])) {
tagifyPostFachbereiche.addTags(selectedPostFachbereiche); tagifyPostFachbereiche.addTags(selectedPostFachbereiche);
} }
<?php if (get_permission_state('r-wiki', $GLOBALS['main_contact']['master_mandant_id'], $GLOBALS['main_contact']['id']) == 1) { ?> <?php if ($canEditPost ?? false) { ?>
$("#saveAllBtn").on("click", function () { $("#saveAllBtn").on("click", function () {
// Während des Speicherns blurren // Während des Speicherns blurren
$("#tab-settings").addClass("blurred"); $("#tab-settings").addClass("blurred");