Add user.fa.edit permission
This commit is contained in:
parent
e6251256b3
commit
7e06923ed0
|
@ -0,0 +1,44 @@
|
||||||
|
<?php
|
||||||
|
|
||||||
|
declare(strict_types=1);
|
||||||
|
|
||||||
|
namespace Engelsystem\Migrations;
|
||||||
|
|
||||||
|
use Engelsystem\Database\Migration\Migration;
|
||||||
|
|
||||||
|
class AddUserFaEditPermission extends Migration
|
||||||
|
{
|
||||||
|
/**
|
||||||
|
* Run the migration
|
||||||
|
*/
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
$db = $this->schema->getConnection();
|
||||||
|
$db->table('privileges')
|
||||||
|
->insert([
|
||||||
|
'name' => 'user.fa.edit', 'description' => 'Edit User Force Active State',
|
||||||
|
]);
|
||||||
|
|
||||||
|
$editFa = $db->table('privileges')
|
||||||
|
->where('name', 'user.fa.edit')
|
||||||
|
->get(['id'])
|
||||||
|
->first();
|
||||||
|
|
||||||
|
$bureaucrat = 80;
|
||||||
|
$db->table('group_privileges')
|
||||||
|
->insertOrIgnore([
|
||||||
|
['group_id' => $bureaucrat, 'privilege_id' => $editFa->id],
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reverse the migration
|
||||||
|
*/
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
$db = $this->schema->getConnection();
|
||||||
|
$db->table('privileges')
|
||||||
|
->where('name', 'user.fa.edit')
|
||||||
|
->delete();
|
||||||
|
}
|
||||||
|
}
|
|
@ -271,7 +271,7 @@ function user_controller()
|
||||||
$shifts,
|
$shifts,
|
||||||
$user->id == $user_source->id,
|
$user->id == $user_source->id,
|
||||||
$tshirt_score,
|
$tshirt_score,
|
||||||
auth()->can('admin_active'),
|
auth()->can('user.edit.shirt'),
|
||||||
auth()->can('admin_user_worklog'),
|
auth()->can('admin_user_worklog'),
|
||||||
$worklogs,
|
$worklogs,
|
||||||
auth()->can('user.ifsg.edit')
|
auth()->can('user.ifsg.edit')
|
||||||
|
|
|
@ -255,9 +255,9 @@ function admin_active()
|
||||||
$userData['work_time'] = sprintf('%.2f', round($timeSum / 3600, 2)) . ' h';
|
$userData['work_time'] = sprintf('%.2f', round($timeSum / 3600, 2)) . ' h';
|
||||||
$userData['score'] = round($usr['shift_length'] / 60)
|
$userData['score'] = round($usr['shift_length'] / 60)
|
||||||
. ' min (' . sprintf('%.2f', $usr['shift_length'] / 3600) . ' h)';
|
. ' min (' . sprintf('%.2f', $usr['shift_length'] / 3600) . ' h)';
|
||||||
$userData['active'] = icon_bool($usr->state->active == 1);
|
$userData['active'] = icon_bool($usr->state->active);
|
||||||
$userData['force_active'] = icon_bool($usr->state->force_active == 1);
|
$userData['force_active'] = icon_bool($usr->state->force_active);
|
||||||
$userData['tshirt'] = icon_bool($usr->state->got_shirt == 1);
|
$userData['tshirt'] = icon_bool($usr->state->got_shirt);
|
||||||
$userData['shift_count'] = $usr['shift_count'];
|
$userData['shift_count'] = $usr['shift_count'];
|
||||||
|
|
||||||
$actions = [];
|
$actions = [];
|
||||||
|
|
|
@ -140,9 +140,14 @@ function admin_user()
|
||||||
}
|
}
|
||||||
|
|
||||||
// Forced active?
|
// Forced active?
|
||||||
if (auth()->can('admin_active') && config('enable_force_active')) {
|
if (config('enable_force_active')) {
|
||||||
$html .= ' <tr><td>' . __('Force active') . '</td><td>' . "\n";
|
$html .= ' <tr><td>' . __('Force active') . '</td><td>' . "\n";
|
||||||
$html .= html_options('force_active', $options, $user_source->state->force_active) . '</td></tr>' . "\n";
|
if (auth()->can('user.fa.edit')) {
|
||||||
|
$html .= html_options('force_active', $options, $user_source->state->force_active);
|
||||||
|
} else {
|
||||||
|
$html .= ($user_source->state->force_active ? __('Yes') : __('No'));
|
||||||
|
}
|
||||||
|
$html .= '</td></tr>' . "\n";
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($goodie_enabled && $user_edit_shirt) {
|
if ($goodie_enabled && $user_edit_shirt) {
|
||||||
|
@ -341,7 +346,7 @@ function admin_user()
|
||||||
if ($user_edit_shirt) {
|
if ($user_edit_shirt) {
|
||||||
$user_source->state->active = $request->postData('eAktiv');
|
$user_source->state->active = $request->postData('eAktiv');
|
||||||
}
|
}
|
||||||
if (auth()->can('admin_active') && config('enable_force_active')) {
|
if (auth()->can('user.fa.edit') && config('enable_force_active')) {
|
||||||
$user_source->state->force_active = $request->input('force_active');
|
$user_source->state->force_active = $request->input('force_active');
|
||||||
}
|
}
|
||||||
$user_source->state->save();
|
$user_source->state->save();
|
||||||
|
|
Loading…
Reference in New Issue