Compare commits
3 Commits
ab4f38a360
...
60eea92f11
| Author | SHA1 | Date | |
|---|---|---|---|
| 60eea92f11 | |||
| 5da7916651 | |||
| 8aadf65cc3 |
@@ -2893,18 +2893,50 @@ 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/jquery/jquery-3.5.1.min.js"></script>
|
||||||
<script type="text/javascript" src="/plugins/Semantic-UI-master/semantic.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')?>">
|
<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>
|
<script>
|
||||||
|
|
||||||
var $y = jQuery.noConflict();
|
var $y = jQuery.noConflict();
|
||||||
$y( document ).ready(function() {
|
$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() {
|
$("<?php echo "#all_get".$type;?>").click(function() {
|
||||||
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('set selected', <?= json_encode($allselect) ?>);
|
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('set selected', <?= json_encode($allselect) ?>);
|
||||||
});
|
});
|
||||||
$("<?php echo "#all_del".$type;?>").click(function() {
|
$("<?php echo "#all_del".$type;?>").click(function() {
|
||||||
console.log("delete");
|
console.log("delete");
|
||||||
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('clear');
|
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('clear');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<?
|
<?
|
||||||
|
|||||||
@@ -572,18 +572,50 @@ 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/jquery/jquery-3.5.1.min.js"></script>
|
||||||
<script type="text/javascript" src="/plugins/Semantic-UI-master/semantic.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')?>">
|
<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>
|
<script>
|
||||||
|
|
||||||
var $y = jQuery.noConflict();
|
var $y = jQuery.noConflict();
|
||||||
$y( document ).ready(function() {
|
$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() {
|
$("<?php echo "#all_get".$type;?>").click(function() {
|
||||||
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('set selected', <?= json_encode($allselect) ?>);
|
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('set selected', <?= json_encode($allselect) ?>);
|
||||||
});
|
});
|
||||||
$("<?php echo "#all_del".$type;?>").click(function() {
|
$("<?php echo "#all_del".$type;?>").click(function() {
|
||||||
console.log("delete");
|
console.log("delete");
|
||||||
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('clear');
|
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('clear');
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<?
|
<?
|
||||||
|
|||||||
@@ -62,6 +62,39 @@ function ajax_is_category_editable_for_br(int $categoryId): bool
|
|||||||
return false;
|
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
|
// Betriebsrat darf einen Post nur bearbeiten, wenn er in einer freigegebenen
|
||||||
// Kategorie (oder Unterkategorie einer freigegebenen Kategorie) liegt.
|
// Kategorie (oder Unterkategorie einer freigegebenen Kategorie) liegt.
|
||||||
function ajax_can_edit_post(int $postId): bool
|
function ajax_can_edit_post(int $postId): bool
|
||||||
@@ -1419,7 +1452,7 @@ function get_post_list()
|
|||||||
// nur Posts, die in dieser Kategorie sind
|
// nur Posts, die in dieser Kategorie sind
|
||||||
$categoryCondition = "
|
$categoryCondition = "
|
||||||
AND EXISTS (
|
AND EXISTS (
|
||||||
SELECT 1
|
SELECT 1
|
||||||
FROM knowledgecenter_category_post AS cp
|
FROM knowledgecenter_category_post AS cp
|
||||||
WHERE cp.post_id = kp.id
|
WHERE cp.post_id = kp.id
|
||||||
AND cp.category_id = $categoryId
|
AND cp.category_id = $categoryId
|
||||||
@@ -1428,20 +1461,39 @@ function get_post_list()
|
|||||||
$categoryCondition = "";
|
$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)
|
// Beiträge abfragen (nur Post‑ID und Titel der aktuellen Version)
|
||||||
$sqlPosts = "
|
$sqlPosts = "
|
||||||
SELECT
|
SELECT
|
||||||
kp.id AS post_id,
|
kp.id AS post_id,
|
||||||
pv.title AS current_title
|
pv.title AS current_title
|
||||||
FROM knowledgecenter_posts AS kp
|
FROM knowledgecenter_posts AS kp
|
||||||
LEFT JOIN knowledgecenter_post_versions AS pv
|
LEFT JOIN knowledgecenter_post_versions AS pv
|
||||||
ON kp.id = pv.post_id
|
ON kp.id = pv.post_id
|
||||||
AND pv.language_id = $languageId
|
AND pv.language_id = $languageId
|
||||||
/* … Bedingungen für gültige Version und höchste version_number … */
|
/* … Bedingungen für gültige Version und höchste version_number … */
|
||||||
WHERE 1=1
|
WHERE 1=1
|
||||||
$searchCondition
|
$searchCondition
|
||||||
$categoryCondition
|
$categoryCondition
|
||||||
|
$brCategoryCondition
|
||||||
GROUP BY kp.id
|
GROUP BY kp.id
|
||||||
ORDER BY kp.modified_at DESC
|
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)
|
// Prüft ob eine Kategorie (oder irgendein Vorfahre über knowledgecenter_category_links)
|
||||||
// betriebsrat_editable=1 hat. Läuft den Baum nach oben durch.
|
// betriebsrat_editable=1 hat. Läuft den Baum nach oben durch.
|
||||||
function is_category_betriebsrat_editable(int $categoryId): bool
|
function is_category_betriebsrat_editable(int $categoryId): bool
|
||||||
|
|||||||
@@ -134,6 +134,13 @@ while ($row = mysqli_fetch_assoc($resultSavedEinrichts)) {
|
|||||||
$savedEinrichts[] = $row['einricht_id'];
|
$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)
|
// Array mit Daten für Tagify (Einrichtungen)
|
||||||
$savedEinrichtsData = [];
|
$savedEinrichtsData = [];
|
||||||
foreach ($einrichts as $einricht) {
|
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'), {
|
var tagifyFachbereiche = new Tagify(document.getElementById('selected_fachbereiche'), {
|
||||||
whitelist: fachbereicheData,
|
whitelist: fachbereicheData,
|
||||||
|
|||||||
@@ -186,29 +186,44 @@ $_kcBrOnly = !is_wiki_redakteur() && is_wiki_betriebsrat();
|
|||||||
* gefiltert, sodass in den Bereichen (Abteilung, Mandant, Rolle) entweder kein Eintrag vorliegt
|
* gefiltert, sodass in den Bereichen (Abteilung, Mandant, Rolle) entweder kein Eintrag vorliegt
|
||||||
* oder der Eintrag mit den erlaubten Werten übereinstimmt.
|
* 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 = "
|
$sqlPosts = "
|
||||||
SELECT
|
SELECT
|
||||||
kp.id,
|
kp.id,
|
||||||
kp.modified_at,
|
kp.modified_at,
|
||||||
pv.title,
|
pv.title,
|
||||||
pv.image,
|
pv.image,
|
||||||
pv.link,
|
pv.link,
|
||||||
pv.link_label,
|
pv.link_label,
|
||||||
pv.version_number
|
pv.version_number
|
||||||
FROM
|
FROM
|
||||||
knowledgecenter_category_post AS kcp
|
knowledgecenter_category_post AS kcp
|
||||||
JOIN
|
JOIN
|
||||||
knowledgecenter_posts AS kp ON kcp.post_id = kp.id
|
knowledgecenter_posts AS kp ON kcp.post_id = kp.id
|
||||||
LEFT JOIN
|
LEFT JOIN
|
||||||
knowledgecenter_post_versions AS pv ON kp.id = pv.post_id
|
knowledgecenter_post_versions AS pv ON kp.id = pv.post_id
|
||||||
AND pv.language_id = $languageId
|
AND pv.language_id = $languageId
|
||||||
AND pv.state = 1
|
AND pv.state = 1
|
||||||
AND (pv.valid_from IS NULL OR pv.valid_from <= NOW())
|
AND (pv.valid_from IS NULL OR pv.valid_from <= NOW())
|
||||||
AND (pv.valid_until IS NULL OR pv.valid_until >= NOW())
|
AND (pv.valid_until IS NULL OR pv.valid_until >= NOW())
|
||||||
AND pv.version_number = (
|
AND pv.version_number = (
|
||||||
SELECT MAX(v2.version_number)
|
SELECT MAX(v2.version_number)
|
||||||
FROM knowledgecenter_post_versions AS v2
|
FROM knowledgecenter_post_versions AS v2
|
||||||
WHERE v2.post_id = kp.id
|
WHERE v2.post_id = kp.id
|
||||||
AND v2.language_id = $languageId
|
AND v2.language_id = $languageId
|
||||||
AND v2.state = 1
|
AND v2.state = 1
|
||||||
AND (v2.valid_from IS NULL OR v2.valid_from <= NOW())
|
AND (v2.valid_from IS NULL OR v2.valid_from <= NOW())
|
||||||
@@ -232,9 +247,10 @@ $_kcBrOnly = !is_wiki_redakteur() && is_wiki_betriebsrat();
|
|||||||
AND ( pr.role_id IS NULL OR pr.role_id IN ($allowedRoles) )
|
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 ( pe.einricht_id IS NULL OR pe.einricht_id IN ($allowedEinrichts) )
|
||||||
AND ( pfb.fachbereich_id IS NULL OR pfb.fachbereich_id IN ($allowedFachbereiche) )
|
AND ( pfb.fachbereich_id IS NULL OR pfb.fachbereich_id IN ($allowedFachbereiche) )
|
||||||
GROUP BY
|
$brCategoryFilter
|
||||||
|
GROUP BY
|
||||||
kp.id
|
kp.id
|
||||||
ORDER BY
|
ORDER BY
|
||||||
$orderBy $orderDir
|
$orderBy $orderDir
|
||||||
";
|
";
|
||||||
|
|
||||||
|
|||||||
@@ -75,7 +75,7 @@
|
|||||||
|
|
||||||
<!-- Right column: Sidebar with save button and meta fields -->
|
<!-- Right column: Sidebar with save button and meta fields -->
|
||||||
<div class="edit-sidebar">
|
<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">
|
<span title="<?= $translation->get("save") ?>" id="saveVersionBtn" class="post-action-btn-text green">
|
||||||
<?= $translation->get("save") ?>
|
<?= $translation->get("save") ?>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
@@ -136,6 +136,13 @@ $result = mysqli_query($GLOBALS['mysql_con'], $query);
|
|||||||
while ($row = mysqli_fetch_assoc($result)) {
|
while ($row = mysqli_fetch_assoc($result)) {
|
||||||
$postEinrichtsData[] = ['value' => $row['id'], 'name' => $row['description']];
|
$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 = [];
|
$selectedPostEinrichts = [];
|
||||||
if ($postId != 0) {
|
if ($postId != 0) {
|
||||||
$querySelected = "SELECT e.id, e.description
|
$querySelected = "SELECT e.id, e.description
|
||||||
@@ -409,6 +416,17 @@ if (!empty($post['text_color'])) {
|
|||||||
if (selectedPostEinrichts.length) {
|
if (selectedPostEinrichts.length) {
|
||||||
tagifyPostEinrichts.addTags(selectedPostEinrichts);
|
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
|
// Fachbereiche für Post
|
||||||
var tagifyPostFachbereiche = new Tagify(document.getElementById('postFachbereichTags'), {
|
var tagifyPostFachbereiche = new Tagify(document.getElementById('postFachbereichTags'), {
|
||||||
|
|||||||
@@ -3,14 +3,32 @@
|
|||||||
|
|
||||||
// Redirect-URL für den Zurück-Button bzw. Navigation
|
// Redirect-URL für den Zurück-Button bzw. Navigation
|
||||||
$redirectURL = isset($_GET['redirectURL']) ? $_GET['redirectURL'] : '?action=Category';
|
$redirectURL = isset($_GET['redirectURL']) ? $_GET['redirectURL'] : '?action=Category';
|
||||||
// Kategorien für das Dropdown holen (state = 1)
|
// Kategorien für das Dropdown holen
|
||||||
$catsQuery = "
|
$_isBrOnly = !is_wiki_redakteur() && is_wiki_betriebsrat();
|
||||||
SELECT c.id, t.title
|
if ($_isBrOnly) {
|
||||||
FROM knowledgecenter_categories_update AS c
|
$_brCatIds = get_all_betriebsrat_accessible_category_ids();
|
||||||
LEFT JOIN knowledgecenter_category_translations AS t
|
if (empty($_brCatIds)) {
|
||||||
ON t.category_id = c.id AND t.language_id = $languageId
|
$catsQuery = "SELECT NULL LIMIT 0";
|
||||||
ORDER BY t.title ASC
|
} 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);
|
$catsResult = mysqli_query($GLOBALS['mysql_con'], $catsQuery);
|
||||||
$allCategories = [];
|
$allCategories = [];
|
||||||
while ($r = mysqli_fetch_assoc($catsResult)) {
|
while ($r = mysqli_fetch_assoc($catsResult)) {
|
||||||
@@ -44,9 +62,14 @@ while ($r = mysqli_fetch_assoc($catsResult)) {
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
|
||||||
|
<?php
|
||||||
|
$_brCategoryIds = $_isBrOnly ? ($_brCatIds ?? []) : null;
|
||||||
|
$_brCategoryIdsJson = json_encode($_brCategoryIds);
|
||||||
|
?>
|
||||||
<script>
|
<script>
|
||||||
var myRedirectURL = window.location.href;
|
var myRedirectURL = window.location.href;
|
||||||
var debounceTimer;
|
var debounceTimer;
|
||||||
|
var brCategoryIds = <?= $_brCategoryIdsJson ?>;
|
||||||
|
|
||||||
function loadPostList() {
|
function loadPostList() {
|
||||||
var searchQuery = $('#searchQuery').val();
|
var searchQuery = $('#searchQuery').val();
|
||||||
@@ -61,7 +84,8 @@ while ($r = mysqli_fetch_assoc($catsResult)) {
|
|||||||
language_id: '<?= $languageId ?>',
|
language_id: '<?= $languageId ?>',
|
||||||
redirectURL: myRedirectURL,
|
redirectURL: myRedirectURL,
|
||||||
query: searchQuery,
|
query: searchQuery,
|
||||||
category_id: categoryId // hier mitgeben
|
category_id: categoryId,
|
||||||
|
br_category_ids: brCategoryIds !== null ? JSON.stringify(brCategoryIds) : null
|
||||||
},
|
},
|
||||||
dataType: 'json',
|
dataType: 'json',
|
||||||
beforeSend: function () { $('#overlayLoader').show(); },
|
beforeSend: function () { $('#overlayLoader').show(); },
|
||||||
|
|||||||
@@ -747,13 +747,45 @@ 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/jquery/jquery-3.5.1.min.js"></script>
|
||||||
<script type="text/javascript" src="/plugins/Semantic-UI-master/semantic.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')?>">
|
<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>
|
<script>
|
||||||
var $y = jQuery.noConflict();
|
var $y = jQuery.noConflict();
|
||||||
$y( document ).ready(function() {
|
$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() {
|
$("<?php echo "#all_".$type;?>").click(function() {
|
||||||
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('set selected', <?= json_encode($allselect) ?>);
|
$y('.websites.ui.fluid.multiple.dropdown.type_<?= $type ?>').dropdown('set selected', <?= json_encode($allselect) ?>);
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
<?
|
<?
|
||||||
|
|||||||
Reference in New Issue
Block a user