Compare commits
3 Commits
ab4f38a360
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| 60eea92f11 | |||
| 5da7916651 | |||
| 8aadf65cc3 |
@@ -2893,11 +2893,43 @@ function multi_select_permission($collection_id, $type){
|
||||
<script type="text/javascript" src="/plugins/jquery/jquery-3.5.1.min.js"></script>
|
||||
<script type="text/javascript" src="/plugins/Semantic-UI-master/semantic.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/plugins/Semantic-UI-master/bc-semantic.css?time=<?= filemtime($_SERVER['DOCUMENT_ROOT'] . '/plugins/Semantic-UI-master/bc-semantic.css')?>">
|
||||
<?php
|
||||
$einrichtLinks = [];
|
||||
if ($type == "einricht") {
|
||||
$linkRes = mysqli_query($GLOBALS['mysql_con'],
|
||||
"SELECT einricht_id, linked_einricht_id FROM organigramm_einricht_link");
|
||||
while ($lr = mysqli_fetch_assoc($linkRes)) {
|
||||
$einrichtLinks[strval($lr['einricht_id'])][] = strval($lr['linked_einricht_id']);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<script>
|
||||
|
||||
var $y = jQuery.noConflict();
|
||||
$y( document ).ready(function() {
|
||||
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('set selected', <?= json_encode($preselect) ?>);
|
||||
var $drop = $y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>');
|
||||
<?php if ($type == "einricht"): ?>
|
||||
var einrichtLinks = <?= json_encode($einrichtLinks) ?>;
|
||||
var busy = false;
|
||||
$drop.dropdown({
|
||||
onChange: function(value) {
|
||||
if (busy) return;
|
||||
var current = value ? value.split(',').filter(Boolean) : [];
|
||||
var toAdd = [];
|
||||
current.forEach(function(id) {
|
||||
(einrichtLinks[id] || []).forEach(function(lid) {
|
||||
if (current.indexOf(lid) < 0 && toAdd.indexOf(lid) < 0) toAdd.push(lid);
|
||||
});
|
||||
});
|
||||
if (toAdd.length) {
|
||||
busy = true;
|
||||
$drop.dropdown('set selected', current.concat(toAdd));
|
||||
busy = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
<?php endif; ?>
|
||||
$drop.dropdown('set selected', <?= json_encode($preselect) ?>);
|
||||
});
|
||||
$("<?php echo "#all_get".$type;?>").click(function() {
|
||||
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('set selected', <?= json_encode($allselect) ?>);
|
||||
|
||||
@@ -572,11 +572,43 @@ function multi_select_permission($collection_id, $type){
|
||||
<script type="text/javascript" src="/plugins/jquery/jquery-3.5.1.min.js"></script>
|
||||
<script type="text/javascript" src="/plugins/Semantic-UI-master/semantic.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/plugins/Semantic-UI-master/bc-semantic.css?time=<?= filemtime($_SERVER['DOCUMENT_ROOT'] . '/plugins/Semantic-UI-master/bc-semantic.css')?>">
|
||||
<?php
|
||||
$einrichtLinks = [];
|
||||
if ($type == "einricht") {
|
||||
$linkRes = mysqli_query($GLOBALS['mysql_con'],
|
||||
"SELECT einricht_id, linked_einricht_id FROM organigramm_einricht_link");
|
||||
while ($lr = mysqli_fetch_assoc($linkRes)) {
|
||||
$einrichtLinks[strval($lr['einricht_id'])][] = strval($lr['linked_einricht_id']);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<script>
|
||||
|
||||
var $y = jQuery.noConflict();
|
||||
$y( document ).ready(function() {
|
||||
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('set selected', <?= json_encode($preselect) ?>);
|
||||
var $drop = $y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>');
|
||||
<?php if ($type == "einricht"): ?>
|
||||
var einrichtLinks = <?= json_encode($einrichtLinks) ?>;
|
||||
var busy = false;
|
||||
$drop.dropdown({
|
||||
onChange: function(value) {
|
||||
if (busy) return;
|
||||
var current = value ? value.split(',').filter(Boolean) : [];
|
||||
var toAdd = [];
|
||||
current.forEach(function(id) {
|
||||
(einrichtLinks[id] || []).forEach(function(lid) {
|
||||
if (current.indexOf(lid) < 0 && toAdd.indexOf(lid) < 0) toAdd.push(lid);
|
||||
});
|
||||
});
|
||||
if (toAdd.length) {
|
||||
busy = true;
|
||||
$drop.dropdown('set selected', current.concat(toAdd));
|
||||
busy = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
<?php endif; ?>
|
||||
$drop.dropdown('set selected', <?= json_encode($preselect) ?>);
|
||||
});
|
||||
$("<?php echo "#all_get".$type;?>").click(function() {
|
||||
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('set selected', <?= json_encode($allselect) ?>);
|
||||
|
||||
@@ -62,6 +62,39 @@ function ajax_is_category_editable_for_br(int $categoryId): bool
|
||||
return false;
|
||||
}
|
||||
|
||||
// Alle Kategorie-IDs, die für Betriebsrat zugänglich sind (direkt betriebsrat_editable=1
|
||||
// plus alle Nachfahren im Baum – BFS nach unten).
|
||||
function ajax_get_all_betriebsrat_accessible_category_ids(): array
|
||||
{
|
||||
$seeds = [];
|
||||
$res = mysqli_query($GLOBALS['mysql_con'],
|
||||
"SELECT id FROM knowledgecenter_categories_update WHERE betriebsrat_editable = 1");
|
||||
while ($row = mysqli_fetch_assoc($res)) {
|
||||
$seeds[] = (int)$row['id'];
|
||||
}
|
||||
if (empty($seeds)) {
|
||||
return [];
|
||||
}
|
||||
$visited = [];
|
||||
$queue = $seeds;
|
||||
while (!empty($queue)) {
|
||||
$current = array_shift($queue);
|
||||
if (isset($visited[$current])) {
|
||||
continue;
|
||||
}
|
||||
$visited[$current] = true;
|
||||
$cRes = mysqli_query($GLOBALS['mysql_con'],
|
||||
"SELECT child_category_id FROM knowledgecenter_category_links WHERE parent_category_id = $current");
|
||||
while ($cRow = mysqli_fetch_assoc($cRes)) {
|
||||
$cid = (int)$cRow['child_category_id'];
|
||||
if (!isset($visited[$cid])) {
|
||||
$queue[] = $cid;
|
||||
}
|
||||
}
|
||||
}
|
||||
return array_keys($visited);
|
||||
}
|
||||
|
||||
// Betriebsrat darf einen Post nur bearbeiten, wenn er in einer freigegebenen
|
||||
// Kategorie (oder Unterkategorie einer freigegebenen Kategorie) liegt.
|
||||
function ajax_can_edit_post(int $postId): bool
|
||||
@@ -1428,6 +1461,24 @@ function get_post_list()
|
||||
$categoryCondition = "";
|
||||
}
|
||||
|
||||
// Betriebsrat darf nur Posts sehen, die in einer freigegebenen Kategorie liegen.
|
||||
// Die erlaubten Kategorie-IDs werden von post_listform.php berechnet und übergeben,
|
||||
// da get_permission_state() im Ajax-Kontext nicht verfügbar ist.
|
||||
$brCategoryCondition = "";
|
||||
$rawBrIds = isset($_POST['br_category_ids']) && $_POST['br_category_ids'] !== 'null'
|
||||
? json_decode($_POST['br_category_ids'], true)
|
||||
: null;
|
||||
if (is_array($rawBrIds)) {
|
||||
if (count($rawBrIds) === 0) {
|
||||
$brCategoryCondition = "AND 1=0";
|
||||
} else {
|
||||
$brCatIdList = implode(',', array_map('intval', $rawBrIds));
|
||||
$brCategoryCondition = "AND EXISTS (
|
||||
SELECT 1 FROM knowledgecenter_category_post AS cp_br
|
||||
WHERE cp_br.post_id = kp.id AND cp_br.category_id IN ($brCatIdList)
|
||||
)";
|
||||
}
|
||||
}
|
||||
|
||||
// Beiträge abfragen (nur Post‑ID und Titel der aktuellen Version)
|
||||
$sqlPosts = "
|
||||
@@ -1442,6 +1493,7 @@ function get_post_list()
|
||||
WHERE 1=1
|
||||
$searchCondition
|
||||
$categoryCondition
|
||||
$brCategoryCondition
|
||||
GROUP BY kp.id
|
||||
ORDER BY kp.modified_at DESC
|
||||
";
|
||||
|
||||
@@ -867,6 +867,39 @@ function require_wiki_edit_permission(): void
|
||||
}
|
||||
}
|
||||
|
||||
// Gibt alle Kategorie-IDs zurück, auf die Betriebsrat Zugriff hat:
|
||||
// direkt betriebsrat_editable=1 sowie alle ihre Nachfahren im Baum (BFS nach unten).
|
||||
function get_all_betriebsrat_accessible_category_ids(): array
|
||||
{
|
||||
$seeds = [];
|
||||
$res = mysqli_query($GLOBALS['mysql_con'],
|
||||
"SELECT id FROM knowledgecenter_categories_update WHERE betriebsrat_editable = 1");
|
||||
while ($row = mysqli_fetch_assoc($res)) {
|
||||
$seeds[] = (int)$row['id'];
|
||||
}
|
||||
if (empty($seeds)) {
|
||||
return [];
|
||||
}
|
||||
$visited = [];
|
||||
$queue = $seeds;
|
||||
while (!empty($queue)) {
|
||||
$current = array_shift($queue);
|
||||
if (isset($visited[$current])) {
|
||||
continue;
|
||||
}
|
||||
$visited[$current] = true;
|
||||
$cRes = mysqli_query($GLOBALS['mysql_con'],
|
||||
"SELECT child_category_id FROM knowledgecenter_category_links WHERE parent_category_id = $current");
|
||||
while ($cRow = mysqli_fetch_assoc($cRes)) {
|
||||
$cid = (int)$cRow['child_category_id'];
|
||||
if (!isset($visited[$cid])) {
|
||||
$queue[] = $cid;
|
||||
}
|
||||
}
|
||||
}
|
||||
return array_keys($visited);
|
||||
}
|
||||
|
||||
// Prüft ob eine Kategorie (oder irgendein Vorfahre über knowledgecenter_category_links)
|
||||
// betriebsrat_editable=1 hat. Läuft den Baum nach oben durch.
|
||||
function is_category_betriebsrat_editable(int $categoryId): bool
|
||||
|
||||
@@ -134,6 +134,13 @@ while ($row = mysqli_fetch_assoc($resultSavedEinrichts)) {
|
||||
$savedEinrichts[] = $row['einricht_id'];
|
||||
}
|
||||
|
||||
// Verknüpfungskarte für Einrichtungen (Gruppen → Mitglieder)
|
||||
$einrichtLinks = [];
|
||||
$linkRes = mysqli_query($GLOBALS['mysql_con'], "SELECT einricht_id, linked_einricht_id FROM organigramm_einricht_link");
|
||||
while ($lr = mysqli_fetch_assoc($linkRes)) {
|
||||
$einrichtLinks[strval($lr['einricht_id'])][] = strval($lr['linked_einricht_id']);
|
||||
}
|
||||
|
||||
// Array mit Daten für Tagify (Einrichtungen)
|
||||
$savedEinrichtsData = [];
|
||||
foreach ($einrichts as $einricht) {
|
||||
@@ -842,6 +849,17 @@ $parentCount = count($parentCategories);
|
||||
}
|
||||
}
|
||||
});
|
||||
var einrichtLinks = <?= json_encode($einrichtLinks) ?>;
|
||||
tagifyEinrichts.on('add', function(e) {
|
||||
var addedId = String(e.detail.data.value);
|
||||
(einrichtLinks[addedId] || []).forEach(function(lid) {
|
||||
var exists = tagifyEinrichts.value.some(function(t) { return String(t.value) === lid; });
|
||||
if (!exists) {
|
||||
var item = einrichtsData.find(function(d) { return String(d.value) === lid; });
|
||||
if (item) tagifyEinrichts.addTags([item]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
var tagifyFachbereiche = new Tagify(document.getElementById('selected_fachbereiche'), {
|
||||
whitelist: fachbereicheData,
|
||||
|
||||
@@ -186,6 +186,21 @@ $_kcBrOnly = !is_wiki_redakteur() && is_wiki_betriebsrat();
|
||||
* gefiltert, sodass in den Bereichen (Abteilung, Mandant, Rolle) entweder kein Eintrag vorliegt
|
||||
* oder der Eintrag mit den erlaubten Werten übereinstimmt.
|
||||
*/
|
||||
// Für Betriebsrat: nur Beiträge zeigen, die mindestens einer freigegebenen Kategorie zugeordnet sind
|
||||
$brCategoryFilter = '';
|
||||
if ($_kcBrOnly) {
|
||||
$brCatIds = get_all_betriebsrat_accessible_category_ids();
|
||||
if (empty($brCatIds)) {
|
||||
$brCategoryFilter = 'AND 1=0'; // kein Zugriff
|
||||
} else {
|
||||
$brCatIdList = implode(',', $brCatIds);
|
||||
$brCategoryFilter = "AND EXISTS (
|
||||
SELECT 1 FROM knowledgecenter_category_post kcp_br
|
||||
WHERE kcp_br.post_id = kp.id AND kcp_br.category_id IN ($brCatIdList)
|
||||
)";
|
||||
}
|
||||
}
|
||||
|
||||
$sqlPosts = "
|
||||
SELECT
|
||||
kp.id,
|
||||
@@ -232,6 +247,7 @@ $_kcBrOnly = !is_wiki_redakteur() && is_wiki_betriebsrat();
|
||||
AND ( pr.role_id IS NULL OR pr.role_id IN ($allowedRoles) )
|
||||
AND ( pe.einricht_id IS NULL OR pe.einricht_id IN ($allowedEinrichts) )
|
||||
AND ( pfb.fachbereich_id IS NULL OR pfb.fachbereich_id IN ($allowedFachbereiche) )
|
||||
$brCategoryFilter
|
||||
GROUP BY
|
||||
kp.id
|
||||
ORDER BY
|
||||
|
||||
@@ -75,7 +75,7 @@
|
||||
|
||||
<!-- Right column: Sidebar with save button and meta fields -->
|
||||
<div class="edit-sidebar">
|
||||
<?php if (get_permission_state('r-wiki', $GLOBALS['main_contact']['master_mandant_id'], $GLOBALS['main_contact']['id']) == 1 || get_permission_state('r-wiki', $GLOBALS['main_contact']['master_mandant_id'], $GLOBALS['main_contact']['id']) == 1) { ?>
|
||||
<?php if ($canEditPost ?? false) { ?>
|
||||
<span title="<?= $translation->get("save") ?>" id="saveVersionBtn" class="post-action-btn-text green">
|
||||
<?= $translation->get("save") ?>
|
||||
</span>
|
||||
|
||||
@@ -136,6 +136,13 @@ $result = mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
while ($row = mysqli_fetch_assoc($result)) {
|
||||
$postEinrichtsData[] = ['value' => $row['id'], 'name' => $row['description']];
|
||||
}
|
||||
|
||||
// Verknüpfungskarte für Einrichtungen (Gruppen → Mitglieder)
|
||||
$postEinrichtLinks = [];
|
||||
$linkRes = mysqli_query($GLOBALS['mysql_con'], "SELECT einricht_id, linked_einricht_id FROM organigramm_einricht_link");
|
||||
while ($lr = mysqli_fetch_assoc($linkRes)) {
|
||||
$postEinrichtLinks[strval($lr['einricht_id'])][] = strval($lr['linked_einricht_id']);
|
||||
}
|
||||
$selectedPostEinrichts = [];
|
||||
if ($postId != 0) {
|
||||
$querySelected = "SELECT e.id, e.description
|
||||
@@ -409,6 +416,17 @@ if (!empty($post['text_color'])) {
|
||||
if (selectedPostEinrichts.length) {
|
||||
tagifyPostEinrichts.addTags(selectedPostEinrichts);
|
||||
}
|
||||
var postEinrichtLinks = <?= json_encode($postEinrichtLinks) ?>;
|
||||
tagifyPostEinrichts.on('add', function(e) {
|
||||
var addedId = String(e.detail.data.value);
|
||||
(postEinrichtLinks[addedId] || []).forEach(function(lid) {
|
||||
var exists = tagifyPostEinrichts.value.some(function(t) { return String(t.value) === lid; });
|
||||
if (!exists) {
|
||||
var item = postEinrichtsData.find(function(d) { return String(d.value) === lid; });
|
||||
if (item) tagifyPostEinrichts.addTags([item]);
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
// Fachbereiche für Post
|
||||
var tagifyPostFachbereiche = new Tagify(document.getElementById('postFachbereichTags'), {
|
||||
|
||||
@@ -3,14 +3,32 @@
|
||||
|
||||
// Redirect-URL für den Zurück-Button bzw. Navigation
|
||||
$redirectURL = isset($_GET['redirectURL']) ? $_GET['redirectURL'] : '?action=Category';
|
||||
// Kategorien für das Dropdown holen (state = 1)
|
||||
$catsQuery = "
|
||||
SELECT c.id, t.title
|
||||
FROM knowledgecenter_categories_update AS c
|
||||
LEFT JOIN knowledgecenter_category_translations AS t
|
||||
ON t.category_id = c.id AND t.language_id = $languageId
|
||||
ORDER BY t.title ASC
|
||||
";
|
||||
// Kategorien für das Dropdown holen
|
||||
$_isBrOnly = !is_wiki_redakteur() && is_wiki_betriebsrat();
|
||||
if ($_isBrOnly) {
|
||||
$_brCatIds = get_all_betriebsrat_accessible_category_ids();
|
||||
if (empty($_brCatIds)) {
|
||||
$catsQuery = "SELECT NULL LIMIT 0";
|
||||
} else {
|
||||
$_brCatIdList = implode(',', $_brCatIds);
|
||||
$catsQuery = "
|
||||
SELECT c.id, t.title
|
||||
FROM knowledgecenter_categories_update AS c
|
||||
LEFT JOIN knowledgecenter_category_translations AS t
|
||||
ON t.category_id = c.id AND t.language_id = $languageId
|
||||
WHERE c.id IN ($_brCatIdList)
|
||||
ORDER BY t.title ASC
|
||||
";
|
||||
}
|
||||
} else {
|
||||
$catsQuery = "
|
||||
SELECT c.id, t.title
|
||||
FROM knowledgecenter_categories_update AS c
|
||||
LEFT JOIN knowledgecenter_category_translations AS t
|
||||
ON t.category_id = c.id AND t.language_id = $languageId
|
||||
ORDER BY t.title ASC
|
||||
";
|
||||
}
|
||||
$catsResult = mysqli_query($GLOBALS['mysql_con'], $catsQuery);
|
||||
$allCategories = [];
|
||||
while ($r = mysqli_fetch_assoc($catsResult)) {
|
||||
@@ -44,9 +62,14 @@ while ($r = mysqli_fetch_assoc($catsResult)) {
|
||||
</div>
|
||||
|
||||
|
||||
<?php
|
||||
$_brCategoryIds = $_isBrOnly ? ($_brCatIds ?? []) : null;
|
||||
$_brCategoryIdsJson = json_encode($_brCategoryIds);
|
||||
?>
|
||||
<script>
|
||||
var myRedirectURL = window.location.href;
|
||||
var debounceTimer;
|
||||
var brCategoryIds = <?= $_brCategoryIdsJson ?>;
|
||||
|
||||
function loadPostList() {
|
||||
var searchQuery = $('#searchQuery').val();
|
||||
@@ -61,7 +84,8 @@ while ($r = mysqli_fetch_assoc($catsResult)) {
|
||||
language_id: '<?= $languageId ?>',
|
||||
redirectURL: myRedirectURL,
|
||||
query: searchQuery,
|
||||
category_id: categoryId // hier mitgeben
|
||||
category_id: categoryId,
|
||||
br_category_ids: brCategoryIds !== null ? JSON.stringify(brCategoryIds) : null
|
||||
},
|
||||
dataType: 'json',
|
||||
beforeSend: function () { $('#overlayLoader').show(); },
|
||||
|
||||
@@ -747,10 +747,42 @@ function multi_select_permission($navigation_id, $type){
|
||||
<script type="text/javascript" src="/plugins/jquery/jquery-3.5.1.min.js"></script>
|
||||
<script type="text/javascript" src="/plugins/Semantic-UI-master/semantic.min.js"></script>
|
||||
<link rel="stylesheet" type="text/css" href="/plugins/Semantic-UI-master/bc-semantic.css?time=<?= filemtime($_SERVER['DOCUMENT_ROOT'] . '/plugins/Semantic-UI-master/bc-semantic.css')?>">
|
||||
<?php
|
||||
$einrichtLinks = [];
|
||||
if ($type == "einricht") {
|
||||
$linkRes = mysqli_query($GLOBALS['mysql_con'],
|
||||
"SELECT einricht_id, linked_einricht_id FROM organigramm_einricht_link");
|
||||
while ($lr = mysqli_fetch_assoc($linkRes)) {
|
||||
$einrichtLinks[strval($lr['einricht_id'])][] = strval($lr['linked_einricht_id']);
|
||||
}
|
||||
}
|
||||
?>
|
||||
<script>
|
||||
var $y = jQuery.noConflict();
|
||||
$y( document ).ready(function() {
|
||||
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('set selected', <?= json_encode($preselect) ?>);
|
||||
var $drop = $y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>');
|
||||
<?php if ($type == "einricht"): ?>
|
||||
var einrichtLinks = <?= json_encode($einrichtLinks) ?>;
|
||||
var busy = false;
|
||||
$drop.dropdown({
|
||||
onChange: function(value) {
|
||||
if (busy) return;
|
||||
var current = value ? value.split(',').filter(Boolean) : [];
|
||||
var toAdd = [];
|
||||
current.forEach(function(id) {
|
||||
(einrichtLinks[id] || []).forEach(function(lid) {
|
||||
if (current.indexOf(lid) < 0 && toAdd.indexOf(lid) < 0) toAdd.push(lid);
|
||||
});
|
||||
});
|
||||
if (toAdd.length) {
|
||||
busy = true;
|
||||
$drop.dropdown('set selected', current.concat(toAdd));
|
||||
busy = false;
|
||||
}
|
||||
}
|
||||
});
|
||||
<?php endif; ?>
|
||||
$drop.dropdown('set selected', <?= json_encode($preselect) ?>);
|
||||
});
|
||||
$("<?php echo "#all_".$type;?>").click(function() {
|
||||
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('set selected', <?= json_encode($allselect) ?>);
|
||||
|
||||
Reference in New Issue
Block a user