knowledgecenter: add Einrichtung/Fachbereich to category permission form
categories_cardform.php now loads and displays tagify pickers for Einrichtungen and Fachbereiche alongside the existing Mandant/Abteilung/Rolle pickers. The saveTagifyData() function passes all 5 types to update_category_links. Also ran DB migration: all permission data from the 5 old _link tables has been copied into the new permission tables (mandant: 178, department: 1108, role: 2159, einricht: 10023, fachbereich: 2722 rows). Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -112,6 +112,52 @@ foreach ($roles as $role) {
|
||||
}
|
||||
}
|
||||
|
||||
// Einrichtungen abrufen
|
||||
$einrichts = [];
|
||||
$resultEinrichts = mysqli_query($GLOBALS['mysql_con'], "SELECT id, description FROM organigramm_einricht ORDER BY description ASC");
|
||||
while ($row = mysqli_fetch_assoc($resultEinrichts)) {
|
||||
$einrichts[] = $row;
|
||||
}
|
||||
|
||||
// Fachbereiche abrufen
|
||||
$fachbereiche = [];
|
||||
$resultFachbereiche = mysqli_query($GLOBALS['mysql_con'], "SELECT id, description FROM organogramm_space ORDER BY description ASC");
|
||||
while ($row = mysqli_fetch_assoc($resultFachbereiche)) {
|
||||
$fachbereiche[] = $row;
|
||||
}
|
||||
|
||||
// Gespeicherte Einrichtungen abrufen
|
||||
$savedEinrichts = [];
|
||||
$querySavedEinrichts = "SELECT einricht_id FROM knowledgecenter_category_einricht WHERE category_id = $categoryId";
|
||||
$resultSavedEinrichts = mysqli_query($GLOBALS['mysql_con'], $querySavedEinrichts);
|
||||
while ($row = mysqli_fetch_assoc($resultSavedEinrichts)) {
|
||||
$savedEinrichts[] = $row['einricht_id'];
|
||||
}
|
||||
|
||||
// Array mit Daten für Tagify (Einrichtungen)
|
||||
$savedEinrichtsData = [];
|
||||
foreach ($einrichts as $einricht) {
|
||||
if (in_array($einricht['id'], $savedEinrichts)) {
|
||||
$savedEinrichtsData[] = ['value' => $einricht['id'], 'name' => $einricht['description']];
|
||||
}
|
||||
}
|
||||
|
||||
// Gespeicherte Fachbereiche abrufen
|
||||
$savedFachbereiche = [];
|
||||
$querySavedFachbereiche = "SELECT fachbereich_id FROM knowledgecenter_category_fachbereich WHERE category_id = $categoryId";
|
||||
$resultSavedFachbereiche = mysqli_query($GLOBALS['mysql_con'], $querySavedFachbereiche);
|
||||
while ($row = mysqli_fetch_assoc($resultSavedFachbereiche)) {
|
||||
$savedFachbereiche[] = $row['fachbereich_id'];
|
||||
}
|
||||
|
||||
// Array mit Daten für Tagify (Fachbereiche)
|
||||
$savedFachbereicheData = [];
|
||||
foreach ($fachbereiche as $fachbereich) {
|
||||
if (in_array($fachbereich['id'], $savedFachbereiche)) {
|
||||
$savedFachbereicheData[] = ['value' => $fachbereich['id'], 'name' => $fachbereich['description']];
|
||||
}
|
||||
}
|
||||
|
||||
// Kategorie auslesen
|
||||
$query = "SELECT c.* FROM knowledgecenter_categories_update AS c WHERE c.id = $categoryId LIMIT 1";
|
||||
$result = mysqli_query($GLOBALS['mysql_con'], $query);
|
||||
@@ -383,6 +429,16 @@ $parentCount = count($parentCategories);
|
||||
<input type="text" id="selected_roles" name="selected_roles"
|
||||
value='<?= htmlspecialchars(json_encode($savedRolesData)); ?>'>
|
||||
</label>
|
||||
<label for="selected_einrichts">
|
||||
Einrichtungen
|
||||
<input type="text" id="selected_einrichts" name="selected_einrichts"
|
||||
value='<?= htmlspecialchars(json_encode($savedEinrichtsData)); ?>'>
|
||||
</label>
|
||||
<label for="selected_fachbereiche">
|
||||
Fachbereiche
|
||||
<input type="text" id="selected_fachbereiche" name="selected_fachbereiche"
|
||||
value='<?= htmlspecialchars(json_encode($savedFachbereicheData)); ?>'>
|
||||
</label>
|
||||
</div>
|
||||
<?php endif; ?>
|
||||
|
||||
@@ -486,11 +542,13 @@ $parentCount = count($parentCategories);
|
||||
processNextForm();
|
||||
}
|
||||
|
||||
// Funktion zum Speichern der Tagify-Daten (Mandanten, Departments, Rollen)
|
||||
// Funktion zum Speichern der Tagify-Daten (Mandanten, Departments, Rollen, Einrichtungen, Fachbereiche)
|
||||
function saveTagifyData() {
|
||||
var mandants = JSON.stringify(tagifyMandants.value.map(function (t) { return t.value; }));
|
||||
var departments = JSON.stringify(tagifyDepartments.value.map(function (t) { return t.value; }));
|
||||
var roles = JSON.stringify(tagifyRoles.value.map(function (t) { return t.value; }));
|
||||
var einrichts = JSON.stringify(tagifyEinrichts.value.map(function (t) { return t.value; }));
|
||||
var fachbereiche = JSON.stringify(tagifyFachbereiche.value.map(function (t) { return t.value; }));
|
||||
|
||||
$.post("/module/knowledgecenter_update/Ajax/Ajax.php", {
|
||||
action: "update_category_links",
|
||||
@@ -498,6 +556,8 @@ $parentCount = count($parentCategories);
|
||||
mandants: mandants,
|
||||
departments: departments,
|
||||
roles: roles,
|
||||
einrichts: einrichts,
|
||||
fachbereiche: fachbereiche,
|
||||
modified_by: $("#modified_by").val()
|
||||
}, function (response) {
|
||||
if (!response.success) {
|
||||
@@ -511,6 +571,12 @@ $parentCount = count($parentCategories);
|
||||
|
||||
tagifyRoles.removeAllTags();
|
||||
tagifyRoles.addTags(response.roles);
|
||||
|
||||
tagifyEinrichts.removeAllTags();
|
||||
tagifyEinrichts.addTags(response.einrichts);
|
||||
|
||||
tagifyFachbereiche.removeAllTags();
|
||||
tagifyFachbereiche.addTags(response.fachbereiche);
|
||||
}
|
||||
}, "json");
|
||||
}
|
||||
@@ -738,6 +804,52 @@ $parentCount = count($parentCategories);
|
||||
}
|
||||
});
|
||||
|
||||
var einrichtsData = <?php echo json_encode(array_map(function ($item) {
|
||||
return ['value' => $item['id'], 'name' => $item['description']];
|
||||
}, $einrichts)); ?>;
|
||||
|
||||
var fachbereicheData = <?php echo json_encode(array_map(function ($item) {
|
||||
return ['value' => $item['id'], 'name' => $item['description']];
|
||||
}, $fachbereiche)); ?>;
|
||||
|
||||
var tagifyEinrichts = new Tagify(document.getElementById('selected_einrichts'), {
|
||||
whitelist: einrichtsData,
|
||||
tagTextProp: 'name',
|
||||
enforceWhitelist: true,
|
||||
dropdown: {
|
||||
enabled: 0,
|
||||
maxItems: Infinity,
|
||||
searchKeys: ["name"]
|
||||
},
|
||||
templates: {
|
||||
dropdownItem: function (tagData) {
|
||||
return `<div ${this.getAttributes(tagData)}
|
||||
class="tagify__dropdown__item">
|
||||
<span>${tagData.name}</span>
|
||||
</div>`;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
var tagifyFachbereiche = new Tagify(document.getElementById('selected_fachbereiche'), {
|
||||
whitelist: fachbereicheData,
|
||||
tagTextProp: 'name',
|
||||
enforceWhitelist: true,
|
||||
dropdown: {
|
||||
enabled: 0,
|
||||
maxItems: Infinity,
|
||||
searchKeys: ["name"]
|
||||
},
|
||||
templates: {
|
||||
dropdownItem: function (tagData) {
|
||||
return `<div ${this.getAttributes(tagData)}
|
||||
class="tagify__dropdown__item">
|
||||
<span>${tagData.name}</span>
|
||||
</div>`;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Handler für das Löschen einer Kategorie
|
||||
$("#deleteCategory").on("click", function () {
|
||||
if (confirm("Möchten Sie diese Kategorie wirklich löschen? Diese Aktion kann nicht rückgängig gemacht werden.")) {
|
||||
|
||||
Reference in New Issue
Block a user