diff --git a/db/migrations/2023_12_27_000000_add_shifttypes_edit_permission_and_shifttypes_requires_shico.php b/db/migrations/2023_12_27_000000_add_shifttypes_edit_permission_and_shifttypes_requires_shico.php
new file mode 100644
index 00000000..2237670b
--- /dev/null
+++ b/db/migrations/2023_12_27_000000_add_shifttypes_edit_permission_and_shifttypes_requires_shico.php
@@ -0,0 +1,77 @@
+db = $this->schema->getConnection();
+
+ $this->shifttypes = $this->db->table('privileges')
+ ->where('name', 'shifttypes')
+ ->get(['id'])
+ ->first()->id;
+ }
+
+ /**
+ * Run the migration
+ */
+ public function up(): void
+ {
+ $db = $this->schema->getConnection();
+ $db->table('privileges')
+ ->insert([
+ 'name' => 'shifttypes.edit', 'description' => 'Edit shift types',
+ ]);
+
+ $editShifttypes = $db->table('privileges')
+ ->where('name', 'shifttypes.edit')
+ ->get(['id'])
+ ->first();
+
+ $this->movePermission($this->shifttypes, $this->bureaucrat, $this->shiCo);
+
+ $db->table('group_privileges')
+ ->insertOrIgnore([
+ 'group_id' => $this->bureaucrat, 'privilege_id' => $editShifttypes->id,
+ ]);
+ }
+
+ /**
+ * Reverse the migration
+ */
+ public function down(): void
+ {
+ $db = $this->schema->getConnection();
+ $db->table('privileges')
+ ->where('name', 'shifttypes.edit')
+ ->delete();
+
+ $this->movePermission($this->shifttypes, $this->shiCo, $this->bureaucrat);
+ }
+
+ protected function movePermission(int $privilege, int $oldGroup, int $newGroup): void
+ {
+ $this->db->table('group_privileges')
+ ->insertOrIgnore(['group_id' => $newGroup, 'privilege_id' => $privilege]);
+
+ $this->db->table('group_privileges')
+ ->where(['group_id' => $oldGroup, 'privilege_id' => $privilege])
+ ->delete();
+ }
+}
diff --git a/includes/view/Locations_view.php b/includes/view/Locations_view.php
index 749d44db..8932ac55 100644
--- a/includes/view/Locations_view.php
+++ b/includes/view/Locations_view.php
@@ -27,6 +27,22 @@ function location_view(Location $location, ShiftsFilterRenderer $shiftsFilterRen
$description .= $parsedown->parse(htmlspecialchars($location->description));
}
+ $neededAngelTypes = '';
+ if (auth()->can('admin_shifts')) {
+ $neededAngelTypes .= '
' . __('location.required_angels') . '
';
+ foreach ($location->neededAngelTypes as $neededAngelType) {
+ if ($neededAngelType->count) {
+ $neededAngelTypes .= '- ' . $neededAngelType->angelType->name
+ . ': '
+ . $neededAngelType->count
+ . '
';
+ }
+ }
+ $neededAngelTypes .= '
';
+ }
+
$dect = '';
if (config('enable_dect') && $location->dect) {
$dect = heading(__('Contact'), 3)
@@ -77,6 +93,7 @@ function location_view(Location $location, ShiftsFilterRenderer $shiftsFilterRen
]) : '',
$dect,
$description,
+ $neededAngelTypes,
tabs($tabs, $selected_tab),
],
true
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index 5a8e0a61..7222650a 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -564,10 +564,10 @@ function User_view(
'actions' => __('general.actions'),
], $my_shifts));
} elseif ($user_source->state->force_active) {
- $myshifts_table = success(__(
- 'myshifts.sucess',
- [($its_me ? __('You have') : ($user_source->name . ' ' . __('has')))]
- ), true);
+ $myshifts_table = success(
+ ($its_me ? __('You have done enough.') : (__('%s has done enough.', [$user_source->name]))),
+ true
+ );
}
}
diff --git a/resources/lang/de_DE/default.po b/resources/lang/de_DE/default.po
index 0f7f0d6d..40597449 100644
--- a/resources/lang/de_DE/default.po
+++ b/resources/lang/de_DE/default.po
@@ -1196,14 +1196,11 @@ msgstr "Dauer"
msgid "Name & Workmates"
msgstr "Name & Kollegen"
-msgid "myshifts.sucess"
-msgstr "%s genug gemacht."
+msgid "You have done enough."
+msgstr "Du hast genug gemacht."
-msgid "You have"
-msgstr "Du hast"
-
-msgid "has"
-msgstr "hat"
+msgid "%s has done enough."
+msgstr "%s hat genug gemacht."
msgid "Vouchers"
msgstr "Gutscheine"
diff --git a/resources/lang/en_US/default.po b/resources/lang/en_US/default.po
index adb0934b..378317af 100644
--- a/resources/lang/en_US/default.po
+++ b/resources/lang/en_US/default.po
@@ -943,6 +943,3 @@ msgstr "Actions"
msgid "general.back"
msgstr "Back"
-
-msgid "myshifts.sucess"
-msgstr "%s done enough."
diff --git a/resources/views/admin/shifttypes/index.twig b/resources/views/admin/shifttypes/index.twig
index 15bdda08..42ae512a 100644
--- a/resources/views/admin/shifttypes/index.twig
+++ b/resources/views/admin/shifttypes/index.twig
@@ -13,9 +13,9 @@
{{ block('title') }}
- {% if is_index|default(false) %}
+ {% if is_index|default(false) and has_permission_to('shifttypes.edit') %}
{{ m.button(m.icon('plus-lg'), url('/admin/shifttypes/edit'), 'secondary') }}
- {% elseif has_permission_to('shifttypes') and is_view|default(false) %}
+ {% elseif is_view|default(false) and has_permission_to('shifttypes.edit') %}
{{ m.button(m.icon('pencil'), url('admin/shifttypes/edit/' ~ shifttype.id), null, 'sm', __('form.edit')) }}
{% endif %}
@@ -43,8 +43,8 @@
+ {% if has_permission_to('shifttypes.edit') %}
-
{{ m.button(m.icon('pencil'), url('admin/shifttypes/edit/' ~ shifttype.id), null, 'sm', __('form.edit')) }}
+ {% endif %}
|
{% endfor %}
diff --git a/resources/views/admin/shifttypes/view.twig b/resources/views/admin/shifttypes/view.twig
index ab5eb26f..d36333da 100644
--- a/resources/views/admin/shifttypes/view.twig
+++ b/resources/views/admin/shifttypes/view.twig
@@ -5,7 +5,22 @@
{% block title %}{{ shifttype.name }}{% endblock %}
{% block row_content %}
-
- {{ shifttype.description|md }}
-
+
+
{{ __('general.description') }}
+ {{ shifttype.description|md }}
+
+
+
{{ __('location.required_angels') }}
+
+
{% endblock %}
diff --git a/src/Controllers/Admin/ShiftTypesController.php b/src/Controllers/Admin/ShiftTypesController.php
index 4ed43516..8fd1fb8e 100644
--- a/src/Controllers/Admin/ShiftTypesController.php
+++ b/src/Controllers/Admin/ShiftTypesController.php
@@ -24,6 +24,9 @@ class ShiftTypesController extends BaseController
/** @var array */
protected array $permissions = [
'shifttypes',
+ 'edit' => 'shifttypes.edit',
+ 'delete' => 'shifttypes.edit',
+ 'save' => 'shifttypes.edit',
];
public function __construct(