Settings Modernization: Refactoring
Settings Modernization: Fixing Date issue Settings Modernization: Reroute Settings Modernization: Reroute settings to /settings/profile, Cleanup and Refactoring
This commit is contained in:
parent
d6899d37d9
commit
63f1c12429
|
@ -74,7 +74,6 @@ $includeFiles = [
|
||||||
__DIR__ . '/../includes/pages/admin_user.php',
|
__DIR__ . '/../includes/pages/admin_user.php',
|
||||||
__DIR__ . '/../includes/pages/guest_login.php',
|
__DIR__ . '/../includes/pages/guest_login.php',
|
||||||
__DIR__ . '/../includes/pages/user_myshifts.php',
|
__DIR__ . '/../includes/pages/user_myshifts.php',
|
||||||
__DIR__ . '/../includes/pages/user_settings.php',
|
|
||||||
__DIR__ . '/../includes/pages/user_shifts.php',
|
__DIR__ . '/../includes/pages/user_shifts.php',
|
||||||
|
|
||||||
__DIR__ . '/../includes/pages/schedule/ImportSchedule.php',
|
__DIR__ . '/../includes/pages/schedule/ImportSchedule.php',
|
||||||
|
|
|
@ -1,149 +0,0 @@
|
||||||
<?php
|
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Engelsystem\Models\User\User;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function settings_title()
|
|
||||||
{
|
|
||||||
return __('Settings');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Change user main attributes (name, dates, etc.)
|
|
||||||
*
|
|
||||||
* @param User $user_source The user
|
|
||||||
* @param bool $enable_tshirt_size
|
|
||||||
* @param array $tshirt_sizes
|
|
||||||
* @return User
|
|
||||||
*/
|
|
||||||
function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes)
|
|
||||||
{
|
|
||||||
$valid = true;
|
|
||||||
$request = request();
|
|
||||||
|
|
||||||
if ($request->has('mail')) {
|
|
||||||
$result = User_validate_mail($request->input('mail'));
|
|
||||||
$user_source->email = $result->getValue();
|
|
||||||
if (!$result->isValid()) {
|
|
||||||
$valid = false;
|
|
||||||
error(__('E-mail address is not correct.'));
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
$valid = false;
|
|
||||||
error(__('Please enter your e-mail.'));
|
|
||||||
}
|
|
||||||
|
|
||||||
$user_source->settings->email_shiftinfo = $request->has('email_shiftinfo');
|
|
||||||
$user_source->settings->email_human = $request->has('email_by_human_allowed');
|
|
||||||
$user_source->settings->email_news = $request->has('email_news');
|
|
||||||
if (config('enable_goody')) {
|
|
||||||
$user_source->settings->email_goody = $request->has('email_goody');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($request->has('tshirt_size') && isset($tshirt_sizes[$request->input('tshirt_size')])) {
|
|
||||||
$user_source->personalData->shirt_size = $request->input('tshirt_size');
|
|
||||||
} elseif ($enable_tshirt_size) {
|
|
||||||
$valid = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($request->has('planned_arrival_date') && $request->input('planned_arrival_date')) {
|
|
||||||
$tmp = parse_date('Y-m-d H:i', $request->input('planned_arrival_date') . ' 00:00');
|
|
||||||
$result = User_validate_planned_arrival_date($tmp);
|
|
||||||
$user_source->personalData->planned_arrival_date = Carbon::createFromTimestamp($result->getValue());
|
|
||||||
if (!$result->isValid()) {
|
|
||||||
$valid = false;
|
|
||||||
error(__('Please enter your planned date of arrival. It should be after the buildup start date and before teardown end date.'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($request->has('planned_departure_date') && $request->input('planned_departure_date')) {
|
|
||||||
$tmp = parse_date('Y-m-d H:i', $request->input('planned_departure_date') . ' 00:00');
|
|
||||||
$plannedArrivalDate = $user_source->personalData->planned_arrival_date;
|
|
||||||
$result = User_validate_planned_departure_date(
|
|
||||||
$plannedArrivalDate ? $plannedArrivalDate->getTimestamp() : 0,
|
|
||||||
$tmp
|
|
||||||
);
|
|
||||||
$user_source->personalData->planned_departure_date = Carbon::createFromTimestamp($result->getValue());
|
|
||||||
if (!$result->isValid()) {
|
|
||||||
$valid = false;
|
|
||||||
error(__('Please enter your planned date of departure. It should be after your planned arrival date and after buildup start date and before teardown end date.'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Trivia
|
|
||||||
$pronoun = strip_request_item('pronoun', $user_source->personalData->pronoun);
|
|
||||||
if (config('enable_pronoun') && mb_strlen($pronoun) <= 15) {
|
|
||||||
$user_source->personalData->pronoun = $pronoun;
|
|
||||||
}
|
|
||||||
if (config('enable_user_name')) {
|
|
||||||
$user_source->personalData->last_name = strip_request_item('lastname', $user_source->personalData->last_name);
|
|
||||||
$user_source->personalData->first_name = strip_request_item('prename', $user_source->personalData->first_name);
|
|
||||||
}
|
|
||||||
if (config('enable_dect')) {
|
|
||||||
if (strlen(strip_request_item('dect')) <= 40) {
|
|
||||||
$user_source->contact->dect = strip_request_item('dect', $user_source->contact->dect);
|
|
||||||
} else {
|
|
||||||
$valid = false;
|
|
||||||
error(__('For dect numbers are only 40 digits allowed.'));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
$user_source->contact->mobile = strip_request_item('mobile', $user_source->contact->mobile);
|
|
||||||
if (config('enable_mobile_show')) {
|
|
||||||
$user_source->settings->mobile_show = $request->has('mobile_show');
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($valid) {
|
|
||||||
$user_source->save();
|
|
||||||
$user_source->contact->save();
|
|
||||||
$user_source->personalData->save();
|
|
||||||
$user_source->settings->save();
|
|
||||||
|
|
||||||
success(__('Settings saved.'));
|
|
||||||
throw_redirect(page_link_to('user_settings'));
|
|
||||||
}
|
|
||||||
|
|
||||||
return $user_source;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Main user settings page/controller
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function user_settings()
|
|
||||||
{
|
|
||||||
$request = request();
|
|
||||||
$config = config();
|
|
||||||
|
|
||||||
$enable_tshirt_size = config('enable_tshirt_size');
|
|
||||||
$tshirt_sizes = config('tshirt_sizes');
|
|
||||||
|
|
||||||
$buildup_start_date = null;
|
|
||||||
$teardown_end_date = null;
|
|
||||||
|
|
||||||
if ($buildup = $config->get('buildup_start')) {
|
|
||||||
/** @var Carbon $buildup */
|
|
||||||
$buildup_start_date = $buildup->getTimestamp();
|
|
||||||
}
|
|
||||||
|
|
||||||
if ($teardown = $config->get('teardown_end')) {
|
|
||||||
/** @var Carbon $teardown */
|
|
||||||
$teardown_end_date = $teardown->getTimestamp();
|
|
||||||
}
|
|
||||||
|
|
||||||
$user_source = auth()->user();
|
|
||||||
if ($request->hasPostData('submit')) {
|
|
||||||
$user_source = user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes);
|
|
||||||
}
|
|
||||||
|
|
||||||
return User_settings_view(
|
|
||||||
$user_source,
|
|
||||||
$buildup_start_date,
|
|
||||||
$teardown_end_date,
|
|
||||||
$enable_tshirt_size,
|
|
||||||
$tshirt_sizes
|
|
||||||
);
|
|
||||||
}
|
|
|
@ -65,9 +65,9 @@ function make_user_submenu()
|
||||||
|
|
||||||
if (auth()->can('user_settings')) {
|
if (auth()->can('user_settings')) {
|
||||||
$user_submenu[] = toolbar_dropdown_item(
|
$user_submenu[] = toolbar_dropdown_item(
|
||||||
page_link_to('user_settings'),
|
page_link_to('settings/profile'),
|
||||||
__('Settings'),
|
__('Settings'),
|
||||||
$page == 'user_settings',
|
$page == 'settings/profile',
|
||||||
'gear'
|
'gear'
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,139 +1,11 @@
|
||||||
<?php
|
<?php
|
||||||
|
|
||||||
use Carbon\Carbon;
|
use Carbon\Carbon;
|
||||||
use Engelsystem\Http\UrlGeneratorInterface;
|
|
||||||
use Engelsystem\Models\Room;
|
use Engelsystem\Models\Room;
|
||||||
use Engelsystem\Models\User\User;
|
use Engelsystem\Models\User\User;
|
||||||
use Engelsystem\Models\Worklog;
|
use Engelsystem\Models\Worklog;
|
||||||
use Engelsystem\Renderer\Renderer;
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
use Illuminate\Support\Str;
|
use Illuminate\Support\Str;
|
||||||
use Engelsystem\Controllers\SettingsController;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Renders user settings page
|
|
||||||
*
|
|
||||||
* @param User $user_source The user
|
|
||||||
* @param int $buildup_start_date Unix timestamp
|
|
||||||
* @param int $teardown_end_date Unix timestamp
|
|
||||||
* @param bool $enable_tshirt_size
|
|
||||||
* @param array $tshirt_sizes
|
|
||||||
*
|
|
||||||
* @return string
|
|
||||||
*/
|
|
||||||
function User_settings_view(
|
|
||||||
$user_source,
|
|
||||||
$buildup_start_date,
|
|
||||||
$teardown_end_date,
|
|
||||||
$enable_tshirt_size,
|
|
||||||
$tshirt_sizes
|
|
||||||
) {
|
|
||||||
$personalData = $user_source->personalData;
|
|
||||||
$enable_user_name = config('enable_user_name');
|
|
||||||
$enable_pronoun = config('enable_pronoun');
|
|
||||||
$enable_dect = config('enable_dect');
|
|
||||||
$enable_planned_arrival = config('enable_planned_arrival');
|
|
||||||
$enable_goody = config('enable_goody');
|
|
||||||
$enable_mobile_show = config('enable_mobile_show');
|
|
||||||
|
|
||||||
/** @var $urlGenerator UrlGeneratorInterface */
|
|
||||||
$urlGenerator = app(UrlGeneratorInterface::class);
|
|
||||||
/** @var Renderer $renderer */
|
|
||||||
$renderer = app(Renderer::class);
|
|
||||||
return $renderer->render(
|
|
||||||
'pages/settings/settings.twig',
|
|
||||||
[
|
|
||||||
'title' => 'settings.profile',
|
|
||||||
'settings_menu' => app()->make(SettingsController::class)->settingsMenu(),
|
|
||||||
'content' =>
|
|
||||||
msg()
|
|
||||||
. div('row', [
|
|
||||||
div('col-md-9', [
|
|
||||||
form([
|
|
||||||
form_info('', __('Here you can change your user details.')),
|
|
||||||
form_info(entry_required() . ' = ' . __('Entry required!')),
|
|
||||||
form_text('nick', __('Nick'), $user_source->name, true),
|
|
||||||
$enable_pronoun
|
|
||||||
? form_text('pronoun', __('Pronoun'), $personalData->pronoun, false, 15)
|
|
||||||
. form_info('', __('Will be shown on your profile page and in angel lists.'))
|
|
||||||
: '',
|
|
||||||
$enable_user_name
|
|
||||||
? form_text('lastname', __('Last name'), $personalData->last_name, false, 64)
|
|
||||||
: '',
|
|
||||||
$enable_user_name
|
|
||||||
? form_text('prename', __('First name'), $personalData->first_name, false, 64)
|
|
||||||
: '',
|
|
||||||
$enable_planned_arrival ? form_date(
|
|
||||||
'planned_arrival_date',
|
|
||||||
__('Planned date of arrival') . ' ' . entry_required(),
|
|
||||||
$personalData->planned_arrival_date
|
|
||||||
? $personalData->planned_arrival_date->getTimestamp()
|
|
||||||
: '',
|
|
||||||
$buildup_start_date,
|
|
||||||
$teardown_end_date
|
|
||||||
) : '',
|
|
||||||
$enable_planned_arrival ? form_date(
|
|
||||||
'planned_departure_date',
|
|
||||||
__('Planned date of departure'),
|
|
||||||
$personalData->planned_departure_date
|
|
||||||
? $personalData->planned_departure_date->getTimestamp()
|
|
||||||
: '',
|
|
||||||
$buildup_start_date,
|
|
||||||
$teardown_end_date
|
|
||||||
) : '',
|
|
||||||
$enable_dect ? form_text('dect', __('DECT'), $user_source->contact->dect, false, 40) : '',
|
|
||||||
form_text('mobile', __('Mobile'), $user_source->contact->mobile, false, 40),
|
|
||||||
$enable_mobile_show ? form_checkbox(
|
|
||||||
'mobile_show',
|
|
||||||
__('Show mobile number to other users to contact me'),
|
|
||||||
$user_source->settings->mobile_show
|
|
||||||
) : '',
|
|
||||||
form_text('mail', __('E-Mail') . ' ' . entry_required(), $user_source->email, false, 254),
|
|
||||||
form_checkbox(
|
|
||||||
'email_shiftinfo',
|
|
||||||
__(
|
|
||||||
'The %s is allowed to send me an email (e.g. when my shifts change)',
|
|
||||||
[config('app_name')]
|
|
||||||
),
|
|
||||||
$user_source->settings->email_shiftinfo
|
|
||||||
),
|
|
||||||
form_checkbox(
|
|
||||||
'email_news',
|
|
||||||
__('Notify me of new news'),
|
|
||||||
$user_source->settings->email_news
|
|
||||||
),
|
|
||||||
form_checkbox(
|
|
||||||
'email_by_human_allowed',
|
|
||||||
__('Allow heaven angels to contact you by e-mail.'),
|
|
||||||
$user_source->settings->email_human
|
|
||||||
),
|
|
||||||
$enable_goody ? form_checkbox(
|
|
||||||
'email_goody',
|
|
||||||
__('To receive vouchers, give consent that nick, email address, worked hours and shirt size will be stored until the next similar event.')
|
|
||||||
. (config('privacy_email') ? ' ' . __('To withdraw your approval, send an email to <a href="mailto:%s">%1$s</a>.', [config('privacy_email')]) : ''),
|
|
||||||
$user_source->settings->email_goody
|
|
||||||
) : '',
|
|
||||||
$enable_tshirt_size ? form_select(
|
|
||||||
'tshirt_size',
|
|
||||||
__('Shirt size'),
|
|
||||||
$tshirt_sizes,
|
|
||||||
$personalData->shirt_size,
|
|
||||||
__('Please select...')
|
|
||||||
) : '',
|
|
||||||
form_info(
|
|
||||||
'',
|
|
||||||
__(
|
|
||||||
'You can manage your Angeltypes <a href="%s">on the Angeltypes page</a>.',
|
|
||||||
[$urlGenerator->to('angeltypes')]
|
|
||||||
)
|
|
||||||
),
|
|
||||||
form_submit('submit', __('Save'))
|
|
||||||
]),
|
|
||||||
])
|
|
||||||
])
|
|
||||||
]
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gui for deleting user with password field.
|
* Gui for deleting user with password field.
|
||||||
|
@ -363,7 +235,7 @@ function User_view_shiftentries($needed_angel_type)
|
||||||
{
|
{
|
||||||
$shift_info = '<br><a href="'
|
$shift_info = '<br><a href="'
|
||||||
. page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $needed_angel_type['id']])
|
. page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $needed_angel_type['id']])
|
||||||
. '"><b>' . $needed_angel_type['name'] . '</a>:</b> ';
|
.'"><b>' . $needed_angel_type['name'] . '</a>:</b> ';
|
||||||
|
|
||||||
$shift_entries = [];
|
$shift_entries = [];
|
||||||
foreach ($needed_angel_type['users'] as $user_shift) {
|
foreach ($needed_angel_type['users'] as $user_shift) {
|
||||||
|
@ -585,8 +457,8 @@ function User_view(
|
||||||
$auth = auth();
|
$auth = auth();
|
||||||
$nightShiftsConfig = config('night_shifts');
|
$nightShiftsConfig = config('night_shifts');
|
||||||
$user_name = htmlspecialchars(
|
$user_name = htmlspecialchars(
|
||||||
$user_source->personalData->first_name
|
$user_source->personalData->first_name) . ' ' . htmlspecialchars($user_source->personalData->last_name
|
||||||
) . ' ' . htmlspecialchars($user_source->personalData->last_name);
|
);
|
||||||
$myshifts_table = '';
|
$myshifts_table = '';
|
||||||
if ($its_me || $admin_user_privilege) {
|
if ($its_me || $admin_user_privilege) {
|
||||||
$my_shifts = User_view_myshifts(
|
$my_shifts = User_view_myshifts(
|
||||||
|
@ -658,7 +530,7 @@ function User_view(
|
||||||
icon('list') . __('Add work log')
|
icon('list') . __('Add work log')
|
||||||
) : '',
|
) : '',
|
||||||
$its_me ? button(
|
$its_me ? button(
|
||||||
page_link_to('user_settings'),
|
page_link_to('settings/profile'),
|
||||||
icon('gear') . __('Settings')
|
icon('gear') . __('Settings')
|
||||||
) : '',
|
) : '',
|
||||||
($its_me && $auth->can('ical')) ? button(
|
($its_me && $auth->can('ical')) ? button(
|
||||||
|
@ -682,7 +554,7 @@ function User_view(
|
||||||
]),
|
]),
|
||||||
div('row user-info', [
|
div('row user-info', [
|
||||||
div('col-md-2', [
|
div('col-md-2', [
|
||||||
config('enable_dect') && $user_source->contact->dect ?
|
config('enable_dect') ?
|
||||||
heading(
|
heading(
|
||||||
icon('phone')
|
icon('phone')
|
||||||
. ' <a href="tel:' . $user_source->contact->dect . '">'
|
. ' <a href="tel:' . $user_source->contact->dect . '">'
|
||||||
|
@ -690,16 +562,6 @@ function User_view(
|
||||||
. '</a>'
|
. '</a>'
|
||||||
)
|
)
|
||||||
: '' ,
|
: '' ,
|
||||||
config('enable_mobile_show') && $user_source->contact->mobile ?
|
|
||||||
$user_source->settings->mobile_show ?
|
|
||||||
heading(
|
|
||||||
icon('phone')
|
|
||||||
. ' <a href="tel:' . $user_source->contact->mobile . '">'
|
|
||||||
. $user_source->contact->mobile
|
|
||||||
. '</a>'
|
|
||||||
)
|
|
||||||
: ''
|
|
||||||
: '' ,
|
|
||||||
$auth->can('user_messages') ?
|
$auth->can('user_messages') ?
|
||||||
heading(
|
heading(
|
||||||
'<a href="' . page_link_to('/messages/' . $user_source->id) . '">'
|
'<a href="' . page_link_to('/messages/' . $user_source->id) . '">'
|
||||||
|
@ -725,9 +587,9 @@ function User_view(
|
||||||
) : '',
|
) : '',
|
||||||
$its_me && count($shifts) == 0
|
$its_me && count($shifts) == 0
|
||||||
? error(sprintf(
|
? error(sprintf(
|
||||||
__('Go to the <a href="%s">shifts table</a> to sign yourself up for some shifts.'),
|
__('Go to the <a href="%s">shifts table</a> to sign yourself up for some shifts.'),
|
||||||
page_link_to('user_shifts')
|
page_link_to('user_shifts')
|
||||||
), true)
|
), true)
|
||||||
: '',
|
: '',
|
||||||
$its_me ? ical_hint() : ''
|
$its_me ? ical_hint() : ''
|
||||||
]
|
]
|
||||||
|
@ -952,7 +814,7 @@ function User_Pronoun_render(User $user): string
|
||||||
*/
|
*/
|
||||||
function render_profile_link($text, $user_id = null, $class = '')
|
function render_profile_link($text, $user_id = null, $class = '')
|
||||||
{
|
{
|
||||||
$profile_link = page_link_to('user-settings');
|
$profile_link = page_link_to('settings/profile');
|
||||||
if (!is_null($user_id)) {
|
if (!is_null($user_id)) {
|
||||||
$profile_link = page_link_to('users', ['action' => 'view', 'user_id' => $user_id]);
|
$profile_link = page_link_to('users', ['action' => 'view', 'user_id' => $user_id]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -245,7 +245,6 @@ msgstr ""
|
||||||
"Wir haben dir eine eMail mit einem Link zum Passwort-zurücksetzen geschickt."
|
"Wir haben dir eine eMail mit einem Link zum Passwort-zurücksetzen geschickt."
|
||||||
|
|
||||||
#: resources/views/pages/password/reset-success.twig:9
|
#: resources/views/pages/password/reset-success.twig:9
|
||||||
#: includes/pages/user_settings.php:120
|
|
||||||
msgid "Password saved."
|
msgid "Password saved."
|
||||||
msgstr "Passwort gespeichert."
|
msgstr "Passwort gespeichert."
|
||||||
|
|
||||||
|
@ -388,7 +387,6 @@ msgid "The buildup start date has to be before the teardown end date."
|
||||||
msgstr "Das Aufbau Start Datum muss vor dem Abbau Ende Datum liegen."
|
msgstr "Das Aufbau Start Datum muss vor dem Abbau Ende Datum liegen."
|
||||||
|
|
||||||
#: includes/controller/event_config_controller.php:120
|
#: includes/controller/event_config_controller.php:120
|
||||||
#: includes/pages/user_settings.php:93
|
|
||||||
msgid "Settings saved."
|
msgid "Settings saved."
|
||||||
msgstr "Einstellungen gespeichert."
|
msgstr "Einstellungen gespeichert."
|
||||||
|
|
||||||
|
@ -1586,7 +1584,7 @@ msgstr "Der Nick "%s" existiert schon."
|
||||||
msgid "Please enter a nickname."
|
msgid "Please enter a nickname."
|
||||||
msgstr "Gib bitte einen Nick an."
|
msgstr "Gib bitte einen Nick an."
|
||||||
|
|
||||||
#: includes/pages/guest_login.php:93 includes/pages/user_settings.php:32
|
#: includes/pages/guest_login.php:93
|
||||||
msgid "E-mail address is not correct."
|
msgid "E-mail address is not correct."
|
||||||
msgstr "Die E-Mail Adresse ist nicht in Ordnung."
|
msgstr "Die E-Mail Adresse ist nicht in Ordnung."
|
||||||
|
|
||||||
|
@ -1594,7 +1592,7 @@ msgstr "Die E-Mail Adresse ist nicht in Ordnung."
|
||||||
msgid "E-mail address is already used by another user."
|
msgid "E-mail address is already used by another user."
|
||||||
msgstr "Die E-Mail Adresse wurde bereits von einem anderen User benutzt."
|
msgstr "Die E-Mail Adresse wurde bereits von einem anderen User benutzt."
|
||||||
|
|
||||||
#: includes/pages/guest_login.php:101 includes/pages/user_settings.php:36
|
#: includes/pages/guest_login.php:101
|
||||||
msgid "Please enter your e-mail."
|
msgid "Please enter your e-mail."
|
||||||
msgstr "Bitte gib Deine E-Mail-Adresse ein."
|
msgstr "Bitte gib Deine E-Mail-Adresse ein."
|
||||||
|
|
||||||
|
@ -1608,7 +1606,6 @@ msgid "Your password is too short (please use at least %s characters)."
|
||||||
msgstr "Dein Passwort ist zu kurz (Bitte mindestens %s Zeichen nutzen)."
|
msgstr "Dein Passwort ist zu kurz (Bitte mindestens %s Zeichen nutzen)."
|
||||||
|
|
||||||
#: includes/pages/guest_login.php:140 includes/pages/guest_login.php:144
|
#: includes/pages/guest_login.php:140 includes/pages/guest_login.php:144
|
||||||
#: includes/pages/user_settings.php:54
|
|
||||||
msgid ""
|
msgid ""
|
||||||
"Please enter your planned date of arrival. It should be after the buildup "
|
"Please enter your planned date of arrival. It should be after the buildup "
|
||||||
"start date and before teardown end date."
|
"start date and before teardown end date."
|
||||||
|
@ -1616,7 +1613,7 @@ msgstr ""
|
||||||
"Bitte gib Dein geplantes Ankunftsdatum an. Es sollte nach dem Aufbaubeginn "
|
"Bitte gib Dein geplantes Ankunftsdatum an. Es sollte nach dem Aufbaubeginn "
|
||||||
"und vor dem Abbauende liegen."
|
"und vor dem Abbauende liegen."
|
||||||
|
|
||||||
#: includes/pages/guest_login.php:166 includes/pages/user_settings.php:82
|
#: includes/pages/guest_login.php:166
|
||||||
msgid "For dect numbers are only 40 digits allowed."
|
msgid "For dect numbers are only 40 digits allowed."
|
||||||
msgstr "Die DECT Nummer darf nur 40 Zeichen lang sein."
|
msgstr "Die DECT Nummer darf nur 40 Zeichen lang sein."
|
||||||
|
|
||||||
|
@ -1809,12 +1806,11 @@ msgstr "Unvollständiger Aufruf, fehlende Fragen ID."
|
||||||
msgid "No question found."
|
msgid "No question found."
|
||||||
msgstr "Keine Frage gefunden."
|
msgstr "Keine Frage gefunden."
|
||||||
|
|
||||||
#: includes/pages/user_settings.php:11 includes/sys_menu.php:69
|
#: includes/sys_menu.php:69
|
||||||
#: includes/view/User_view.php:616
|
#: includes/view/User_view.php:616
|
||||||
msgid "Settings"
|
msgid "Settings"
|
||||||
msgstr "Einstellungen"
|
msgstr "Einstellungen"
|
||||||
|
|
||||||
#: includes/pages/user_settings.php:68
|
|
||||||
msgid ""
|
msgid ""
|
||||||
"Please enter your planned date of departure. It should be after your planned "
|
"Please enter your planned date of departure. It should be after your planned "
|
||||||
"arrival date and after buildup start date and before teardown end date."
|
"arrival date and after buildup start date and before teardown end date."
|
||||||
|
@ -1822,11 +1818,9 @@ msgstr ""
|
||||||
"Bitte gibt dein geplantes Abreisedatum an. Es sollte nach Deinem "
|
"Bitte gibt dein geplantes Abreisedatum an. Es sollte nach Deinem "
|
||||||
"Anreisedatum, nach dem Aufbaubeginn und vor dem Abbauende liegen."
|
"Anreisedatum, nach dem Aufbaubeginn und vor dem Abbauende liegen."
|
||||||
|
|
||||||
#: includes/pages/user_settings.php:113
|
|
||||||
msgid "-> not OK. Please try again."
|
msgid "-> not OK. Please try again."
|
||||||
msgstr "-> Nicht OK. Bitte erneut versuchen."
|
msgstr "-> Nicht OK. Bitte erneut versuchen."
|
||||||
|
|
||||||
#: includes/pages/user_settings.php:115
|
|
||||||
msgid "Your password is to short (please use at least 6 characters)."
|
msgid "Your password is to short (please use at least 6 characters)."
|
||||||
msgstr "Dein Passwort ist zu kurz (Bitte mindestens 6 Zeichen nutzen)."
|
msgstr "Dein Passwort ist zu kurz (Bitte mindestens 6 Zeichen nutzen)."
|
||||||
|
|
||||||
|
|
|
@ -139,7 +139,6 @@ msgid "The buildup start date has to be before the teardown end date."
|
||||||
msgstr "A data de montagem deve ser anterior a data de desmontagem do evento."
|
msgstr "A data de montagem deve ser anterior a data de desmontagem do evento."
|
||||||
|
|
||||||
#: includes/controller/event_config_controller.php:92
|
#: includes/controller/event_config_controller.php:92
|
||||||
#: includes/pages/user_settings.php:77
|
|
||||||
msgid "Settings saved."
|
msgid "Settings saved."
|
||||||
msgstr "Configurações salvas."
|
msgstr "Configurações salvas."
|
||||||
|
|
||||||
|
@ -515,28 +514,26 @@ msgid "Token is not correct."
|
||||||
msgstr "O token não está correto."
|
msgstr "O token não está correto."
|
||||||
|
|
||||||
#: includes/controller/users_controller.php:227
|
#: includes/controller/users_controller.php:227
|
||||||
#: includes/pages/guest_login.php:102 includes/pages/user_settings.php:97
|
#: includes/pages/guest_login.php:102
|
||||||
msgid "Your passwords don't match."
|
msgid "Your passwords don't match."
|
||||||
msgstr "Suas senhas não correspondem."
|
msgstr "Suas senhas não correspondem."
|
||||||
|
|
||||||
#: includes/controller/users_controller.php:231
|
#: includes/controller/users_controller.php:231
|
||||||
#: includes/pages/user_settings.php:95
|
|
||||||
msgid "Your password is to short (please use at least 6 characters)."
|
msgid "Your password is to short (please use at least 6 characters)."
|
||||||
msgstr "Sua senha é muito curta (por favor use no mínimo 6 caracteres)."
|
msgstr "Sua senha é muito curta (por favor use no mínimo 6 caracteres)."
|
||||||
|
|
||||||
#: includes/controller/users_controller.php:236
|
#: includes/controller/users_controller.php:236
|
||||||
#: includes/pages/user_settings.php:99
|
|
||||||
msgid "Password saved."
|
msgid "Password saved."
|
||||||
msgstr "Sua senha foi salva."
|
msgstr "Sua senha foi salva."
|
||||||
|
|
||||||
#: includes/controller/users_controller.php:257
|
#: includes/controller/users_controller.php:257
|
||||||
#: includes/controller/users_controller.php:261
|
#: includes/controller/users_controller.php:261
|
||||||
#: includes/pages/guest_login.php:67 includes/pages/user_settings.php:21
|
#: includes/pages/guest_login.php:67
|
||||||
msgid "E-mail address is not correct."
|
msgid "E-mail address is not correct."
|
||||||
msgstr "E-mail não está correto."
|
msgstr "E-mail não está correto."
|
||||||
|
|
||||||
#: includes/controller/users_controller.php:265
|
#: includes/controller/users_controller.php:265
|
||||||
#: includes/pages/guest_login.php:71 includes/pages/user_settings.php:25
|
#: includes/pages/guest_login.php:71
|
||||||
msgid "Please enter your e-mail."
|
msgid "Please enter your e-mail."
|
||||||
msgstr "Por favor digite seu e-mail."
|
msgstr "Por favor digite seu e-mail."
|
||||||
|
|
||||||
|
@ -1307,7 +1304,7 @@ msgstr "Seu apelido "%s" já existe."
|
||||||
msgid "Your nick "%s" is too short (min. 2 characters)."
|
msgid "Your nick "%s" is too short (min. 2 characters)."
|
||||||
msgstr "Seu apelido "%s" é muito pequeno (mínimo 2 caracteres)."
|
msgstr "Seu apelido "%s" é muito pequeno (mínimo 2 caracteres)."
|
||||||
|
|
||||||
#: includes/pages/guest_login.php:86 includes/pages/user_settings.php:36
|
#: includes/pages/guest_login.php:86
|
||||||
msgid "Please check your jabber account information."
|
msgid "Please check your jabber account information."
|
||||||
msgstr "Por favor verifique a informação da sua conta jabber."
|
msgstr "Por favor verifique a informação da sua conta jabber."
|
||||||
|
|
||||||
|
@ -1320,7 +1317,7 @@ msgstr "Por favor escolha o tamanho da camisa."
|
||||||
msgid "Your password is too short (please use at least %s characters)."
|
msgid "Your password is too short (please use at least %s characters)."
|
||||||
msgstr "Sua senha é muito curta (por favor use pelo menos %s caracteres)."
|
msgstr "Sua senha é muito curta (por favor use pelo menos %s caracteres)."
|
||||||
|
|
||||||
#: includes/pages/guest_login.php:115 includes/pages/user_settings.php:52
|
#: includes/pages/guest_login.php:115
|
||||||
msgid ""
|
msgid ""
|
||||||
"Please enter your planned date of arrival. It should be after the buildup "
|
"Please enter your planned date of arrival. It should be after the buildup "
|
||||||
"start date and before teardown end date."
|
"start date and before teardown end date."
|
||||||
|
@ -1593,11 +1590,10 @@ msgstr "Chamada incompletada, falta o ID da pergunta."
|
||||||
msgid "No question found."
|
msgid "No question found."
|
||||||
msgstr "Nenhuma dúvida encontrada."
|
msgstr "Nenhuma dúvida encontrada."
|
||||||
|
|
||||||
#: includes/pages/user_settings.php:4 includes/view/User_view.php:332
|
#: includes/view/User_view.php:332
|
||||||
msgid "Settings"
|
msgid "Settings"
|
||||||
msgstr "Configurações"
|
msgstr "Configurações"
|
||||||
|
|
||||||
#: includes/pages/user_settings.php:62
|
|
||||||
msgid ""
|
msgid ""
|
||||||
"Please enter your planned date of departure. It should be after your planned "
|
"Please enter your planned date of departure. It should be after your planned "
|
||||||
"arrival date and after buildup start date and before teardown end date."
|
"arrival date and after buildup start date and before teardown end date."
|
||||||
|
@ -1606,11 +1602,9 @@ msgstr ""
|
||||||
"chegada\n"
|
"chegada\n"
|
||||||
"e ao início da montagem, e anterior à data de desmontagem."
|
"e ao início da montagem, e anterior à data de desmontagem."
|
||||||
|
|
||||||
#: includes/pages/user_settings.php:93
|
|
||||||
msgid "-> not OK. Please try again."
|
msgid "-> not OK. Please try again."
|
||||||
msgstr "-> não OK. Por favor tente novamente."
|
msgstr "-> não OK. Por favor tente novamente."
|
||||||
|
|
||||||
#: includes/pages/user_settings.php:101
|
|
||||||
msgid "Failed setting password."
|
msgid "Failed setting password."
|
||||||
msgstr "A alteração da senha falhaou."
|
msgstr "A alteração da senha falhaou."
|
||||||
|
|
||||||
|
|
|
@ -57,12 +57,13 @@
|
||||||
'max': config('teardown_end') ? config('teardown_end').format('Y-m-d') : '',
|
'max': config('teardown_end') ? config('teardown_end').format('Y-m-d') : '',
|
||||||
}
|
}
|
||||||
) }}
|
) }}
|
||||||
|
{% set planned_departure_date = user.personalData.planned_departure_date %}
|
||||||
{{ f.input(
|
{{ f.input(
|
||||||
'planned_departure_date',
|
'planned_departure_date',
|
||||||
__('settings.profile.planned_departure_date'),
|
__('settings.profile.planned_departure_date'),
|
||||||
'date',
|
'date',
|
||||||
{
|
{
|
||||||
'value': user.personalData.planned_departure_date.format('Y-m-d'),
|
'value': planned_departure_date ? planned_departure_date.format('Y-m-d') : '',
|
||||||
'min': config('buildup_start') ? config('buildup_start').format('Y-m-d') : '',
|
'min': config('buildup_start') ? config('buildup_start').format('Y-m-d') : '',
|
||||||
'max': config('teardown_end') ? config('teardown_end').format('Y-m-d') : '',
|
'max': config('teardown_end') ? config('teardown_end').format('Y-m-d') : '',
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,13 +9,14 @@ trait ChecksArrivalsAndDepartures
|
||||||
{
|
{
|
||||||
protected function isArrivalDateValid(?string $arrival, ?string $departure): bool
|
protected function isArrivalDateValid(?string $arrival, ?string $departure): bool
|
||||||
{
|
{
|
||||||
if (is_null($arrival)) {
|
$arrival_carbon = $this->toCarbon($arrival);
|
||||||
|
$departure_carbon = $this->toCarbon($departure);
|
||||||
|
|
||||||
|
if (is_null($arrival_carbon)) {
|
||||||
return false; // since required value
|
return false; // since required value
|
||||||
}
|
}
|
||||||
|
|
||||||
$arrival_carbon = $this->toCarbon($arrival);
|
if (!is_null($departure_carbon) && $arrival_carbon->greaterThan($departure_carbon)) {
|
||||||
|
|
||||||
if (!is_null($departure) && $arrival_carbon->greaterThan($this->toCarbon($departure))) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,29 +25,32 @@ trait ChecksArrivalsAndDepartures
|
||||||
|
|
||||||
protected function isDepartureDateValid(?string $arrival, ?string $departure): bool
|
protected function isDepartureDateValid(?string $arrival, ?string $departure): bool
|
||||||
{
|
{
|
||||||
if (is_null($departure)) {
|
$arrival_carbon = $this->toCarbon($arrival);
|
||||||
return true; // since optional value
|
|
||||||
}
|
|
||||||
$departure_carbon = $this->toCarbon($departure);
|
$departure_carbon = $this->toCarbon($departure);
|
||||||
|
|
||||||
return $departure_carbon->greaterThanOrEqualTo($this->toCarbon($arrival)) &&
|
if (is_null($departure_carbon)) {
|
||||||
|
return true; // since optional value
|
||||||
|
}
|
||||||
|
|
||||||
|
return $departure_carbon->greaterThanOrEqualTo($arrival_carbon) &&
|
||||||
!$this->isBeforeBuildup($departure_carbon) && !$this->isAfterTeardown($departure_carbon);
|
!$this->isBeforeBuildup($departure_carbon) && !$this->isAfterTeardown($departure_carbon);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function toCarbon(string $date_string): Carbon
|
private function toCarbon(?string $date_string): ?Carbon
|
||||||
{
|
{
|
||||||
return new Carbon(DateTime::createFromFormat('Y-m-d', $date_string));
|
$dateTime = DateTime::createFromFormat('Y-m-d', $date_string ?: '');
|
||||||
|
return $dateTime ? new Carbon($dateTime) : null;
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isBeforeBuildup(Carbon $date): bool
|
private function isBeforeBuildup(Carbon $date): bool
|
||||||
{
|
{
|
||||||
$buildup = config('buildup_start');
|
$buildup = config('buildup_start');
|
||||||
return !empty($buildup) && $date->lessThan($buildup->setTime(0,0));
|
return !empty($buildup) && $date->lessThan($buildup->setTime(0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isAfterTeardown(Carbon $date): bool
|
private function isAfterTeardown(Carbon $date): bool
|
||||||
{
|
{
|
||||||
$teardown = config('teardown_end');
|
$teardown = config('teardown_end');
|
||||||
return !empty($teardown) && $date->greaterThanOrEqualTo($teardown->addDay()->setTime(0,0));
|
return !empty($teardown) && $date->greaterThanOrEqualTo($teardown->addDay()->setTime(0, 0));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
namespace Engelsystem\Controllers;
|
namespace Engelsystem\Controllers;
|
||||||
|
|
||||||
use Carbon\Carbon;
|
|
||||||
use Engelsystem\Config\Config;
|
use Engelsystem\Config\Config;
|
||||||
use Engelsystem\Http\Exceptions\HttpNotFound;
|
use Engelsystem\Http\Exceptions\HttpNotFound;
|
||||||
use Engelsystem\Http\Response;
|
use Engelsystem\Http\Response;
|
||||||
|
@ -107,14 +106,12 @@ class SettingsController extends BaseController
|
||||||
if (!$this->isArrivalDateValid($data['planned_arrival_date'], $data['planned_departure_date'])) {
|
if (!$this->isArrivalDateValid($data['planned_arrival_date'], $data['planned_departure_date'])) {
|
||||||
$this->addNotification('settings.profile.planned_arrival_date.invalid', 'errors');
|
$this->addNotification('settings.profile.planned_arrival_date.invalid', 'errors');
|
||||||
return $this->redirect->to('/settings/profile');
|
return $this->redirect->to('/settings/profile');
|
||||||
|
} elseif (!$this->isDepartureDateValid($data['planned_arrival_date'], $data['planned_departure_date'])) {
|
||||||
} else if (!$this->isDepartureDateValid($data['planned_arrival_date'], $data['planned_departure_date'])) {
|
|
||||||
$this->addNotification('settings.profile.planned_departure_date.invalid', 'errors');
|
$this->addNotification('settings.profile.planned_departure_date.invalid', 'errors');
|
||||||
return $this->redirect->to('/settings/profile');
|
return $this->redirect->to('/settings/profile');
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
$user->personalData->planned_arrival_date = $data['planned_arrival_date'];
|
$user->personalData->planned_arrival_date = $data['planned_arrival_date'];
|
||||||
$user->personalData->planned_departure_date = $data['planned_departure_date'];
|
$user->personalData->planned_departure_date = $data['planned_departure_date'] ?: null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,12 +121,12 @@ class SettingsController extends BaseController
|
||||||
|
|
||||||
$user->contact->mobile = $data['mobile'];
|
$user->contact->mobile = $data['mobile'];
|
||||||
$user->email = $data['email'];
|
$user->email = $data['email'];
|
||||||
$user->settings->email_shiftinfo = $data['email_shiftinfo'];
|
$user->settings->email_shiftinfo = $data['email_shiftinfo'] ?: false;
|
||||||
$user->settings->email_news = $data['email_news'];
|
$user->settings->email_news = $data['email_news'] ?: false;
|
||||||
$user->settings->email_human = $data['email_human'];
|
$user->settings->email_human = $data['email_human'] ?: false;
|
||||||
|
|
||||||
if (config('enable_goody')) {
|
if (config('enable_goody')) {
|
||||||
$user->settings->email_goody = $data['email_goody'];
|
$user->settings->email_goody = $data['email_goody'] ?: false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isset(config('tshirt_sizes')[$data['shirt_size']])) {
|
if (isset(config('tshirt_sizes')[$data['shirt_size']])) {
|
||||||
|
@ -301,7 +298,7 @@ class SettingsController extends BaseController
|
||||||
public function settingsMenu(): array
|
public function settingsMenu(): array
|
||||||
{
|
{
|
||||||
$menu = [
|
$menu = [
|
||||||
url('/user-settings') => 'settings.profile',
|
url('/settings/profile') => 'settings.profile',
|
||||||
url('/settings/password') => 'settings.password',
|
url('/settings/password') => 'settings.password',
|
||||||
url('/settings/language') => 'settings.language',
|
url('/settings/language') => 'settings.language',
|
||||||
url('/settings/theme') => 'settings.theme'
|
url('/settings/theme') => 'settings.theme'
|
||||||
|
|
|
@ -141,10 +141,6 @@ class LegacyMiddleware implements MiddlewareInterface
|
||||||
return [$title, $content];
|
return [$title, $content];
|
||||||
case 'user_worklog':
|
case 'user_worklog':
|
||||||
return user_worklog_controller();
|
return user_worklog_controller();
|
||||||
case 'user_settings':
|
|
||||||
$title = settings_title();
|
|
||||||
$content = user_settings();
|
|
||||||
return [$title, $content];
|
|
||||||
case 'register':
|
case 'register':
|
||||||
$title = register_title();
|
$title = register_title();
|
||||||
$content = guest_register();
|
$content = guest_register();
|
||||||
|
|
|
@ -9,35 +9,57 @@ use Engelsystem\Test\Unit\TestCase;
|
||||||
|
|
||||||
class ChecksArrivalsAndDeparturesTest extends TestCase
|
class ChecksArrivalsAndDeparturesTest extends TestCase
|
||||||
{
|
{
|
||||||
public function invalidDateCombinations(): array
|
public function invalidArrivalCombinations(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[null, null, '2022-01-16', '2022-01-15'], # arrival greater than departure
|
[null, null, null, null], # arrival being null
|
||||||
['2022-01-15', '2022-01-15', '2022-01-14', '2022-01-16'], # arrival before buildup, departure after teardown
|
[null, null, '2022-01-16', '2022-01-15'], # arrival greater than departure
|
||||||
|
['2022-01-15', null, '2022-01-14', null], # arrival before buildup
|
||||||
|
[null, '2022-01-14', '2022-01-15', null], # arrival after teardown
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public function validDateCombinations(): array
|
public function invalidDepartureCombinations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[null, null, '2022-01-16', '2022-01-15'], # departure smaller than arrival
|
||||||
|
['2022-01-15', null, null, '2022-01-14'], # departure before buildup
|
||||||
|
[null, '2022-01-14', null, '2022-01-15'], # departure after teardown
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validArrivalCombinations(): array
|
||||||
{
|
{
|
||||||
return [
|
return [
|
||||||
[null, null, '2022-01-15', '2022-01-15'], # arrival equals departure
|
[null, null, '2022-01-15', '2022-01-15'], # arrival equals departure
|
||||||
[null, null, '2022-01-14', '2022-01-15'], # arrival smaller than departure
|
[null, null, '2022-01-14', '2022-01-15'], # arrival smaller than departure
|
||||||
['2022-01-14', null, '2022-01-14', '2022-01-15'], # arrival on buildup
|
['2022-01-14', null, '2022-01-14', '2022-01-15'], # arrival on buildup
|
||||||
['2022-01-13', null, '2022-01-14', '2022-01-15'], # arrival after buildup
|
['2022-01-13', null, '2022-01-14', '2022-01-15'], # arrival after buildup
|
||||||
|
];
|
||||||
|
}
|
||||||
|
|
||||||
|
public function validDepartureCombinations(): array
|
||||||
|
{
|
||||||
|
return [
|
||||||
|
[null, null, '2022-01-15', null], # departure being null
|
||||||
|
[null, null, '2022-01-15', '2022-01-15'], # departure equals arrival
|
||||||
|
[null, null, '2022-01-14', '2022-01-15'], # departure greater than arrival
|
||||||
[null, '2022-01-15', '2022-01-14', '2022-01-15'], # departure on teardown
|
[null, '2022-01-15', '2022-01-14', '2022-01-15'], # departure on teardown
|
||||||
[null, '2022-01-16', '2022-01-14', '2022-01-15'], # departure before teardown
|
[null, '2022-01-16', '2022-01-14', '2022-01-15'], # departure before teardown
|
||||||
['2022-01-14', '2022-01-16', '2022-01-14', '2022-01-15'], # all together
|
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::isArrivalDateValid
|
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::isArrivalDateValid
|
||||||
* @dataProvider invalidDateCombinations
|
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::toCarbon
|
||||||
|
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::isBeforeBuildup
|
||||||
|
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::isAfterTeardown
|
||||||
|
* @dataProvider invalidArrivalCombinations
|
||||||
*/
|
*/
|
||||||
public function testCheckInvalidDatesForArrival($buildup, $teardown, $arrival, $departure)
|
public function testCheckInvalidDatesForArrival($buildup, $teardown, $arrival, $departure)
|
||||||
{
|
{
|
||||||
config(['buildup_start' => is_null($buildup) ? null: new Carbon($buildup)]);
|
config(['buildup_start' => is_null($buildup) ? null : new Carbon($buildup)]);
|
||||||
config(['teardown_end' => is_null($teardown) ? null: new Carbon($teardown)]);
|
config(['teardown_end' => is_null($teardown) ? null : new Carbon($teardown)]);
|
||||||
|
|
||||||
$check = new ChecksArrivalsAndDeparturesImplementation();
|
$check = new ChecksArrivalsAndDeparturesImplementation();
|
||||||
$this->assertFalse($check->checkArrival($arrival, $departure));
|
$this->assertFalse($check->checkArrival($arrival, $departure));
|
||||||
|
@ -45,12 +67,15 @@ class ChecksArrivalsAndDeparturesTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::isDepartureDateValid
|
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::isDepartureDateValid
|
||||||
* @dataProvider invalidDateCombinations
|
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::toCarbon
|
||||||
|
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::isBeforeBuildup
|
||||||
|
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::isAfterTeardown
|
||||||
|
* @dataProvider invalidDepartureCombinations
|
||||||
*/
|
*/
|
||||||
public function testCheckInvalidDatesForDeparture($buildup, $teardown, $arrival, $departure)
|
public function testCheckInvalidDatesForDeparture($buildup, $teardown, $arrival, $departure)
|
||||||
{
|
{
|
||||||
config(['buildup_start' => is_null($buildup) ? null: new Carbon($buildup)]);
|
config(['buildup_start' => is_null($buildup) ? null : new Carbon($buildup)]);
|
||||||
config(['teardown_end' => is_null($teardown) ? null: new Carbon($teardown)]);
|
config(['teardown_end' => is_null($teardown) ? null : new Carbon($teardown)]);
|
||||||
|
|
||||||
$check = new ChecksArrivalsAndDeparturesImplementation();
|
$check = new ChecksArrivalsAndDeparturesImplementation();
|
||||||
$this->assertFalse($check->checkDeparture($arrival, $departure));
|
$this->assertFalse($check->checkDeparture($arrival, $departure));
|
||||||
|
@ -58,12 +83,15 @@ class ChecksArrivalsAndDeparturesTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::isArrivalDateValid
|
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::isArrivalDateValid
|
||||||
* @dataProvider validDateCombinations
|
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::toCarbon
|
||||||
|
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::isBeforeBuildup
|
||||||
|
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::isAfterTeardown
|
||||||
|
* @dataProvider validArrivalCombinations
|
||||||
*/
|
*/
|
||||||
public function testCheckValidDatesForArrival($buildup, $teardown, $arrival, $departure)
|
public function testCheckValidDatesForArrival($buildup, $teardown, $arrival, $departure)
|
||||||
{
|
{
|
||||||
config(['buildup_start' => is_null($buildup) ? null: new Carbon($buildup)]);
|
config(['buildup_start' => is_null($buildup) ? null : new Carbon($buildup)]);
|
||||||
config(['teardown_end' => is_null($teardown) ? null: new Carbon($teardown)]);
|
config(['teardown_end' => is_null($teardown) ? null : new Carbon($teardown)]);
|
||||||
|
|
||||||
$check = new ChecksArrivalsAndDeparturesImplementation();
|
$check = new ChecksArrivalsAndDeparturesImplementation();
|
||||||
$this->assertTrue($check->checkArrival($arrival, $departure));
|
$this->assertTrue($check->checkArrival($arrival, $departure));
|
||||||
|
@ -71,12 +99,15 @@ class ChecksArrivalsAndDeparturesTest extends TestCase
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::isDepartureDateValid
|
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::isDepartureDateValid
|
||||||
* @dataProvider validDateCombinations
|
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::toCarbon
|
||||||
|
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::isBeforeBuildup
|
||||||
|
* @covers \Engelsystem\Controllers\ChecksArrivalsAndDepartures::isAfterTeardown
|
||||||
|
* @dataProvider validDepartureCombinations
|
||||||
*/
|
*/
|
||||||
public function testCheckValidDatesForDeparture($buildup, $teardown, $arrival, $departure)
|
public function testCheckValidDatesForDeparture($buildup, $teardown, $arrival, $departure)
|
||||||
{
|
{
|
||||||
config(['buildup_start' => is_null($buildup) ? null: new Carbon($buildup)]);
|
config(['buildup_start' => is_null($buildup) ? null : new Carbon($buildup)]);
|
||||||
config(['teardown_end' => is_null($teardown) ? null: new Carbon($teardown)]);
|
config(['teardown_end' => is_null($teardown) ? null : new Carbon($teardown)]);
|
||||||
|
|
||||||
$check = new ChecksArrivalsAndDeparturesImplementation();
|
$check = new ChecksArrivalsAndDeparturesImplementation();
|
||||||
$this->assertTrue($check->checkDeparture($arrival, $departure));
|
$this->assertTrue($check->checkDeparture($arrival, $departure));
|
||||||
|
|
|
@ -3,15 +3,10 @@
|
||||||
namespace Engelsystem\Test\Unit\Controllers;
|
namespace Engelsystem\Test\Unit\Controllers;
|
||||||
|
|
||||||
use Engelsystem\Config\Config;
|
use Engelsystem\Config\Config;
|
||||||
use Engelsystem\Controllers\Admin\UserShirtController;
|
|
||||||
use Engelsystem\Controllers\SettingsController;
|
use Engelsystem\Controllers\SettingsController;
|
||||||
use Engelsystem\Http\Exceptions\HttpNotFound;
|
use Engelsystem\Http\Exceptions\HttpNotFound;
|
||||||
use Engelsystem\Http\Redirector;
|
|
||||||
use Engelsystem\Http\Response;
|
use Engelsystem\Http\Response;
|
||||||
use Engelsystem\Models\User\Contact;
|
|
||||||
use Engelsystem\Models\User\PersonalData;
|
|
||||||
use Engelsystem\Models\User\Settings;
|
use Engelsystem\Models\User\Settings;
|
||||||
use Engelsystem\Models\User\State;
|
|
||||||
use Engelsystem\Test\Unit\TestCase;
|
use Engelsystem\Test\Unit\TestCase;
|
||||||
use PHPUnit\Framework\MockObject\MockObject;
|
use PHPUnit\Framework\MockObject\MockObject;
|
||||||
use Symfony\Component\HttpFoundation\Session\Session;
|
use Symfony\Component\HttpFoundation\Session\Session;
|
||||||
|
@ -56,7 +51,8 @@ class SettingsControllerTest extends TestCase
|
||||||
/** @var SettingsController */
|
/** @var SettingsController */
|
||||||
protected $controller;
|
protected $controller;
|
||||||
|
|
||||||
protected function setUpProfileTest() {
|
protected function setUpProfileTest()
|
||||||
|
{
|
||||||
$body = [
|
$body = [
|
||||||
'pronoun' => 'Herr',
|
'pronoun' => 'Herr',
|
||||||
'first_name' => 'John',
|
'first_name' => 'John',
|
||||||
|
@ -128,8 +124,14 @@ class SettingsControllerTest extends TestCase
|
||||||
$this->assertEquals($body['pronoun'], $this->user->personalData->pronoun);
|
$this->assertEquals($body['pronoun'], $this->user->personalData->pronoun);
|
||||||
$this->assertEquals($body['first_name'], $this->user->personalData->first_name);
|
$this->assertEquals($body['first_name'], $this->user->personalData->first_name);
|
||||||
$this->assertEquals($body['last_name'], $this->user->personalData->last_name);
|
$this->assertEquals($body['last_name'], $this->user->personalData->last_name);
|
||||||
$this->assertEquals($body['planned_arrival_date'], $this->user->personalData->planned_arrival_date->format('Y-m-d'));
|
$this->assertEquals(
|
||||||
$this->assertEquals($body['planned_departure_date'], $this->user->personalData->planned_departure_date->format('Y-m-d'));
|
$body['planned_arrival_date'],
|
||||||
|
$this->user->personalData->planned_arrival_date->format('Y-m-d')
|
||||||
|
);
|
||||||
|
$this->assertEquals(
|
||||||
|
$body['planned_departure_date'],
|
||||||
|
$this->user->personalData->planned_departure_date->format('Y-m-d')
|
||||||
|
);
|
||||||
$this->assertEquals($body['dect'], $this->user->contact->dect);
|
$this->assertEquals($body['dect'], $this->user->contact->dect);
|
||||||
$this->assertEquals($body['mobile'], $this->user->contact->mobile);
|
$this->assertEquals($body['mobile'], $this->user->contact->mobile);
|
||||||
$this->assertEquals($body['email'], $this->user->email);
|
$this->assertEquals($body['email'], $this->user->email);
|
||||||
|
@ -565,7 +567,7 @@ class SettingsControllerTest extends TestCase
|
||||||
config(['oauth' => $providers]);
|
config(['oauth' => $providers]);
|
||||||
|
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'http://localhost/user-settings' => 'settings.profile',
|
'http://localhost/settings/profile' => 'settings.profile',
|
||||||
'http://localhost/settings/password' => 'settings.password',
|
'http://localhost/settings/password' => 'settings.password',
|
||||||
'http://localhost/settings/language' => 'settings.language',
|
'http://localhost/settings/language' => 'settings.language',
|
||||||
'http://localhost/settings/theme' => 'settings.theme',
|
'http://localhost/settings/theme' => 'settings.theme',
|
||||||
|
@ -574,7 +576,7 @@ class SettingsControllerTest extends TestCase
|
||||||
|
|
||||||
config(['oauth' => $providersHidden]);
|
config(['oauth' => $providersHidden]);
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'http://localhost/user-settings' => 'settings.profile',
|
'http://localhost/settings/profile' => 'settings.profile',
|
||||||
'http://localhost/settings/password' => 'settings.password',
|
'http://localhost/settings/password' => 'settings.password',
|
||||||
'http://localhost/settings/language' => 'settings.language',
|
'http://localhost/settings/language' => 'settings.language',
|
||||||
'http://localhost/settings/theme' => 'settings.theme',
|
'http://localhost/settings/theme' => 'settings.theme',
|
||||||
|
@ -590,7 +592,7 @@ class SettingsControllerTest extends TestCase
|
||||||
config(['oauth' => []]);
|
config(['oauth' => []]);
|
||||||
|
|
||||||
$this->assertEquals([
|
$this->assertEquals([
|
||||||
'http://localhost/user-settings' => 'settings.profile',
|
'http://localhost/settings/profile' => 'settings.profile',
|
||||||
'http://localhost/settings/password' => 'settings.password',
|
'http://localhost/settings/password' => 'settings.password',
|
||||||
'http://localhost/settings/language' => 'settings.language',
|
'http://localhost/settings/language' => 'settings.language',
|
||||||
'http://localhost/settings/theme' => 'settings.theme'
|
'http://localhost/settings/theme' => 'settings.theme'
|
||||||
|
|
|
@ -8,12 +8,12 @@ class ChecksArrivalsAndDeparturesImplementation
|
||||||
{
|
{
|
||||||
use ChecksArrivalsAndDepartures;
|
use ChecksArrivalsAndDepartures;
|
||||||
|
|
||||||
public function checkArrival(string $arrival, string $departure): bool
|
public function checkArrival(?string $arrival, ?string $departure): bool
|
||||||
{
|
{
|
||||||
return $this->isArrivalDateValid($arrival, $departure);
|
return $this->isArrivalDateValid($arrival, $departure);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function checkDeparture(string $arrival, string $departure): bool
|
public function checkDeparture(?string $arrival, ?string $departure): bool
|
||||||
{
|
{
|
||||||
return $this->isDepartureDateValid($arrival, $departure);
|
return $this->isDepartureDateValid($arrival, $departure);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue