aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMichaela Brückner <brueckner@data-quest.de>2022-12-01 09:00:29 +0100
committerMichaela Brückner <brueckner@data-quest.de>2022-12-01 09:01:52 +0100
commit00ab0aa17d728136dc3e8d2c2b9056ea075a04ad (patch)
treeda02cdecff655704195e0661759518084cc8b183
parent08c85bb4f1cdc4a4419e370c00d5ff1d5fec012a (diff)
closes #1839
-rw-r--r--app/views/resources/_common/_special_permission_table.php123
-rw-r--r--app/views/resources/room_group/permissions.php2
2 files changed, 124 insertions, 1 deletions
diff --git a/app/views/resources/_common/_special_permission_table.php b/app/views/resources/_common/_special_permission_table.php
new file mode 100644
index 0000000..e401b4f
--- /dev/null
+++ b/app/views/resources/_common/_special_permission_table.php
@@ -0,0 +1,123 @@
+<?php
+/**
+ * Template variables:
+ * - table_id: The ID of the table. This is required for the JS code which adds
+ * new users to the table to work.
+ * - table caption: An optional table caption.
+ * - permissions: An array of ResourcePermission objects.
+ * - single_user: The User object in case the table is used in single
+ * user mode where the permissions of one specific user are displayed.
+ * - custom_columns: An associative multi-dimensional array to display
+ * additional columns.
+ * Structure:
+ * The first layer has the column names as indexes.
+ * The second layer contains an associative array with the cells
+ * for the column. That array has the permission object IDs
+ * (see permissions above) as indexes.
+ * - custom_actions: A multi-dimensional array for additional actions in the
+ * actions column. The array has the following structure:
+ * The first layer contains associative arrays where each array represents
+ * one action.
+ * The second layer consists of associative arrays with the following
+ * structure:
+ * [
+ * 'icon' => The Icon object for the action.
+ * 'title' => The descriptive title for the action.
+ * 'link_classes' => Classes which shall be added to the link element
+ * of the action.
+ * 'url' => An optional URL that shall be attached to the action's
+ * link element via the href attribute.
+ * 'js_action' => An optional JavaScript action that shall be attached
+ * to the link element using the onclick attribute.
+ * ]
+ */
+
+?>
+<table class="default sortable-table resource-permissions-table"
+ data-sortlist="[[1, 0]]"
+ <?= $table_id ? 'id="' . htmlReady($table_id) . '"' : '' ?>>
+ <? if (!empty($table_caption)): ?>
+ <caption><?= htmlReady($table_caption) ?></caption>
+ <? endif ?>
+ <colgroup>
+ <col>
+ <col>
+ <? if (!empty($custom_columns)): ?>
+ <? foreach ($custom_columns as $column_name): ?>
+ <col>
+ <? endforeach ?>
+ <? endif ?>
+ </colgroup>
+ <thead>
+ <tr>
+ <th data-sort="text"><?= _('Name') ?></th>
+ <th data-sort="htmldata"><?= _('Rechtestufe') ?></th>
+ <? if (!empty($custom_columns)): ?>
+ <? foreach (array_keys($custom_columns) as $column_name): ?>
+ <th><?= htmlReady($column_name) ?></th>
+ <? endforeach ?>
+ <? endif ?>
+ </tr>
+ </thead>
+ <tbody>
+ <? if (count($permissions)): ?>
+ <? foreach ($permissions as $permission): ?>
+ <?
+ $permission_sort_key = 10;
+ switch ($permission->perms) {
+ case 'autor':
+ {
+ $permission_sort_key = 20;
+ break;
+ }
+ case 'tutor':
+ {
+ $permission_sort_key = 30;
+ break;
+ }
+ case 'admin':
+ {
+ $permission_sort_key = 40;
+ break;
+ }
+ }
+ ?>
+ <tr data-user_id="<?= htmlReady($permission->user_id) ?>">
+ <td>
+ <? if ($permission->user instanceof User): ?>
+ <?= htmlReady($permission->user->getFullName('full_rev_username')) ?>
+ (<?= htmlReady($permission->user->perms) ?>)
+ <? else: ?>
+ <?= _('unbekannt') ?>
+ <? endif ?>
+ <input type="hidden" name="permissions[user_id][]"
+ value="<?= htmlReady($permission->user_id) ?>">
+ </td>
+ <td data-sort-value="<?= htmlReady($permission_sort_key) ?>">
+ <?= htmlReady($permission->perms) ?>
+ </td>
+ <? if (!empty($custom_columns)): ?>
+ <? foreach ($custom_columns as $column_content): ?>
+ <td>
+ <?= htmlReady($column_content[$permission->id]) ?>
+ </td>
+ <? endforeach ?>
+ <? endif ?>
+ </tr>
+ <? endforeach ?>
+ <? endif ?>
+ <tr id="resource-empty-permission-list-message"
+ <?= count($permissions) ? 'class="invisible"' : '' ?>>
+ <td colspan="3" style="text-align: center">
+ <? if ($single_user instanceof User): ?>
+ <?= $custom_empty_list_message ?: sprintf(
+ _('Es sind keine besonderen Rechte für %s vorhanden.'),
+ htmlReady($single_user->getFullName()
+ )) ?>
+ <? else: ?>
+ <?= $custom_empty_list_message ?: _('Es sind keine besonderen Rechte vorhanden.') ?>
+ <? endif ?>
+ </td>
+ </tr>
+ </tbody>
+</table>
diff --git a/app/views/resources/room_group/permissions.php b/app/views/resources/room_group/permissions.php
index 642f02f..aee23c3 100644
--- a/app/views/resources/room_group/permissions.php
+++ b/app/views/resources/room_group/permissions.php
@@ -42,7 +42,7 @@
) ?>
<? if ($partial_permissions): ?>
<?= $this->render_partial(
- 'resources/_common/_permission_table.php',
+ 'resources/_common/_special_permission_table.php',
[
'permissions' => $partial_permissions,
'custom_columns' => [