Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: pull from upstream #7

Merged
merged 14 commits into from
Aug 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 17 additions & 7 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,20 @@ ln -s ../../bin/pre-commit .git/hooks/pre-commit

## Docker

We suggest using Docker for the Development local build.
> [!TIP]
> We suggest using Docker for the Development local build.
> This repo [ships a docker setup](docker/dev) for a quick development start.
> If you use another uid/gid than 1000 on your machine you have to adjust it in [docker/dev/.env](docker/dev/.env).

If unspecific issues appear try using Docker version >= 20.10.14.

This repo [ships a docker setup](docker/dev) for a quick development start.

If you use another uid/gid than 1000 on your machine you have to adjust it in [docker/dev/.env](docker/dev/.env).

Run this once
Make sure you're in the `docker/dev` subfolder:

```bash
cd docker/dev
```

Then, run
```bash
docker compose up
```

Expand Down Expand Up @@ -215,3 +217,11 @@ For some reason *PhpStorm* is unable to detect the server name.
But without a server name it's impossible to set up path mappings.
Because of that the docker setup sets the server name *engelsystem*.
To get Xdebug working you have to create a server with the name *engelsystem* manually.

## Troubleshooting

### Docker version
If unspecific issues appear try using Docker version >= 20.10.14.

### `service "es_workspace" is not running`
Make sure you're running your docker commands from the `docker/dev` directory, not from `docker`
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ The Engelsystem can now be used.
* Both Apache and Nginx allow for different VirtualHost configurations.

### Docker

For instructions on how to build the Docker container for development, please consult the [DEVELOPMENT.md](DEVELOPMENT.md).

