Cleanup: Simplification and removed dead code and duplicated/outdated declarations

This commit is contained in:
Igor Scheller 2022-06-16 23:00:56 +02:00
parent 3ebea2ae15
commit 5e81b8d2af
27 changed files with 64 additions and 205 deletions

View File

@ -81,7 +81,7 @@ function public_dashboard_controller_free_shift($shift, ShiftsFilter $filter = n
'shifttype_name' => $shifttype['name'], 'shifttype_name' => $shifttype['name'],
'title' => $shift['title'], 'title' => $shift['title'],
'room_name' => $room->name, 'room_name' => $room->name,
'needed_angels' => [] 'needed_angels' => public_dashboard_needed_angels($shift['NeedAngels'], $filter),
]; ];
if (time() + 3 * 60 * 60 > $shift['start']) { if (time() + 3 * 60 * 60 > $shift['start']) {
@ -91,8 +91,6 @@ function public_dashboard_controller_free_shift($shift, ShiftsFilter $filter = n
$free_shift['style'] = 'danger'; $free_shift['style'] = 'danger';
} }
$free_shift['needed_angels'] = public_dashboard_needed_angels($shift['NeedAngels'], $filter);
return $free_shift; return $free_shift;
} }

View File

@ -17,9 +17,7 @@ function shift_link($shift)
$parameters['shift_id'] = $shift['SID']; $parameters['shift_id'] = $shift['SID'];
} }
$link = page_link_to('shifts', $parameters); return page_link_to('shifts', $parameters);
return $link;
} }
/** /**

View File

@ -40,7 +40,7 @@ function user_driver_licenses_controller()
$user = auth()->user(); $user = auth()->user();
if (!$user) { if (!$user) {
throw_redirect(page_link_to('')); throw_redirect(page_link_to());
} }
$action = strip_request_item('action', 'edit'); $action = strip_request_item('action', 'edit');

View File

@ -87,7 +87,7 @@ function user_worklog_from_request(Worklog $worklog)
} }
$worklog->hours = $request->input('work_hours'); $worklog->hours = $request->input('work_hours');
if (!preg_match("/^[0-9]+(\.[0-9]{0,2})?$/", $worklog->hours)) { if (!preg_match("/^\d+(\.\d{0,2})?$/", $worklog->hours)) {
$valid = false; $valid = false;
error(__('Please enter work hours in format ##[.##].')); error(__('Please enter work hours in format ##[.##].'));
} }

View File

@ -19,7 +19,7 @@ function users_controller()
$request = request(); $request = request();
if (!$user) { if (!$user) {
throw_redirect(page_link_to('')); throw_redirect(page_link_to());
} }
$action = 'list'; $action = 'list';
@ -58,7 +58,7 @@ function user_delete_controller()
} }
if (!auth()->can('admin_user')) { if (!auth()->can('admin_user')) {
throw_redirect(page_link_to('')); throw_redirect(page_link_to());
} }
// You cannot delete yourself // You cannot delete yourself
@ -150,7 +150,7 @@ function user_edit_vouchers_controller()
(!auth()->can('admin_user') && !auth()->can('voucher.edit')) (!auth()->can('admin_user') && !auth()->can('voucher.edit'))
|| !config('enable_voucher') || !config('enable_voucher')
) { ) {
throw_redirect(page_link_to('')); throw_redirect(page_link_to());
} }
if ($request->hasPostData('submit')) { if ($request->hasPostData('submit')) {
@ -266,7 +266,7 @@ function users_list_controller()
$request = request(); $request = request();
if (!auth()->can('admin_user')) { if (!auth()->can('admin_user')) {
throw_redirect(page_link_to('')); throw_redirect(page_link_to());
} }
$order_by = 'name'; $order_by = 'name';
@ -385,8 +385,6 @@ function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter)
$filtered_shifts = []; $filtered_shifts = [];
foreach ($shifts as $shift) { foreach ($shifts as $shift) {
$needed_angels_count = 0; $needed_angels_count = 0;
$taken = 0;
foreach ($needed_angeltypes[$shift['SID']] as $needed_angeltype) { foreach ($needed_angeltypes[$shift['SID']] as $needed_angeltype) {
$taken = 0; $taken = 0;

View File

@ -18,6 +18,7 @@ require __DIR__ . '/includes.php';
/** /**
* Check for maintenance * Check for maintenance
*/ */
/** @var \Engelsystem\Application $app */
if ($app->get('config')->get('maintenance')) { if ($app->get('config')->get('maintenance')) {
http_response_code(503); http_response_code(503);
$url = $app->get(UrlGeneratorInterface::class); $url = $app->get(UrlGeneratorInterface::class);

View File

@ -29,7 +29,7 @@ function engelsystem_email_to_user($recipientUser, $title, $message, $notIfItsMe
$translator->setLocale($recipientUser->settings->language); $translator->setLocale($recipientUser->settings->language);
$mailer->sendView( $mailer->sendView(
$recipientUser->contact->email ? $recipientUser->contact->email : $recipientUser->email, $recipientUser->contact->email ?: $recipientUser->email,
$title, $title,
'emails/mail', 'emails/mail',
['username' => $recipientUser->name, 'message' => $message] ['username' => $recipientUser->name, 'message' => $message]

View File

@ -27,13 +27,13 @@ class ShiftsFilter
private $userShiftsAdmin; private $userShiftsAdmin;
/** @var int[] */ /** @var int[] */
private $filled = []; private $filled;
/** @var int[] */ /** @var int[] */
private $rooms = []; private $rooms;
/** @var int[] */ /** @var int[] */
private $types = []; private $types;
/** @var int unix timestamp */ /** @var int unix timestamp */
private $startTime = null; private $startTime = null;

View File

@ -375,8 +375,8 @@ function Shift_signup_allowed_angel(
if ( if (
empty($user_angeltype) empty($user_angeltype)
|| ($angeltype['no_self_signup'] == 1 && !empty($user_angeltype)) || $angeltype['no_self_signup'] == 1
|| ($angeltype['restricted'] == 1 && !empty($user_angeltype) && !isset($user_angeltype['confirm_user_id'])) || ($angeltype['restricted'] == 1 && !isset($user_angeltype['confirm_user_id']))
) { ) {
// you cannot join if user is not of this angel type // you cannot join if user is not of this angel type
// you cannot join if you are not confirmed // you cannot join if you are not confirmed

View File

@ -1,130 +0,0 @@
<?php
use Engelsystem\Database\Db;
/**
* Returns a new empty UserDriverLicense
* FIXME entity object needed
*
* @return array
*/
function UserDriverLicense_new()
{
return [
'user_id' => null,
'has_car' => false,
'has_license_car' => false,
'has_license_3_5t_transporter' => false,
'has_license_7_5t_truck' => false,
'has_license_12_5t_truck' => false,
'has_license_forklift' => false
];
}
/**
* Is it valid?
*
* @param array $user_driver_license The UserDriverLicense to check
* @return boolean
*/
function UserDriverLicense_valid($user_driver_license)
{
return
$user_driver_license['has_license_car']
|| $user_driver_license['has_license_3_5t_transporter']
|| $user_driver_license['has_license_7_5t_truck']
|| $user_driver_license['has_license_12_5t_truck']
|| $user_driver_license['has_license_forklift'];
}
/**
* Get a users driver license information
*
* @param int $user_id The users id
* @return array|null
*/
function UserDriverLicense($user_id)
{
$driverLicense = DB::selectOne('
SELECT *
FROM `UserDriverLicenses`
WHERE `user_id`=?', [$user_id]);
return empty($driverLicense) ? null : $driverLicense;
}
/**
* Create a user's driver license entry
*
* @param array $user_driver_license The UserDriverLicense to create
* @param int $userId
* @return array
*/
function UserDriverLicenses_create($user_driver_license, $userId)
{
$user_driver_license['user_id'] = $userId;
DB::insert('
INSERT INTO `UserDriverLicenses` (
`user_id`,
`has_car`,
`has_license_car`,
`has_license_3_5t_transporter`,
`has_license_7_5t_truck`,
`has_license_12_5t_truck`,
`has_license_forklift`
)
VALUES (?, ?, ?, ?, ?, ?, ?)
',
[
$user_driver_license['user_id'],
(int)$user_driver_license['has_car'],
(int)$user_driver_license['has_license_car'],
(int)$user_driver_license['has_license_3_5t_transporter'],
(int)$user_driver_license['has_license_7_5t_truck'],
(int)$user_driver_license['has_license_12_5t_truck'],
(int)$user_driver_license['has_license_forklift'],
]
);
return $user_driver_license;
}
/**
* Update a user's driver license entry
*
* @param array $user_driver_license The UserDriverLicense to update
*/
function UserDriverLicenses_update($user_driver_license)
{
DB::update('
UPDATE `UserDriverLicenses`
SET
`has_car`=?,
`has_license_car`=?,
`has_license_3_5t_transporter`=?,
`has_license_7_5t_truck`=?,
`has_license_12_5t_truck`=?,
`has_license_forklift`=?
WHERE `user_id`=?
',
[
(int)$user_driver_license['has_car'],
(int)$user_driver_license['has_license_car'],
(int)$user_driver_license['has_license_3_5t_transporter'],
(int)$user_driver_license['has_license_7_5t_truck'],
(int)$user_driver_license['has_license_12_5t_truck'],
(int)$user_driver_license['has_license_forklift'],
$user_driver_license['user_id'],
]
);
}
/**
* Delete a user's driver license entry
*
* @param int $user_id
*/
function UserDriverLicenses_delete($user_id)
{
DB::delete('DELETE FROM `UserDriverLicenses` WHERE `user_id`=?', [$user_id]);
}

View File

@ -2,7 +2,6 @@
use Carbon\Carbon; use Carbon\Carbon;
use Engelsystem\Models\Room; use Engelsystem\Models\Room;
use Engelsystem\Models\User\User;
use Engelsystem\Models\Worklog; use Engelsystem\Models\Worklog;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;

View File

@ -306,7 +306,7 @@ function admin_active()
form_submit('submit', __('Search')) form_submit('submit', __('Search'))
], page_link_to('admin_active')), ], page_link_to('admin_active')),
$set_active == '' ? form([ $set_active == '' ? form([
form_text('count', __('How much angels should be active?'), $count ? $count : $forced_count), form_text('count', __('How much angels should be active?'), $count ?: $forced_count),
form_submit('set_active', __('Preview')) form_submit('set_active', __('Preview'))
]) : $set_active, ]) : $set_active,
$msg . msg(), $msg . msg(),

View File

@ -91,7 +91,7 @@ function admin_free()
} }
} }
$email = ($usr->contact->email ? $usr->contact->email : $usr->email); $email = $usr->contact->email ?: $usr->email;
$free_users_table[] = [ $free_users_table[] = [
'name' => User_Nick_render($usr) . User_Pronoun_render($usr), 'name' => User_Nick_render($usr) . User_Pronoun_render($usr),
'shift_state' => User_shift_state_render($usr), 'shift_state' => User_shift_state_render($usr),

View File

@ -123,14 +123,11 @@ function admin_groups()
$group = Db::selectOne('SELECT * FROM `Groups` WHERE `UID`=? LIMIT 1', [$group_id]); $group = Db::selectOne('SELECT * FROM `Groups` WHERE `UID`=? LIMIT 1', [$group_id]);
$privileges = $request->request->all('privileges'); $privileges = $request->request->all('privileges');
if (!is_array($privileges)) {
$privileges = [];
}
if (!empty($group)) { if (!empty($group)) {
Db::delete('DELETE FROM `GroupPrivileges` WHERE `group_id`=?', [$group_id]); Db::delete('DELETE FROM `GroupPrivileges` WHERE `group_id`=?', [$group_id]);
$privilege_names = []; $privilege_names = [];
foreach ($privileges as $privilege) { foreach ($privileges as $privilege) {
if (preg_match('/^\d{1,}$/', $privilege)) { if (preg_match('/^\d+$/', $privilege)) {
$group_privileges_source = Db::selectOne( $group_privileges_source = Db::selectOne(
'SELECT `name` FROM `Privileges` WHERE `id`=? LIMIT 1', 'SELECT `name` FROM `Privileges` WHERE `id`=? LIMIT 1',
[$privilege] [$privilege]

View File

@ -27,8 +27,8 @@ function admin_shifts()
$session = session(); $session = session();
$start = Carbon::createTimestampFromDatetime(date('Y-m-d') . 'T00:00'); $start = Carbon::createTimestampFromDatetime(date('Y-m-d') . 'T00:00');
$end = $start; $end = $start;
$mode = 'single'; $mode = '';
$angelmode = 'manually'; $angelmode = '';
$length = ''; $length = '';
$change_hours = []; $change_hours = [];
$title = ''; $title = '';
@ -452,7 +452,7 @@ function admin_shifts()
div('col-md-6', [ div('col-md-6', [
form_datetime('start', __('Start'), $start), form_datetime('start', __('Start'), $start),
form_datetime('end', __('End'), $end), form_datetime('end', __('End'), $end),
form_info(__('Mode'), ''), form_info(__('Mode')),
form_radio('mode', __('Create one shift'), $mode == 'single', 'single'), form_radio('mode', __('Create one shift'), $mode == 'single', 'single'),
form_radio('mode', __('Create multiple shifts'), $mode == 'multi', 'multi'), form_radio('mode', __('Create multiple shifts'), $mode == 'multi', 'multi'),
form_text( form_text(
@ -482,7 +482,7 @@ function admin_shifts()
) )
]), ]),
div('col-md-6', [ div('col-md-6', [
form_info(__('Needed angels'), ''), form_info(__('Needed angels')),
form_radio( form_radio(
'angelmode', 'angelmode',
__('Take needed angels from room settings'), __('Take needed angels from room settings'),

View File

@ -44,7 +44,7 @@ function admin_user()
. page_link_to('admin_user', ['action' => 'save', 'id' => $user_id]) . page_link_to('admin_user', ['action' => 'save', 'id' => $user_id])
. '" method="post">' . "\n"; . '" method="post">' . "\n";
$html .= form_csrf(); $html .= form_csrf();
$html .= '<table border="0">' . "\n"; $html .= '<table>' . "\n";
$html .= '<input type="hidden" name="Type" value="Normal">' . "\n"; $html .= '<input type="hidden" name="Type" value="Normal">' . "\n";
$html .= '<tr><td>' . "\n"; $html .= '<tr><td>' . "\n";
$html .= '<table>' . "\n"; $html .= '<table>' . "\n";
@ -100,7 +100,7 @@ function admin_user()
$html .= ' <tr><td>T-Shirt</td><td>' . "\n"; $html .= ' <tr><td>T-Shirt</td><td>' . "\n";
$html .= html_options('eTshirt', $options, $user_source->state->got_shirt) . '</td></tr>' . "\n"; $html .= html_options('eTshirt', $options, $user_source->state->got_shirt) . '</td></tr>' . "\n";
$html .= '</table>' . "\n" . '</td><td valign="top"></td></tr>'; $html .= '</table>' . "\n" . '</td><td></td></tr>';
$html .= '</td></tr>' . "\n"; $html .= '</td></tr>' . "\n";
$html .= '</table>' . "\n" . '<br />' . "\n"; $html .= '</table>' . "\n" . '<br />' . "\n";

View File

@ -5,6 +5,7 @@ declare(strict_types=1);
namespace Engelsystem\Controllers\Admin\Schedule; namespace Engelsystem\Controllers\Admin\Schedule;
use Carbon\Carbon; use Carbon\Carbon;
use DateTimeInterface;
use Engelsystem\Controllers\BaseController; use Engelsystem\Controllers\BaseController;
use Engelsystem\Controllers\HasUserNotifications; use Engelsystem\Controllers\HasUserNotifications;
use Engelsystem\Helpers\Schedule\Event; use Engelsystem\Helpers\Schedule\Event;
@ -247,7 +248,7 @@ class ImportSchedule extends BaseController
foreach ($newEvents as $event) { foreach ($newEvents as $event) {
$this->createEvent( $this->createEvent(
$event, $event,
(int)$shiftType, $shiftType,
$rooms $rooms
->where('name', $event->getRoom()->getName()) ->where('name', $event->getRoom()->getName())
->first(), ->first(),
@ -258,7 +259,7 @@ class ImportSchedule extends BaseController
foreach ($changeEvents as $event) { foreach ($changeEvents as $event) {
$this->updateEvent( $this->updateEvent(
$event, $event,
(int)$shiftType, $shiftType,
$rooms $rooms
->where('name', $event->getRoom()->getName()) ->where('name', $event->getRoom()->getName())
->first() ->first()
@ -326,8 +327,8 @@ class ImportSchedule extends BaseController
[ [
'shift' => $shift->getTitle(), 'shift' => $shift->getTitle(),
'room' => $room->name, 'room' => $room->name,
'from' => $shift->getDate()->format(Carbon::RFC3339), 'from' => $shift->getDate()->format(DateTimeInterface::RFC3339),
'to' => $shift->getEndDate()->format(Carbon::RFC3339), 'to' => $shift->getEndDate()->format(DateTimeInterface::RFC3339),
'guid' => $shift->getGuid(), 'guid' => $shift->getGuid(),
] ]
); );
@ -364,8 +365,8 @@ class ImportSchedule extends BaseController
[ [
'shift' => $shift->getTitle(), 'shift' => $shift->getTitle(),
'room' => $room->name, 'room' => $room->name,
'from' => $shift->getDate()->format(Carbon::RFC3339), 'from' => $shift->getDate()->format(DateTimeInterface::RFC3339),
'to' => $shift->getEndDate()->format(Carbon::RFC3339), 'to' => $shift->getEndDate()->format(DateTimeInterface::RFC3339),
'guid' => $shift->getGuid(), 'guid' => $shift->getGuid(),
] ]
); );
@ -386,8 +387,8 @@ class ImportSchedule extends BaseController
'Deleted schedule shift "{shift}" ({from} {to}, {guid})', 'Deleted schedule shift "{shift}" ({from} {to}, {guid})',
[ [
'shift' => $shift->getTitle(), 'shift' => $shift->getTitle(),
'from' => $shift->getDate()->format(Carbon::RFC3339), 'from' => $shift->getDate()->format(DateTimeInterface::RFC3339),
'to' => $shift->getEndDate()->format(Carbon::RFC3339), 'to' => $shift->getEndDate()->format(DateTimeInterface::RFC3339),
'guid' => $shift->getGuid(), 'guid' => $shift->getGuid(),
] ]
); );
@ -395,7 +396,7 @@ class ImportSchedule extends BaseController
/** /**
* @param Request $request * @param Request $request
* @return Event[]|Room[]|RoomModel[]|ScheduleUrl|Schedule|string * @return Event[]|Room[]|RoomModel[]
* @throws ErrorException * @throws ErrorException
*/ */
protected function getScheduleData(Request $request) protected function getScheduleData(Request $request)
@ -528,7 +529,7 @@ class ImportSchedule extends BaseController
$end = Carbon::createFromTimestamp($shift->end); $end = Carbon::createFromTimestamp($shift->end);
$duration = $start->diff($end); $duration = $start->diff($end);
$event = new Event( return new Event(
$scheduleShift->guid, $scheduleShift->guid,
0, 0,
new Room($shift->room_name), new Room($shift->room_name),
@ -542,8 +543,6 @@ class ImportSchedule extends BaseController
'', '',
'' ''
); );
return $event;
} }
/** /**

View File

@ -24,7 +24,7 @@ function user_myshifts()
if ( if (
$request->has('id') $request->has('id')
&& auth()->can('user_shifts_admin') && auth()->can('user_shifts_admin')
&& preg_match('/^\d{1,}$/', $request->input('id')) && preg_match('/^\d+$/', $request->input('id'))
&& User::find($request->input('id')) && User::find($request->input('id'))
) { ) {
$shift_entry_id = $request->input('id'); $shift_entry_id = $request->input('id');

View File

@ -39,11 +39,11 @@ function form_spinner($name, $label, $value)
</div> </div>
<script type="text/javascript"> <script type="text/javascript">
$(\'#spinner-' . $name . '-down\').click(function() { $(\'#spinner-' . $name . '-down\').click(function() {
var spinner = $(\'#spinner-' . $name . '\'); let spinner = $(\'#spinner-' . $name . '\');
spinner.val(parseInt(spinner.val()) - 1); spinner.val(parseInt(spinner.val()) - 1);
}); });
$(\'#spinner-' . $name . '-up\').click(function() { $(\'#spinner-' . $name . '-up\').click(function() {
var spinner = $(\'#spinner-' . $name . '\'); let spinner = $(\'#spinner-' . $name . '\');
spinner.val(parseInt(spinner.val()) + 1); spinner.val(parseInt(spinner.val()) + 1);
}); });
</script> </script>
@ -55,7 +55,7 @@ function form_spinner($name, $label, $value)
* *
* @param string $name Name of the parameter * @param string $name Name of the parameter
* @param string $label Label * @param string $label Label
* @param int $value Unix Timestamp * @param int|Carbon $value Unix Timestamp
* @param string $start_date Earliest possible date * @param string $start_date Earliest possible date
* @param string $end_date * @param string $end_date
* @return string HTML * @return string HTML
@ -93,10 +93,12 @@ function form_datetime(string $name, string $label, $value)
return form_element($label, sprintf(' return form_element($label, sprintf('
<div class="input-group datetime" id="%s"> <div class="input-group datetime" id="%s">
<input type="datetime-local" pattern="[0-9]{4}-[0-9]{2}-[0-9]{2} ([01][0-9]|2[0-3]):[0-5][0-9]" placeholder="YYYY-MM-DD HH:MM" name="%s" <input type="datetime-local"
pattern="[0-9]{4}-[0-9]{2}-[0-9]{2} ([01][0-9]|2[0-3]):[0-5][0-9]" placeholder="YYYY-MM-DD HH:MM"
name="%s"
class="form-control" value="%s" autocomplete="off"> class="form-control" value="%s" autocomplete="off">
</div> </div>
', $dom_id, $name, htmlspecialchars($value ? $value->format('Y-m-d H:i') : ''), $dom_id), $dom_id); ', $dom_id, $name, htmlspecialchars($value ? $value->format('Y-m-d H:i') : '')), $dom_id);
} }
/** /**
@ -112,7 +114,7 @@ function form_checkboxes($name, $label, $items, $selected)
{ {
$html = form_element($label, ''); $html = form_element($label, '');
foreach ($items as $key => $item) { foreach ($items as $key => $item) {
$html .= form_checkbox($name . '_' . $key, $item, array_search($key, $selected) !== false); $html .= form_checkbox($name . '_' . $key, $item, in_array($key, $selected));
} }
return $html; return $html;
} }
@ -140,8 +142,8 @@ function form_multi_checkboxes($names, $label, $items, $selected, $disabled = []
$dom_id = ''; $dom_id = '';
foreach ($names as $name => $title) { foreach ($names as $name => $title) {
$dom_id = $name . '_' . $key; $dom_id = $name . '_' . $key;
$sel = array_search($key, $selected[$name]) !== false ? ' checked="checked"' : ''; $sel = in_array($key, $selected[$name]) ? ' checked="checked"' : '';
if (!empty($disabled) && !empty($disabled[$name]) && array_search($key, $disabled[$name]) !== false) { if (!empty($disabled) && !empty($disabled[$name]) && in_array($key, $disabled[$name])) {
$sel .= ' disabled="disabled"'; $sel .= ' disabled="disabled"';
} }
$html .= '<td style="text-align: center;">' $html .= '<td style="text-align: center;">'
@ -216,7 +218,7 @@ function form_info($label, $text = '')
if ($text == '') { if ($text == '') {
return '<h4>' . $label . '</h4>'; return '<h4>' . $label . '</h4>';
} }
return form_element($label, '<p class="form-control-static">' . $text . '</p>', ''); return form_element($label, '<p class="form-control-static">' . $text . '</p>');
} }
/** /**

View File

@ -173,7 +173,7 @@ function check_date($input, $error_message = null, $null_allowed = false, $time_
* Returns REQUEST value filtered or default value (null) if not set. * Returns REQUEST value filtered or default value (null) if not set.
* *
* @param string $name * @param string $name
* @param string $default_value * @param string|null $default_value
* @return mixed|null * @return mixed|null
*/ */
function strip_request_item($name, $default_value = null) function strip_request_item($name, $default_value = null)
@ -215,7 +215,7 @@ function strip_request_item_nl($name, $default_value = null)
if ($request->has($name)) { if ($request->has($name)) {
// Only allow letters, symbols, punctuation, separators, numbers and newlines without html tags // Only allow letters, symbols, punctuation, separators, numbers and newlines without html tags
return preg_replace( return preg_replace(
"/([^\p{L}\p{S}\p{P}\p{Z}\p{N}+\n]{1,})/ui", "/([^\p{L}\p{S}\p{P}\p{Z}\p{N}+\n]+)/ui",
'', '',
strip_tags($request->input($name)) strip_tags($request->input($name))
); );
@ -232,7 +232,7 @@ function strip_request_item_nl($name, $default_value = null)
function strip_item($item) function strip_item($item)
{ {
// Only allow letters, symbols, punctuation, separators and numbers without html tags // Only allow letters, symbols, punctuation, separators and numbers without html tags
return preg_replace("/([^\p{L}\p{S}\p{P}\p{Z}\p{N}+]{1,})/ui", '', strip_tags($item)); return preg_replace("/([^\p{L}\p{S}\p{P}\p{Z}\p{N}+]+)/ui", '', strip_tags($item));
} }
/** /**

View File

@ -110,7 +110,7 @@ function progress_bar($valuemin, $valuemax, $valuenow, $class = '', $content = '
. 'aria-valuenow="' . $valuenow . '" aria-valuemin="' . $valuemin . '" aria-valuemax="' . $valuemax . '" ' . 'aria-valuenow="' . $valuenow . '" aria-valuemin="' . $valuemin . '" aria-valuemax="' . $valuemax . '" '
. 'style="width: ' . floor(($valuenow - $valuemin) * 100 / ($valuemax - $valuemin)) . '%"' . 'style="width: ' . floor(($valuenow - $valuemin) * 100 / ($valuemax - $valuemin)) . '%"'
. '>' . '>'
. $content . '' . $content
. '</div>' . '</div>'
. '</div>'; . '</div>';
} }

View File

@ -23,7 +23,7 @@ function public_dashboard_view($stats, $free_shifts)
$shift_panels[] = '</div>'; $shift_panels[] = '</div>';
$needed_angels = div('first', [ $needed_angels = div('first', [
div('col-md-12', [ div('col-md-12', [
heading(__('Needed angels:'), 1) heading(__('Needed angels:'))
]), ]),
div('container-fluid', [ div('container-fluid', [
join($shift_panels) join($shift_panels)

View File

@ -24,7 +24,7 @@ function Room_view(Room $room, ShiftsFilterRenderer $shiftsFilterRenderer, Shift
if ($room->description) { if ($room->description) {
$description = '<h3>' . __('Description') . '</h3>'; $description = '<h3>' . __('Description') . '</h3>';
$parsedown = new Parsedown(); $parsedown = new Parsedown();
$description .= $parsedown->parse((string)$room->description); $description .= $parsedown->parse($room->description);
} }
$tabs = []; $tabs = [];

View File

@ -34,19 +34,19 @@ class ShiftCalendarRenderer
private $shiftsFilter; private $shiftsFilter;
/** @var int */ /** @var int */
private $firstBlockStartTime = 0; private $firstBlockStartTime;
/** @var int */ /** @var int */
private $lastBlockEndTime = 0; private $lastBlockEndTime;
/** @var int */ /** @var int */
private $blocksPerSlot = null; private $blocksPerSlot = null;
/** @var array[] */ /** @var array[] */
private $needed_angeltypes = []; private $needed_angeltypes;
/** @var array[] */ /** @var array[] */
private $shift_entries = []; private $shift_entries;
/** /**
* ShiftCalendarRenderer constructor. * ShiftCalendarRenderer constructor.
@ -100,7 +100,7 @@ class ShiftCalendarRenderer
} }
} }
// If all lanes for this room are busy, create a new lane and add shift to it // If all lanes for this room are busy, create a new lane and add shift to it
if ($shift_added == false) { if (!$shift_added) {
$newLane = new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot()); $newLane = new ShiftCalendarLane($header, $this->getFirstBlockStartTime(), $this->getBlocksPerSlot());
$newLane->addShift($shift); $newLane->addShift($shift);
$lanes[$room_id][] = $newLane; $lanes[$room_id][] = $newLane;

View File

@ -5,7 +5,6 @@ namespace Engelsystem;
use Engelsystem\Models\Room; use Engelsystem\Models\Room;
use Engelsystem\Models\User\User; use Engelsystem\Models\User\User;
use function config;
use function theme_type; use function theme_type;
/** /**

View File

@ -54,7 +54,7 @@ function UserDriverLicense_edit_view($user_source, $user_driver_license)
' '
<script type="text/javascript"> <script type="text/javascript">
$(function() { $(function() {
var checkbox = $(\'#wants_to_drive\'); let checkbox = $(\'#wants_to_drive\');
if(checkbox.is(\':checked\')) if(checkbox.is(\':checked\'))
$(\'#driving_license\').show(); $(\'#driving_license\').show();
else else

View File

@ -632,7 +632,7 @@ function User_view(
form([ form([
form_hidden('action', 'arrived'), form_hidden('action', 'arrived'),
form_hidden('user', $user_source->id), form_hidden('user', $user_source->id),
form_submit('submit', __('arrived'), '', false, 'primary') form_submit('submit', __('arrived'), '', false)
], page_link_to('admin_arrive'), true) : '', ], page_link_to('admin_arrive'), true) : '',
($admin_user_privilege || $auth->can('voucher.edit')) && config('enable_voucher') ? ($admin_user_privilege || $auth->can('voucher.edit')) && config('enable_voucher') ?
button( button(
@ -677,19 +677,17 @@ function User_view(
icon('phone') icon('phone')
. ' <a href="tel:' . $user_source->contact->dect . '">' . ' <a href="tel:' . $user_source->contact->dect . '">'
. $user_source->contact->dect . $user_source->contact->dect
. '</a>', 1 . '</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) . '">'
. icon('envelope') . icon('envelope')
. '</a>', . '</a>'
1
) )
: '' , : '' ,
] ]),
),
User_view_state($admin_user_privilege, $freeloader, $user_source), User_view_state($admin_user_privilege, $freeloader, $user_source),
User_angeltypes_render($user_angeltypes), User_angeltypes_render($user_angeltypes),
User_groups_render($user_groups), User_groups_render($user_groups),