#### Build
To build the `es_server` container:
```bash
Expand Down
2 changes: 1 addition & 1 deletion config/config.default.php
Original file line number Diff line number Diff line change
Expand Up @@ -413,7 +413,7 @@

// Whether to show the current day of the event (-2, -1, 0, 1, 2…) in footer and on the dashboard.
// The event start date has to be set for it to appear.
'enable_show_day_of_event' => (bool) env('ENABLE_SHOW_DAY_OF_EVENT', false),
'enable_day_of_event' => (bool) env('ENABLE_DAY_OF_EVENT', false),
// If true there will be a day 0 (-1, 0, 1…). If false there won't (-1, 1…)
'event_has_day0' => (bool) env('EVENT_HAS_DAY0', true),

Expand Down
8 changes: 4 additions & 4 deletions includes/controller/angeltypes_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,13 @@ function angeltype_delete_controller()

if (request()->hasPostData('delete')) {
$angeltype->delete();
engelsystem_log('Deleted angeltype: ' . AngelType_name_render($angeltype, true));
success(sprintf(__('Angeltype %s deleted.'), $angeltype->name));
engelsystem_log('Deleted angel type: ' . AngelType_name_render($angeltype, true));
success(sprintf(__('Angel type %s deleted.'), $angeltype->name));
throw_redirect(url('/angeltypes'));
}

return [
sprintf(__('Delete angeltype %s'), htmlspecialchars($angeltype->name)),
sprintf(__('Delete angel type %s'), htmlspecialchars($angeltype->name)),
AngelType_delete_view($angeltype),
];
}
Expand Down Expand Up @@ -137,7 +137,7 @@ function angeltype_edit_controller()

success(__('Angel type saved.'));
engelsystem_log(
'Saved angeltype: ' . $angeltype->name . ($angeltype->restricted ? ', restricted' : '')
'Saved angel type: ' . $angeltype->name . ($angeltype->restricted ? ', restricted' : '')
. ($angeltype->shift_self_signup ? ', shift_self_signup' : '')
. (config('driving_license_enabled')
? (($angeltype->requires_driver_license ? ', requires driver license' : '') . ', ')
Expand Down
4 changes: 2 additions & 2 deletions includes/controller/shift_entries_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ function shift_entry_create_controller_supporter(Shift $shift, AngelType $angelt
}

if (!$signup_user->userAngelTypes()->wherePivot('angel_type_id', $angeltype->id)->exists()) {
error(__('User is not in angeltype.'));
error(__('User is not in angel type.'));
throw_redirect(shift_link($shift));
}

Expand Down Expand Up @@ -186,7 +186,7 @@ function shift_entry_create_controller_supporter(Shift $shift, AngelType $angelt
function shift_entry_error_message(ShiftSignupState $shift_signup_state)
{
match ($shift_signup_state->getState()) {
ShiftSignupStatus::ANGELTYPE => error(__('You need be accepted member of the angeltype.')),
ShiftSignupStatus::ANGELTYPE => error(__('You need be accepted member of the angel type.')),
ShiftSignupStatus::COLLIDES => error(__('This shift collides with one of your shifts.')),
ShiftSignupStatus::OCCUPIED => error(__('This shift is already occupied.')),
ShiftSignupStatus::SHIFT_ENDED => error(__('This shift ended already.')),
Expand Down
4 changes: 2 additions & 2 deletions includes/controller/shifts_controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ function shift_edit_controller()
$shifttype_id = $request->input('shifttype_id');
} else {
$valid = false;
error(__('Please select a shifttype.'));
error(__('Please select a shift type.'));
}

if ($request->has('start') && $tmp = DateTime::createFromFormat('Y-m-d H:i', $request->input('start'))) {
Expand Down Expand Up @@ -208,7 +208,7 @@ function shift_edit_controller()
. info(__('This page is much more comfortable with javascript.'), true)
. '</noscript>',
form([
form_select('shifttype_id', __('Shifttype'), $shifttypes, $shifttype_id),
form_select('shifttype_id', __('Shift type'), $shifttypes, $shifttype_id),
form_text('title', __('title.title'), $title),
form_select('rid', __('Location:'), $locations, $rid),
form_text('start', __('Start:'), $start->format('Y-m-d H:i')),
Expand Down
52 changes: 24 additions & 28 deletions includes/controller/user_angeltypes_controller.php
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<?php

use Engelsystem\Http\Exceptions\HttpForbidden;
use Engelsystem\Http\Exceptions\HttpNotFound;
use Engelsystem\Mail\EngelsystemMailer;
use Engelsystem\Models\AngelType;
use Engelsystem\Models\User\User;
Expand Down Expand Up @@ -38,19 +40,18 @@ function user_angeltypes_unconfirmed_hint()
$unconfirmed_links[] = '<a href="'
. url('/angeltypes', ['action' => 'view', 'angeltype_id' => $user_angeltype->angel_type_id])
. '">' . htmlspecialchars($user_angeltype->angelType->name)
. ' (+' . $user_angeltype->count . ')'
. ' (+' . $user_angeltype->users_count . ')'
. '</a>';
}

$count = $unconfirmed_user_angeltypes->count();
return
_e(
'There is %d unconfirmed angeltype.',
'There are %d unconfirmed angeltypes.',
'There are unconfirmed angels in %d angel type. Angel type that needs approval:',
'There are unconfirmed angels in %d angel types. Angel types that need approvals:',
$count,
[$count]
)
. ' ' . __('Angel types which need approvals:')
. ' ' . join(', ', $unconfirmed_links);
}

Expand All @@ -70,7 +71,7 @@ function user_angeltypes_delete_all_controller(): array

$angeltype = AngelType::findOrFail($request->input('angeltype_id'));
if (!auth()->user()->isAngelTypeSupporter($angeltype) && !auth()->can('admin_user_angeltypes')) {
error(__('You are not allowed to delete all users for this angeltype.'));
error(__('You are not allowed to delete all users for this angel type.'));
throw_redirect(url('/angeltypes'));
}

Expand All @@ -79,8 +80,8 @@ function user_angeltypes_delete_all_controller(): array
->whereNull('confirm_user_id')
->delete();

engelsystem_log(sprintf('Denied all users for angeltype %s', AngelType_name_render($angeltype, true)));
success(sprintf(__('Denied all users for angeltype %s.'), $angeltype->name));
engelsystem_log(sprintf('Denied all users for angel type %s', AngelType_name_render($angeltype, true)));
success(sprintf(__('Denied all users for angel type %s.'), $angeltype->name));
throw_redirect(url('/angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype->id]));
}

Expand All @@ -107,7 +108,7 @@ function user_angeltypes_confirm_all_controller(): array

$angeltype = AngelType::findOrFail($request->input('angeltype_id'));
if (!auth()->can('admin_user_angeltypes') && !$user->isAngelTypeSupporter($angeltype)) {
error(__('You are not allowed to confirm all users for this angeltype.'));
error(__('You are not allowed to confirm all users for this angel type.'));
throw_redirect(url('/angeltypes'));
}

Expand All @@ -118,8 +119,8 @@ function user_angeltypes_confirm_all_controller(): array
->whereNull('confirm_user_id')
->update(['confirm_user_id' => $user->id]);

engelsystem_log(sprintf('Confirmed all users for angeltype %s', AngelType_name_render($angeltype, true)));
success(sprintf(__('Confirmed all users for angeltype %s.'), $angeltype->name));
engelsystem_log(sprintf('Confirmed all users for angel type %s', AngelType_name_render($angeltype, true)));
success(sprintf(__('Confirmed all users for angel type %s.'), $angeltype->name));

foreach ($users as $user) {
user_angeltype_confirm_email($user, $angeltype);
Expand All @@ -145,15 +146,14 @@ function user_angeltype_confirm_controller(): array
$request = request();

if (!$request->has('user_angeltype_id')) {
error(__('User angeltype doesn\'t exist.'));
throw_redirect(url('/angeltypes'));
throw new HttpNotFound();
}

/** @var UserAngelType $user_angeltype */
$user_angeltype = UserAngelType::findOrFail($request->input('user_angeltype_id'));
$angeltype = $user_angeltype->angelType;
if (!$user->isAngelTypeSupporter($angeltype) && !auth()->can('admin_user_angeltypes')) {
error(__('You are not allowed to confirm this users angeltype.'));
error(__('You are not allowed to confirm this users angel type.'));
throw_redirect(url('/angeltypes'));
}

Expand All @@ -163,19 +163,19 @@ function user_angeltype_confirm_controller(): array
$user_angeltype->save();

engelsystem_log(sprintf(
'%s confirmed for angeltype %s',
'%s confirmed for angel type %s',
User_Nick_render($user_source, true),
AngelType_name_render($angeltype, true)
));
success(sprintf(__('%s confirmed for angeltype %s.'), $user_source->displayName, $angeltype->name));
success(sprintf(__('%s confirmed for angel type %s.'), $user_source->displayName, $angeltype->name));

user_angeltype_confirm_email($user_source, $angeltype);

throw_redirect(url('/angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype->id]));
}

return [
__('Confirm angeltype for user'),
__('Confirm angel type for user'),
UserAngelType_confirm_view($user_angeltype, $user_source, $angeltype),
];
}
Expand Down Expand Up @@ -223,8 +223,7 @@ function user_angeltype_delete_controller(): array
$user = auth()->user();

if (!$request->has('user_angeltype_id')) {
error(__('User angeltype doesn\'t exist.'));
throw_redirect(url('/angeltypes'));
throw new HttpNotFound();
}

/** @var UserAngelType $user_angeltype */
Expand All @@ -237,7 +236,7 @@ function user_angeltype_delete_controller(): array
&& !$user->isAngelTypeSupporter($angeltype)
&& !auth()->can('admin_user_angeltypes')
) {
error(__('You are not allowed to delete this users angeltype.'));
error(__('You are not allowed to delete this users angel type.'));
throw_redirect(url('/angeltypes'));
}

Expand All @@ -251,7 +250,7 @@ function user_angeltype_delete_controller(): array
}

return [
__('Leave angeltype'),
__('Leave angel type'),
UserAngelType_delete_view($user_angeltype, $user_source, $angeltype, $isOwnAngelType),
];
}
Expand All @@ -266,14 +265,11 @@ function user_angeltype_update_controller(): array
$supporter = false;
$request = request();

if (!auth()->can('admin_angel_types') && !config('supporters_can_promote')) {
error(__('You are not allowed to set supporter rights.'));
throw_redirect(url('/angeltypes'));
}

if (!$request->has('user_angeltype_id')) {
error(__('User angeltype doesn\'t exist.'));
throw_redirect(url('/angeltypes'));
throw new HttpNotFound();
}
if (!auth()->can('admin_angel_types') && !config('supporters_can_promote')) {
throw new HttpForbidden();
}

if ($request->has('supporter') && preg_match('/^[01]$/', $request->input('supporter'))) {
Expand Down Expand Up @@ -389,7 +385,7 @@ function user_angeltype_add_controller(): array
}

return [
__('Add user to angeltype'),
__('Add user to angel type'),
UserAngelType_add_view($angeltype, $users_select, $user_source->id),
];
}
Expand Down
2 changes: 1 addition & 1 deletion includes/helper/legacy_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ function dateWithEventDay(string $day): string
$dayOfEvent = DayOfEvent::get($date);
$dateFormatted = $date->format(__('general.date'));

if (!config('enable_show_day_of_event') || is_null($dayOfEvent)) {
if (is_null($dayOfEvent)) {
return $dateFormatted;
}

Expand Down
2 changes: 1 addition & 1 deletion includes/pages/admin_active.php
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,7 @@ function admin_active()
$parameters['show_all_shifts'] = 1;
}
$actions[] = form(
[form_submit('submit', icon('plus-lg') . __('set active'), 'btn-sm', false, 'secondary')],
[form_submit('submit', icon('plus-lg') . __('Set active'), 'btn-sm', false, 'secondary')],
url('/admin-active', $parameters),
false,
true
Expand Down
2 changes: 1 addition & 1 deletion includes/pages/admin_arrive.php
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,7 @@ function admin_arrive()
table(array_merge(
['name' => __('general.name'),],
($admin_arrive ? ['rendered_planned_arrival_date' => __('Planned arrival')] : []),
['arrived' => __('Arrived?')],
['arrived' => __('Arrived')],
($admin_arrive ? [
'rendered_arrival_date' => __('Arrival date'),
'rendered_planned_departure_date' => __('Planned departure'),
Expand Down
2 changes: 1 addition & 1 deletion includes/pages/admin_free.php
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ function admin_free()
div('col-md-12 form-inline', [
div('row', [
form_text('search', __('form.search'), $search, null, null, null, 'col'),
form_select('angeltype', __('Angeltype'), $angel_types, $angelType, '', 'col'),
form_select('angeltype', __('Angel type'), $angel_types, $angelType, '', 'col'),
form_submit('submit', icon('search') . __('form.search')),
]),
]),
Expand Down
6 changes: 3 additions & 3 deletions includes/pages/admin_shifts.php
Original file line number Diff line number Diff line change
Expand Up @@ -339,9 +339,9 @@ function admin_shifts()
$shifts_table_entry = [
'timeslot' =>
icon('clock-history') . ' '
. $start->format(__('general.datetime'))
. dateWithEventDay($start->format('Y-m-d')) . ' ' . $start->format(__('H:i'))
. ' - '
. '<span title="' . $end->format(__('general.date')) . '">'
. '<span title="' . dateWithEventDay($end->format('Y-m-d')) . '">'
. $end->format(__('H:i'))
. '</span>'
. ', ' . round($end->copy()->diffInMinutes($start) / 60, 2) . 'h'
Expand Down Expand Up @@ -511,7 +511,7 @@ function admin_shifts()
form([
div('row', [
div('col-md-6 col-xl-5', [
form_select('shifttype_id', __('Shifttype'), $shifttypes, $shifttype_id),
form_select('shifttype_id', __('Shift type'), $shifttypes, $shifttype_id),
form_text('title', __('title.title'), $title, false, 255),
form_select('lid', __('Location'), $location_array, $lid),
]),
Expand Down
4 changes: 2 additions & 2 deletions includes/pages/user_shifts.php
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ function load_types()
$isShico = auth()->can('admin_shifts');

if (!AngelType::count()) {
error(__('The administration has not configured any angeltypes yet - or you are not subscribed to any angeltype.'));
error(__('The administration has not configured any angel types yet - or you are not subscribed to any angel type.'));
throw_redirect(url('/'));
}

Expand Down Expand Up @@ -326,7 +326,7 @@ function view_user_shifts()
'types',
icon('person-lines-fill') . __('angeltypes.angeltypes')
. ' <small><span class="bi bi-info-circle-fill text-info" data-bs-toggle="tooltip" title="'
. __('The tasks shown here are influenced by the angeltypes you joined already!')
. __('The tasks shown here are influenced by the angel types you joined already!')
. '"></span></small>',
$ownAngelTypes
),
Expand Down
Loading