Include phpcs for /includes

This commit is contained in:
Michael Weimann 2022-10-18 19:15:22 +02:00
parent 1af185c7ac
commit f7d499b362
No known key found for this signature in database
GPG Key ID: 34F0524D4DA694A1
36 changed files with 239 additions and 150 deletions

View File

@ -4,6 +4,7 @@
<file>config</file> <file>config</file>
<file>db</file> <file>db</file>
<file>includes</file>
<file>public/index.php</file> <file>public/index.php</file>
<file>src</file> <file>src</file>
<file>tests</file> <file>tests</file>
@ -18,5 +19,8 @@
<properties> <properties>
<property name="ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach" value="true" /> <property name="ignoreUnusedValuesWhenOnlyKeysAreUsedInForeach" value="true" />
</properties> </properties>
</rule> </rule>
<rule ref="Generic.Files.LineLength.TooLong">
<exclude-pattern>/includes</exclude-pattern>
</rule>
</ruleset> </ruleset>

View File

@ -6,6 +6,7 @@ use Engelsystem\Config\Config;
/** /**
* Include the autoloader * Include the autoloader
*/ */
require_once __DIR__ . '/autoload.php'; require_once __DIR__ . '/autoload.php';
/** /**

View File

@ -305,7 +305,8 @@ function angeltypes_list_controller()
$angeltype['membership'] = AngelType_render_membership($angeltype); $angeltype['membership'] = AngelType_render_membership($angeltype);
if (!empty($angeltype['user_angeltype_id'])) { if (!empty($angeltype['user_angeltype_id'])) {
$actions[] = button( $actions[] = button(
page_link_to('user_angeltypes', page_link_to(
'user_angeltypes',
['action' => 'delete', 'user_angeltype_id' => $angeltype['user_angeltype_id']] ['action' => 'delete', 'user_angeltype_id' => $angeltype['user_angeltype_id']]
), ),
__('leave'), __('leave'),

View File

@ -186,8 +186,11 @@ function shift_edit_controller()
$angel_types_spinner = ''; $angel_types_spinner = '';
foreach ($angeltypes as $angeltype_id => $angeltype_name) { foreach ($angeltypes as $angeltype_id => $angeltype_name) {
$angel_types_spinner .= form_spinner('type_' . $angeltype_id, $angeltype_name, $angel_types_spinner .= form_spinner(
$needed_angel_types[$angeltype_id]); 'type_' . $angeltype_id,
$angeltype_name,
$needed_angel_types[$angeltype_id]
);
} }
return page_with_title( return page_with_title(

View File

@ -28,11 +28,11 @@ function user_angeltypes_unconfirmed_hint()
$count = count($unconfirmed_user_angeltypes); $count = count($unconfirmed_user_angeltypes);
return _e( return _e(
'There is %d unconfirmed angeltype.', 'There is %d unconfirmed angeltype.',
'There are %d unconfirmed angeltypes.', 'There are %d unconfirmed angeltypes.',
$count, $count,
[$count] [$count]
) )
. ' ' . __('Angel types which need approvals:') . ' ' . __('Angel types which need approvals:')
. ' ' . join(', ', $unconfirmed_links); . ' ' . join(', ', $unconfirmed_links);
} }

View File

@ -110,7 +110,7 @@ function user_driver_license_edit_controller()
$driverLicense->drive_car = $request->has('has_license_car'); $driverLicense->drive_car = $request->has('has_license_car');
$driverLicense->drive_3_5t = $request->has('has_license_3_5t_transporter'); $driverLicense->drive_3_5t = $request->has('has_license_3_5t_transporter');
$driverLicense->drive_7_5t = $request->has('has_license_7_5t_truck'); $driverLicense->drive_7_5t = $request->has('has_license_7_5t_truck');
$driverLicense->drive_12t= $request->has('has_license_12t_truck'); $driverLicense->drive_12t = $request->has('has_license_12t_truck');
$driverLicense->drive_forklift = $request->has('has_license_forklift'); $driverLicense->drive_forklift = $request->has('has_license_forklift');
if ($driverLicense->wantsToDrive()) { if ($driverLicense->wantsToDrive()) {

View File

@ -70,10 +70,12 @@ function user_delete_controller()
if ($request->hasPostData('submit')) { if ($request->hasPostData('submit')) {
$valid = true; $valid = true;
if (!( if (
!(
$request->has('password') $request->has('password')
&& $auth->verifyPassword($user, $request->postData('password')) && $auth->verifyPassword($user, $request->postData('password'))
)) { )
) {
$valid = false; $valid = false;
error(__('auth.password.error')); error(__('auth.password.error'));
} }
@ -173,8 +175,10 @@ function user_edit_vouchers_controller()
$user_source->state->save(); $user_source->state->save();
success(__('Saved the number of vouchers.')); success(__('Saved the number of vouchers.'));
engelsystem_log(User_Nick_render($user_source, true) . ': ' . sprintf('Got %s vouchers', engelsystem_log(User_Nick_render($user_source, true) . ': ' . sprintf(
$user_source->state->got_voucher)); 'Got %s vouchers',
$user_source->state->got_voucher
));
throw_redirect(user_link($user_source->id)); throw_redirect(user_link($user_source->id));
} }
@ -206,7 +210,8 @@ function user_controller()
$shifts = Shifts_by_user($user_source->id, auth()->can('user_shifts_admin')); $shifts = Shifts_by_user($user_source->id, auth()->can('user_shifts_admin'));
foreach ($shifts as &$shift) { foreach ($shifts as &$shift) {
// TODO: Move queries to model // TODO: Move queries to model
$shift['needed_angeltypes'] = Db::select(' $shift['needed_angeltypes'] = Db::select(
'
SELECT DISTINCT `AngelTypes`.* SELECT DISTINCT `AngelTypes`.*
FROM `ShiftEntry` FROM `ShiftEntry`
JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id` JOIN `AngelTypes` ON `ShiftEntry`.`TID`=`AngelTypes`.`id`
@ -216,7 +221,8 @@ function user_controller()
[$shift['SID']] [$shift['SID']]
); );
foreach ($shift['needed_angeltypes'] as &$needed_angeltype) { foreach ($shift['needed_angeltypes'] as &$needed_angeltype) {
$needed_angeltype['users'] = Db::select(' $needed_angeltype['users'] = Db::select(
'
SELECT `ShiftEntry`.`freeloaded`, `users`.* SELECT `ShiftEntry`.`freeloaded`, `users`.*
FROM `ShiftEntry` FROM `ShiftEntry`
JOIN `users` ON `ShiftEntry`.`UID`=`users`.`id` JOIN `users` ON `ShiftEntry`.`UID`=`users`.`id`
@ -270,7 +276,8 @@ function users_list_controller()
} }
$order_by = 'name'; $order_by = 'name';
if ($request->has('OrderBy') && in_array($request->input('OrderBy'), [ if (
$request->has('OrderBy') && in_array($request->input('OrderBy'), [
'name', 'name',
'first_name', 'first_name',
'last_name', 'last_name',
@ -285,7 +292,8 @@ function users_list_controller()
'planned_arrival_date', 'planned_arrival_date',
'planned_departure_date', 'planned_departure_date',
'last_login_at', 'last_login_at',
])) { ])
) {
$order_by = $request->input('OrderBy'); $order_by = $request->input('OrderBy');
} }

View File

@ -3,6 +3,7 @@
/** /**
* Include legacy code * Include legacy code
*/ */
$includeFiles = [ $includeFiles = [
__DIR__ . '/../includes/sys_auth.php', __DIR__ . '/../includes/sys_auth.php',
__DIR__ . '/../includes/sys_form.php', __DIR__ . '/../includes/sys_form.php',

View File

@ -30,19 +30,19 @@ function mail_shift_change($old_shift, $new_shift)
if ($old_shift['start'] != $new_shift['start']) { if ($old_shift['start'] != $new_shift['start']) {
$message .= sprintf( $message .= sprintf(
__('* Shift Start changed from %s to %s'), __('* Shift Start changed from %s to %s'),
date('Y-m-d H:i', $old_shift['start']), date('Y-m-d H:i', $old_shift['start']),
date('Y-m-d H:i', $new_shift['start']) date('Y-m-d H:i', $new_shift['start'])
) . "\n"; ) . "\n";
$noticeable_changes = true; $noticeable_changes = true;
} }
if ($old_shift['end'] != $new_shift['end']) { if ($old_shift['end'] != $new_shift['end']) {
$message .= sprintf( $message .= sprintf(
__('* Shift End changed from %s to %s'), __('* Shift End changed from %s to %s'),
date('Y-m-d H:i', $old_shift['end']), date('Y-m-d H:i', $old_shift['end']),
date('Y-m-d H:i', $new_shift['end']) date('Y-m-d H:i', $new_shift['end'])
) . "\n"; ) . "\n";
$noticeable_changes = true; $noticeable_changes = true;
} }

View File

@ -58,7 +58,8 @@ function AngelType_delete($angeltype)
*/ */
function AngelType_update($angeltype) function AngelType_update($angeltype)
{ {
Db::update(' Db::update(
'
UPDATE `AngelTypes` SET UPDATE `AngelTypes` SET
`name` = ?, `name` = ?,
`restricted` = ?, `restricted` = ?,
@ -104,7 +105,8 @@ function AngelType_update($angeltype)
*/ */
function AngelType_create($angeltype) function AngelType_create($angeltype)
{ {
Db::insert(' Db::insert(
'
INSERT INTO `AngelTypes` ( INSERT INTO `AngelTypes` (
`name`, `name`,
`restricted`, `restricted`,

View File

@ -18,7 +18,8 @@ use Engelsystem\Database\Db;
*/ */
function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count) function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count)
{ {
Db::insert(' Db::insert(
'
INSERT INTO `NeededAngelTypes` ( `shift_id`, `angel_type_id`, `room_id`, `count`) INSERT INTO `NeededAngelTypes` ( `shift_id`, `angel_type_id`, `room_id`, `count`)
VALUES (?, ?, ?, ?) VALUES (?, ?, ?, ?)
', ',
@ -27,7 +28,8 @@ function NeededAngelType_add($shift_id, $angeltype_id, $room_id, $count)
$angeltype_id, $angeltype_id,
$room_id, $room_id,
$count, $count,
]); ]
);
return Db::getPdo()->lastInsertId(); return Db::getPdo()->lastInsertId();
} }
@ -77,7 +79,8 @@ function NeededAngelTypes_by_room($room_id)
*/ */
function NeededAngelTypes_by_shift($shiftId) function NeededAngelTypes_by_shift($shiftId)
{ {
$needed_angeltypes_source = Db::select(' $needed_angeltypes_source = Db::select(
'
SELECT SELECT
`NeededAngelTypes`.*, `NeededAngelTypes`.*,
`AngelTypes`.`id`, `AngelTypes`.`id`,

View File

@ -29,7 +29,8 @@ function ShiftEntries_freeloaded_count()
*/ */
function ShiftEntries_by_shift($shift_id) function ShiftEntries_by_shift($shift_id)
{ {
return Db::select(' return Db::select(
'
SELECT SELECT
`users`.*, `users`.*,
`ShiftEntry`.`UID`, `ShiftEntry`.`UID`,
@ -60,7 +61,8 @@ function ShiftEntry_create($shift_entry)
$shifttype = ShiftType($shift['shifttype_id']); $shifttype = ShiftType($shift['shifttype_id']);
$room = Room::find($shift['RID']); $room = Room::find($shift['RID']);
$angeltype = AngelType($shift_entry['TID']); $angeltype = AngelType($shift_entry['TID']);
$result = Db::insert(' $result = Db::insert(
'
INSERT INTO `ShiftEntry` ( INSERT INTO `ShiftEntry` (
`SID`, `SID`,
`TID`, `TID`,
@ -101,7 +103,8 @@ function ShiftEntry_create($shift_entry)
*/ */
function ShiftEntry_update($shift_entry) function ShiftEntry_update($shift_entry)
{ {
Db::update(' Db::update(
'
UPDATE `ShiftEntry` UPDATE `ShiftEntry`
SET SET
`Comment` = ?, `Comment` = ?,
@ -167,7 +170,8 @@ function ShiftEntry_delete($shiftEntry)
*/ */
function ShiftEntries_upcoming_for_user($userId) function ShiftEntries_upcoming_for_user($userId)
{ {
return Db::select(' return Db::select(
'
SELECT * SELECT *
FROM `ShiftEntry` FROM `ShiftEntry`
JOIN `Shifts` ON (`Shifts`.`SID` = `ShiftEntry`.`SID`) JOIN `Shifts` ON (`Shifts`.`SID` = `ShiftEntry`.`SID`)
@ -192,7 +196,8 @@ function ShiftEntries_upcoming_for_user($userId)
*/ */
function ShiftEntries_finished_by_user($userId, Carbon $sinceTime = null) function ShiftEntries_finished_by_user($userId, Carbon $sinceTime = null)
{ {
return Db::select(' return Db::select(
'
SELECT * SELECT *
FROM `ShiftEntry` FROM `ShiftEntry`
JOIN `Shifts` ON (`Shifts`.`SID` = `ShiftEntry`.`SID`) JOIN `Shifts` ON (`Shifts`.`SID` = `ShiftEntry`.`SID`)
@ -219,7 +224,8 @@ function ShiftEntries_finished_by_user($userId, Carbon $sinceTime = null)
*/ */
function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id) function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id)
{ {
return Db::select(' return Db::select(
'
SELECT * SELECT *
FROM `ShiftEntry` FROM `ShiftEntry`
WHERE `SID` = ? WHERE `SID` = ?
@ -240,7 +246,8 @@ function ShiftEntries_by_shift_and_angeltype($shift_id, $angeltype_id)
*/ */
function ShiftEntries_freeloaded_by_user($userId) function ShiftEntries_freeloaded_by_user($userId)
{ {
return Db::select(' return Db::select(
'
SELECT * SELECT *
FROM `ShiftEntry` FROM `ShiftEntry`
WHERE `freeloaded` = 1 WHERE `freeloaded` = 1

View File

@ -22,7 +22,8 @@ function ShiftType_delete($shifttype_id)
*/ */
function ShiftType_update($shifttype_id, $name, $angeltype_id, $description) function ShiftType_update($shifttype_id, $name, $angeltype_id, $description)
{ {
Db::update(' Db::update(
'
UPDATE `ShiftTypes` SET UPDATE `ShiftTypes` SET
`name`=?, `name`=?,
`angeltype_id`=?, `angeltype_id`=?,
@ -48,7 +49,8 @@ function ShiftType_update($shifttype_id, $name, $angeltype_id, $description)
*/ */
function ShiftType_create($name, $angeltype_id, $description) function ShiftType_create($name, $angeltype_id, $description)
{ {
Db::insert(' Db::insert(
'
INSERT INTO `ShiftTypes` (`name`, `angeltype_id`, `description`) INSERT INTO `ShiftTypes` (`name`, `angeltype_id`, `description`)
VALUES(?, ?, ?) VALUES(?, ?, ?)
', ',

View File

@ -197,7 +197,8 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
*/ */
function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype) function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
{ {
return Db::selectOne(' return Db::selectOne(
'
SELECT SELECT
`NeededAngelTypes`.*, `NeededAngelTypes`.*,
`Shifts`.`SID`, `Shifts`.`SID`,
@ -245,7 +246,8 @@ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
*/ */
function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter) function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
{ {
$sql = sprintf(' $sql = sprintf(
'
SELECT SELECT
users.*, users.*,
`ShiftEntry`.`UID`, `ShiftEntry`.`UID`,
@ -527,7 +529,8 @@ function Shift_update($shift)
$shift['name'] = ShiftType($shift['shifttype_id'])['name']; $shift['name'] = ShiftType($shift['shifttype_id'])['name'];
mail_shift_change(Shift($shift['SID']), $shift); mail_shift_change(Shift($shift['SID']), $shift);
return Db::update(' return Db::update(
'
UPDATE `Shifts` SET UPDATE `Shifts` SET
`shifttype_id` = ?, `shifttype_id` = ?,
`start` = ?, `start` = ?,
@ -564,7 +567,8 @@ function Shift_update($shift)
*/ */
function Shift_create($shift, $transactionId = null) function Shift_create($shift, $transactionId = null)
{ {
Db::insert(' Db::insert(
'
INSERT INTO `Shifts` ( INSERT INTO `Shifts` (
`shifttype_id`, `shifttype_id`,
`start`, `start`,
@ -607,7 +611,8 @@ function Shift_create($shift, $transactionId = null)
*/ */
function Shifts_by_user($userId, $include_freeload_comments = false) function Shifts_by_user($userId, $include_freeload_comments = false)
{ {
return Db::select(' return Db::select(
'
SELECT SELECT
`rooms`.*, `rooms`.*,
`rooms`.name AS Name, `rooms`.name AS Name,

View File

@ -23,7 +23,7 @@ function stats_currently_working(ShiftsFilter $filter = null)
)) AS `count` )) AS `count`
FROM `Shifts` FROM `Shifts`
WHERE (`end` >= UNIX_TIMESTAMP() AND `start` <= UNIX_TIMESTAMP()) WHERE (`end` >= UNIX_TIMESTAMP() AND `start` <= UNIX_TIMESTAMP())
'. ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') ' . ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '')
); );
return $result['count'] ?: '-'; return $result['count'] ?: '-';
@ -48,7 +48,7 @@ function stats_hours_to_work(ShiftsFilter $filter = null)
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `end` >= UNIX_TIMESTAMP() WHERE `end` >= UNIX_TIMESTAMP()
AND s.shift_id IS NULL AND s.shift_id IS NULL
'. ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . ' ' . ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
UNION ALL UNION ALL
@ -59,7 +59,7 @@ function stats_hours_to_work(ShiftsFilter $filter = null)
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `end` >= UNIX_TIMESTAMP() WHERE `end` >= UNIX_TIMESTAMP()
AND NOT s.shift_id IS NULL AND NOT s.shift_id IS NULL
'. ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . ' ' . ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
) AS `tmp` ) AS `tmp`
' '
); );
@ -102,7 +102,7 @@ function stats_angels_needed_three_hours(ShiftsFilter $filter = null)
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `end` > UNIX_TIMESTAMP() AND `start` < ? WHERE `end` > UNIX_TIMESTAMP() AND `start` < ?
AND s.shift_id IS NULL AND s.shift_id IS NULL
'. ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . ' ' . ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
UNION ALL UNION ALL
@ -129,7 +129,7 @@ function stats_angels_needed_three_hours(ShiftsFilter $filter = null)
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `end` > UNIX_TIMESTAMP() AND `start` < ? WHERE `end` > UNIX_TIMESTAMP() AND `start` < ?
AND NOT s.shift_id IS NULL AND NOT s.shift_id IS NULL
'. ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . ' ' . ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
) AS `tmp`', [ ) AS `tmp`', [
$in3hours, $in3hours,
$in3hours $in3hours
@ -181,7 +181,7 @@ function stats_angels_needed_for_nightshifts(ShiftsFilter $filter = null)
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `end` > ? AND `start` < ? WHERE `end` > ? AND `start` < ?
AND s.shift_id IS NULL AND s.shift_id IS NULL
'. ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . ' ' . ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
UNION ALL UNION ALL
@ -208,7 +208,7 @@ function stats_angels_needed_for_nightshifts(ShiftsFilter $filter = null)
LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id LEFT JOIN schedule_shift AS s on Shifts.SID = s.shift_id
WHERE `end` > ? AND `start` < ? WHERE `end` > ? AND `start` < ?
AND NOT s.shift_id IS NULL AND NOT s.shift_id IS NULL
'. ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . ' ' . ($filter ? 'AND Shifts.RID IN (' . implode(',', $filter->getRooms()) . ')' : '') . '
) AS `tmp`', [ ) AS `tmp`', [
$night_start, $night_start,
$night_end, $night_end,

View File

@ -80,7 +80,8 @@ function User_is_AngelType_supporter($user, $angeltype)
$privileges = privileges_for_user($user->id); $privileges = privileges_for_user($user->id);
return (count(Db::select(' return (count(Db::select(
'
SELECT `id` SELECT `id`
FROM `UserAngelTypes` FROM `UserAngelTypes`
WHERE `user_id`=? WHERE `user_id`=?
@ -88,11 +89,11 @@ function User_is_AngelType_supporter($user, $angeltype)
AND `supporter`=TRUE AND `supporter`=TRUE
LIMIT 1 LIMIT 1
', ',
[ [
$user->id, $user->id,
$angeltype['id'] $angeltype['id']
] ]
)) > 0) )) > 0)
|| in_array('admin_user_angeltypes', $privileges); || in_array('admin_user_angeltypes', $privileges);
} }
@ -194,7 +195,8 @@ function UserAngelType_delete($user_angeltype)
*/ */
function UserAngelType_create($userId, $angeltype) function UserAngelType_create($userId, $angeltype)
{ {
Db::insert(' Db::insert(
'
INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`, `supporter`) INSERT INTO `UserAngelTypes` (`user_id`, `angeltype_id`, `supporter`)
VALUES (?, ?, FALSE) VALUES (?, ?, FALSE)
', ',
@ -233,7 +235,8 @@ function UserAngelType($user_angeltype_id)
*/ */
function UserAngelType_by_User_and_AngelType($userId, $angeltype) function UserAngelType_by_User_and_AngelType($userId, $angeltype)
{ {
$angelType = Db::selectOne(' $angelType = Db::selectOne(
'
SELECT * SELECT *
FROM `UserAngelTypes` FROM `UserAngelTypes`
WHERE `user_id`=? WHERE `user_id`=?
@ -256,7 +259,7 @@ function UserAngelType_by_User_and_AngelType($userId, $angeltype)
* @param bool $onlyConfirmed * @param bool $onlyConfirmed
* @return array[]|null * @return array[]|null
*/ */
function UserAngelTypes_by_User($userId, $onlyConfirmed=false) function UserAngelTypes_by_User($userId, $onlyConfirmed = false)
{ {
return Db::select( return Db::select(
' '

View File

@ -10,7 +10,8 @@ use Engelsystem\Database\Db;
*/ */
function User_groups($userId) function User_groups($userId)
{ {
return Db::select(' return Db::select(
'
SELECT `Groups`.* SELECT `Groups`.*
FROM `UserGroups` FROM `UserGroups`
JOIN `Groups` ON `Groups`.`UID`=`UserGroups`.`group_id` JOIN `Groups` ON `Groups`.`UID`=`UserGroups`.`group_id`

View File

@ -1,8 +1,6 @@
<?php <?php
use Carbon\Carbon; use Carbon\Carbon;
use Engelsystem\Helpers\Shifts;
use Engelsystem\Models\Room;
use Engelsystem\Models\Worklog; use Engelsystem\Models\Worklog;
use Illuminate\Support\Collection; use Illuminate\Support\Collection;

View File

@ -87,7 +87,8 @@ function Users_by_angeltype_inverted($angeltype)
function Users_by_angeltype($angeltype) function Users_by_angeltype($angeltype)
{ {
return User::query() return User::query()
->select('users.*', ->select(
'users.*',
'UserAngelTypes.id AS user_angeltype_id', 'UserAngelTypes.id AS user_angeltype_id',
'UserAngelTypes.confirm_user_id', 'UserAngelTypes.confirm_user_id',
'UserAngelTypes.supporter', 'UserAngelTypes.supporter',
@ -151,13 +152,13 @@ function User_validate_planned_arrival_date($planned_arrival_date)
$teardown = $config->get('teardown_end'); $teardown = $config->get('teardown_end');
/** @var Carbon $buildup */ /** @var Carbon $buildup */
if (!empty($buildup) && Carbon::createFromTimestamp($planned_arrival_date)->lessThan($buildup->setTime(0,0))) { if (!empty($buildup) && Carbon::createFromTimestamp($planned_arrival_date)->lessThan($buildup->setTime(0, 0))) {
// Planned arrival can not be before buildup start date // Planned arrival can not be before buildup start date
return new ValidationResult(false, $buildup->getTimestamp()); return new ValidationResult(false, $buildup->getTimestamp());
} }
/** @var Carbon $teardown */ /** @var Carbon $teardown */
if (!empty($teardown) && Carbon::createFromTimestamp($planned_arrival_date)->greaterThanOrEqualTo($teardown->addDay()->setTime(0,0))) { if (!empty($teardown) && Carbon::createFromTimestamp($planned_arrival_date)->greaterThanOrEqualTo($teardown->addDay()->setTime(0, 0))) {
// Planned arrival can not be after teardown end date // Planned arrival can not be after teardown end date
return new ValidationResult(false, $teardown->getTimestamp()); return new ValidationResult(false, $teardown->getTimestamp());
} }
@ -189,13 +190,13 @@ function User_validate_planned_departure_date($planned_arrival_date, $planned_de
$teardown = $config->get('teardown_end'); $teardown = $config->get('teardown_end');
/** @var Carbon $buildup */ /** @var Carbon $buildup */
if (!empty($buildup) && Carbon::createFromTimestamp($planned_departure_date)->lessThan($buildup->setTime(0,0))) { if (!empty($buildup) && Carbon::createFromTimestamp($planned_departure_date)->lessThan($buildup->setTime(0, 0))) {
// Planned departure can not be before buildup start date // Planned departure can not be before buildup start date
return new ValidationResult(false, $buildup->getTimestamp()); return new ValidationResult(false, $buildup->getTimestamp());
} }
/** @var Carbon $teardown */ /** @var Carbon $teardown */
if (!empty($teardown) && Carbon::createFromTimestamp($planned_departure_date)->greaterThanOrEqualTo($teardown->addDay()->setTime(0,0))) { if (!empty($teardown) && Carbon::createFromTimestamp($planned_departure_date)->greaterThanOrEqualTo($teardown->addDay()->setTime(0, 0))) {
// Planned departure can not be after teardown end date // Planned departure can not be after teardown end date
return new ValidationResult(false, $teardown->getTimestamp()); return new ValidationResult(false, $teardown->getTimestamp());
} }
@ -237,18 +238,18 @@ function User_get_eligable_voucher_count($user)
+ $worklog->count(); + $worklog->count();
$shiftsTime = 0; $shiftsTime = 0;
foreach ($shifts as $shift){ foreach ($shifts as $shift) {
$shiftsTime += ($shift['end'] - $shift['start']) / 60 / 60; $shiftsTime += ($shift['end'] - $shift['start']) / 60 / 60;
} }
foreach ($worklog as $entry){ foreach ($worklog as $entry) {
$shiftsTime += $entry->hours; $shiftsTime += $entry->hours;
} }
$vouchers = $voucher_settings['initial_vouchers']; $vouchers = $voucher_settings['initial_vouchers'];
if($voucher_settings['shifts_per_voucher']){ if ($voucher_settings['shifts_per_voucher']) {
$vouchers += $shifts_done / $voucher_settings['shifts_per_voucher']; $vouchers += $shifts_done / $voucher_settings['shifts_per_voucher'];
} }
if($voucher_settings['hours_per_voucher']){ if ($voucher_settings['hours_per_voucher']) {
$vouchers += $shiftsTime / $voucher_settings['hours_per_voucher']; $vouchers += $shiftsTime / $voucher_settings['hours_per_voucher'];
} }
@ -273,7 +274,8 @@ function User_get_shifts_sum_query()
return 'COALESCE(SUM(`end` - `start`), 0)'; return 'COALESCE(SUM(`end` - `start`), 0)';
} }
return sprintf(' return sprintf(
'
COALESCE(SUM( COALESCE(SUM(
(1 + ( (1 + (
(HOUR(FROM_UNIXTIME(`Shifts`.`end`)) > %1$d AND HOUR(FROM_UNIXTIME(`Shifts`.`end`)) < %2$d) (HOUR(FROM_UNIXTIME(`Shifts`.`end`)) > %1$d AND HOUR(FROM_UNIXTIME(`Shifts`.`end`)) < %2$d)

View File

@ -230,7 +230,9 @@ function admin_active()
} }
$actions[] = form( $actions[] = form(
[form_submit('submit', __('set active'), 'btn-sm', false, 'secondary')], [form_submit('submit', __('set active'), 'btn-sm', false, 'secondary')],
page_link_to('admin_active', $parameters), false, true page_link_to('admin_active', $parameters),
false,
true
); );
} }
if ($usr->state->active) { if ($usr->state->active) {
@ -243,7 +245,9 @@ function admin_active()
} }
$actions[] = form( $actions[] = form(
[form_submit('submit', __('remove active'), 'btn-sm', false, 'secondary')], [form_submit('submit', __('remove active'), 'btn-sm', false, 'secondary')],
page_link_to('admin_active', $parametersRemove), false, true page_link_to('admin_active', $parametersRemove),
false,
true
); );
} }
if (!$usr->state->got_shirt) { if (!$usr->state->got_shirt) {
@ -256,7 +260,9 @@ function admin_active()
} }
$actions[] = form( $actions[] = form(
[form_submit('submit', __('got t-shirt'), 'btn-sm', false, 'secondary')], [form_submit('submit', __('got t-shirt'), 'btn-sm', false, 'secondary')],
page_link_to('admin_active', $parametersShirt), false, true page_link_to('admin_active', $parametersShirt),
false,
true
); );
} }
if ($usr->state->got_shirt) { if ($usr->state->got_shirt) {
@ -269,7 +275,9 @@ function admin_active()
} }
$actions[] = form( $actions[] = form(
[form_submit('submit', __('remove t-shirt'), 'btn-sm', false, 'secondary')], [form_submit('submit', __('remove t-shirt'), 'btn-sm', false, 'secondary')],
page_link_to('admin_active', $parameters), false, true page_link_to('admin_active', $parameters),
false,
true
); );
} }

View File

@ -39,8 +39,10 @@ function admin_groups()
'name' => $group['Name'], 'name' => $group['Name'],
'privileges' => join(', ', $privileges_html), 'privileges' => join(', ', $privileges_html),
'actions' => button( 'actions' => button(
page_link_to('admin_groups', page_link_to(
['action' => 'edit', 'id' => $group['UID']]), 'admin_groups',
['action' => 'edit', 'id' => $group['UID']]
),
__('edit'), __('edit'),
'btn-sm' 'btn-sm'
) )

View File

@ -240,11 +240,11 @@ function admin_shifts()
$day = Carbon::createTimestampFromDatetime(date('Y-m-d', $start) . ' 00:00'); $day = Carbon::createTimestampFromDatetime(date('Y-m-d', $start) . ' 00:00');
do { do {
// Alle Schichtwechselstunden durchgehen // Alle Schichtwechselstunden durchgehen
for($i = 0; $i < count($change_hours); $i++) { for ($i = 0; $i < count($change_hours); $i++) {
$start_hour = $change_hours[$i]; $start_hour = $change_hours[$i];
if ($i < count($change_hours) - 1) { if ($i < count($change_hours) - 1) {
// Normales Intervall zwischen zwei Schichtwechselstunden // Normales Intervall zwischen zwei Schichtwechselstunden
$end_hour = $change_hours[$i+1]; $end_hour = $change_hours[$i + 1];
} elseif ($shift_over_midnight) { } elseif ($shift_over_midnight) {
// Letzte Schichtwechselstunde: Wenn eine 24h Abdeckung gewünscht ist, hier die erste Schichtwechselstunde als Ende ensetzen // Letzte Schichtwechselstunde: Wenn eine 24h Abdeckung gewünscht ist, hier die erste Schichtwechselstunde als Ende ensetzen
$end_hour = $change_hours[0]; $end_hour = $change_hours[0];
@ -294,7 +294,7 @@ function admin_shifts()
} }
$day = Carbon::createTimestampFromDatetime(date('Y-m-d', $day + 36 * 60 * 60) . ' 00:00'); $day = Carbon::createTimestampFromDatetime(date('Y-m-d', $day + 36 * 60 * 60) . ' 00:00');
} while($day <= $end_day); } while ($day <= $end_day);
usort($shifts, function ($a, $b) { usort($shifts, function ($a, $b) {
return $a['start'] < $b['start'] ? -1 : 1; return $a['start'] < $b['start'] ? -1 : 1;
@ -388,7 +388,8 @@ function admin_shifts()
LIMIT 1', [$type_id]); LIMIT 1', [$type_id]);
if (!empty($angel_type_source)) { if (!empty($angel_type_source)) {
Db::insert(' Db::insert(
'
INSERT INTO `NeededAngelTypes` (`shift_id`, `angel_type_id`, `count`) INSERT INTO `NeededAngelTypes` (`shift_id`, `angel_type_id`, `count`)
VALUES (?, ?, ?) VALUES (?, ?, ?)
', ',
@ -421,10 +422,10 @@ function admin_shifts()
$angel_types = ''; $angel_types = '';
foreach ($types as $type) { foreach ($types as $type) {
$angel_types .= '<div class="col-md-4">' . form_spinner( $angel_types .= '<div class="col-md-4">' . form_spinner(
'type_' . $type['id'], 'type_' . $type['id'],
$type['name'], $type['name'],
$needed_angel_types[$type['id']] $needed_angel_types[$type['id']]
) )
. '</div>'; . '</div>';
} }
@ -433,10 +434,11 @@ function admin_shifts()
'<a href="%s">%s</a>', '<a href="%s">%s</a>',
page_link_to('admin_shifts_history'), page_link_to('admin_shifts_history'),
icon('clock-history') icon('clock-history')
), [ ),
[
msg(), msg(),
form([ form([
div('row',[ div('row', [
div('col-md-6', [ div('col-md-6', [
form_select('shifttype_id', __('Shifttype'), $shifttypes, $shifttype_id), form_select('shifttype_id', __('Shifttype'), $shifttypes, $shifttype_id),
form_text('title', __('Title'), $title), form_text('title', __('Title'), $title),
@ -501,7 +503,8 @@ function admin_shifts()
]), ]),
form_submit('preview', icon('search') . __('Preview')) form_submit('preview', icon('search') . __('Preview'))
]) ])
]); ]
);
} }
/** /**

View File

@ -67,7 +67,8 @@ function admin_user()
. html_select_key( . html_select_key(
'size', 'size',
'eSize', 'eSize',
$tshirt_sizes, $user_source->personalData->shirt_size, $tshirt_sizes,
$user_source->personalData->shirt_size,
__('Please select...') __('Please select...')
) )
. '</td></tr>' . "\n"; . '</td></tr>' . "\n";
@ -151,7 +152,8 @@ function admin_user()
$html .= form_csrf(); $html .= form_csrf();
$html .= '<table>'; $html .= '<table>';
$groups = Db::select(' $groups = Db::select(
'
SELECT * SELECT *
FROM `Groups` FROM `Groups`
LEFT OUTER JOIN `UserGroups` ON ( LEFT OUTER JOIN `UserGroups` ON (
@ -205,7 +207,8 @@ function admin_user()
|| ($my_highest_group['group_id'] <= $his_highest_group['group_id']) || ($my_highest_group['group_id'] <= $his_highest_group['group_id'])
) )
) { ) {
$groups_source = Db::select(' $groups_source = Db::select(
'
SELECT * SELECT *
FROM `Groups` FROM `Groups`
LEFT OUTER JOIN `UserGroups` ON ( LEFT OUTER JOIN `UserGroups` ON (

View File

@ -107,8 +107,10 @@ function guest_register()
if (!$nickValidation->isValid()) { if (!$nickValidation->isValid()) {
$valid = false; $valid = false;
$msg .= error(sprintf(__('Please enter a valid nick.') . ' ' . __('Use up to 24 letters, numbers, connecting punctuations or spaces for your nickname.'), $msg .= error(sprintf(
$nick), true); __('Please enter a valid nick.') . ' ' . __('Use up to 24 letters, numbers, connecting punctuations or spaces for your nickname.'),
$nick
), true);
} }
if (User::whereName($nick)->count() > 0) { if (User::whereName($nick)->count() > 0) {
$valid = false; $valid = false;
@ -164,7 +166,7 @@ function guest_register()
$valid = false; $valid = false;
$msg .= error(__('Your passwords don\'t match.'), true); $msg .= error(__('Your passwords don\'t match.'), true);
} }
} else if ($enable_password) { } elseif ($enable_password) {
$valid = false; $valid = false;
$msg .= error(sprintf( $msg .= error(sprintf(
__('Your password is too short (please use at least %s characters).'), __('Your password is too short (please use at least %s characters).'),
@ -378,8 +380,10 @@ function guest_register()
24, 24,
'nickname' 'nickname'
), ),
form_info('', form_info(
__('Use up to 24 letters, numbers, connecting punctuations or spaces for your nickname.')) '',
__('Use up to 24 letters, numbers, connecting punctuations or spaces for your nickname.')
)
]), ]),
$enable_pronoun ? div('col', [ $enable_pronoun ? div('col', [
@ -451,7 +455,9 @@ function guest_register()
form_date( form_date(
'planned_arrival_date', 'planned_arrival_date',
__('Planned date of arrival') . ' ' . entry_required(), __('Planned date of arrival') . ' ' . entry_required(),
$planned_arrival_date, $buildup_start_date, $teardown_end_date $planned_arrival_date,
$buildup_start_date,
$teardown_end_date
) )
]) : '', ]) : '',
]), ]),
@ -462,9 +468,13 @@ function guest_register()
]) : '', ]) : '',
div('col', [ div('col', [
$enable_tshirt_size ? form_select('tshirt_size', $enable_tshirt_size ? form_select(
'tshirt_size',
__('Shirt size') . ' ' . entry_required(), __('Shirt size') . ' ' . entry_required(),
$tshirt_sizes, $tshirt_size, __('Please select...')) : '' $tshirt_sizes,
$tshirt_size,
__('Please select...')
) : ''
]), ]),
]), ]),

View File

@ -74,10 +74,10 @@ function make_atom_entry_from_news(News $news)
<title>' . htmlspecialchars($news->title) . '</title> <title>' . htmlspecialchars($news->title) . '</title>
<link href="' . page_link_to('news/' . $news->id) . '"/> <link href="' . page_link_to('news/' . $news->id) . '"/>
<id>' . preg_replace( <id>' . preg_replace(
'#^https?://#', '#^https?://#',
'', '',
page_link_to('news/' . $news->id) page_link_to('news/' . $news->id)
) . '</id> ) . '</id>
<updated>' . $news->updated_at->format('Y-m-d\TH:i:sP') . '</updated> <updated>' . $news->updated_at->format('Y-m-d\TH:i:sP') . '</updated>
<summary type="html">' . htmlspecialchars($news->text) . '</summary> <summary type="html">' . htmlspecialchars($news->text) . '</summary>
</entry>' . "\n"; </entry>' . "\n";

View File

@ -48,7 +48,8 @@ function user_myshifts()
]); ]);
} elseif ($request->has('edit') && preg_match('/^\d+$/', $request->input('edit'))) { } elseif ($request->has('edit') && preg_match('/^\d+$/', $request->input('edit'))) {
$shift_entry_id = $request->input('edit'); $shift_entry_id = $request->input('edit');
$shift = Db::selectOne(' $shift = Db::selectOne(
'
SELECT SELECT
`ShiftEntry`.`freeloaded`, `ShiftEntry`.`freeloaded`,
`ShiftEntry`.`freeload_comment`, `ShiftEntry`.`freeload_comment`,

View File

@ -156,7 +156,8 @@ function load_types()
error(__('The administration has not configured any angeltypes yet - or you are not subscribed to any angeltype.')); error(__('The administration has not configured any angeltypes yet - or you are not subscribed to any angeltype.'));
throw_redirect(page_link_to('/')); throw_redirect(page_link_to('/'));
} }
$types = Db::select(' $types = Db::select(
'
SELECT SELECT
`AngelTypes`.`id`, `AngelTypes`.`id`,
`AngelTypes`.`name`, `AngelTypes`.`name`,
@ -318,7 +319,7 @@ function view_user_shifts()
function ical_hint() function ical_hint()
{ {
$user = auth()->user(); $user = auth()->user();
if(!auth()->can('ical')) { if (!auth()->can('ical')) {
return ''; return '';
} }

View File

@ -261,7 +261,7 @@ function strip_item($item)
function check_email($email) function check_email($email)
{ {
// Convert the domain part from idn to ascii // Convert the domain part from idn to ascii
if(substr_count($email, '@') == 1) { if (substr_count($email, '@') == 1) {
list($name, $domain) = explode('@', $email); list($name, $domain) = explode('@', $email);
$domain = idn_to_ascii($domain, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46); $domain = idn_to_ascii($domain, IDNA_DEFAULT, INTL_IDNA_VARIANT_UTS46);
$email = $name . '@' . $domain; $email = $name . '@' . $domain;

View File

@ -52,7 +52,7 @@ function tabs($tabs, $selected = 0)
$id = null; $id = null;
} }
$tab_header[] = '<li role="presentation" class="nav-item"> $tab_header[] = '<li role="presentation" class="nav-item">
<a href="'. $href . '" class="nav-link' . ($active ? ' active' : '') . '" role="tab"' <a href="' . $href . '" class="nav-link' . ($active ? ' active' : '') . '" role="tab"'
. ($id ? ' id="' . $id . '-tab"' : '') . ($id ? ' id="' . $id . '-tab"' : '')
. ($id ? ' aria-controls="' . $id . '" data-bs-target="#' . $id . '" data-bs-toggle="tab" role="tab"' : '') . ($id ? ' aria-controls="' . $id . '" data-bs-target="#' . $id . '" data-bs-toggle="tab" role="tab"' : '')
. ($id && $active ? ' aria-selected="true"' : ' aria-selected="false"') . ($id && $active ? ' aria-selected="true"' : ' aria-selected="false"')
@ -221,7 +221,7 @@ function toolbar_dropdown_item_divider(): string
*/ */
function toolbar_dropdown($icon, $label, $submenu, $class = ''): string function toolbar_dropdown($icon, $label, $submenu, $class = ''): string
{ {
$template =<<<EOT $template = <<<EOT
<li class="nav-item dropdown"> <li class="nav-item dropdown">
<a class="nav-link dropdown-toggle {class}" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false"> <a class="nav-link dropdown-toggle {class}" href="#" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
{icon} {label} {icon} {label}

View File

@ -97,14 +97,17 @@ function AngelType_edit_view($angeltype, $supporter_mode)
? form_info(__('No Self Sign Up allowed'), $angeltype['no_self_signup'] ? __('Yes') : __('No')) ? form_info(__('No Self Sign Up allowed'), $angeltype['no_self_signup'] ? __('Yes') : __('No'))
: form_checkbox('no_self_signup', __('No Self Sign Up allowed'), $angeltype['no_self_signup']), : form_checkbox('no_self_signup', __('No Self Sign Up allowed'), $angeltype['no_self_signup']),
$supporter_mode $supporter_mode
? form_info(__('Requires driver license'), ? form_info(
$angeltype['requires_driver_license'] __('Requires driver license'),
$angeltype['requires_driver_license']
? __('Yes') ? __('Yes')
: __('No')) : __('No')
)
: form_checkbox( : form_checkbox(
'requires_driver_license', 'requires_driver_license',
__('Requires driver license'), __('Requires driver license'),
$angeltype['requires_driver_license']), $angeltype['requires_driver_license']
),
$supporter_mode $supporter_mode
? form_info(__('Show on dashboard'), $angeltype['show_on_dashboard'] ? __('Yes') : __('No')) ? form_info(__('Show on dashboard'), $angeltype['show_on_dashboard'] ? __('Yes') : __('No'))
: form_checkbox('show_on_dashboard', __('Show on dashboard'), $angeltype['show_on_dashboard']), : form_checkbox('show_on_dashboard', __('Show on dashboard'), $angeltype['show_on_dashboard']),
@ -256,12 +259,15 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a
if ($admin_user_angeltypes) { if ($admin_user_angeltypes) {
$member['actions'] = table_buttons([ $member['actions'] = table_buttons([
$admin_angeltypes $admin_angeltypes
? button(page_link_to('user_angeltypes', [ ? button(
'action' => 'update', page_link_to('user_angeltypes', [
'user_angeltype_id' => $member['user_angeltype_id'], 'action' => 'update',
'supporter' => 1 'user_angeltype_id' => $member['user_angeltype_id'],
]), 'supporter' => 1
__('Add supporter rights'), 'btn-sm') ]),
__('Add supporter rights'),
'btn-sm'
)
: '', : '',
button( button(
page_link_to('user_angeltypes', [ page_link_to('user_angeltypes', [

View File

@ -226,14 +226,14 @@ class ShiftCalendarRenderer
return div('tick day'); return div('tick day');
} }
return div('tick day', [ return div('tick day', [
date(__('m-d'), $time) .'<br>'.date(__('H:i'), $time) date(__('m-d'), $time) . '<br>' . date(__('H:i'), $time)
]); ]);
} elseif ($time % (60 * 60) == 0) { } elseif ($time % (60 * 60) == 0) {
if (!$label) { if (!$label) {
return div('tick hour'); return div('tick hour');
} }
return div('tick hour', [ return div('tick hour', [
date(__('m-d'), $time) .'<br>'.date(__('H:i'), $time) date(__('m-d'), $time) . '<br>' . date(__('H:i'), $time)
]); ]);
} }
return div('tick'); return div('tick');
@ -276,9 +276,9 @@ class ShiftCalendarRenderer
} }
} }
return ShiftCalendarRenderer::SECONDS_PER_ROW * floor( return ShiftCalendarRenderer::SECONDS_PER_ROW * floor(
($start_time - ShiftCalendarRenderer::TIME_MARGIN) ($start_time - ShiftCalendarRenderer::TIME_MARGIN)
/ ShiftCalendarRenderer::SECONDS_PER_ROW / ShiftCalendarRenderer::SECONDS_PER_ROW
); );
} }
/** /**
@ -295,9 +295,9 @@ class ShiftCalendarRenderer
} }
return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil( return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil(
($end_time + ShiftCalendarRenderer::TIME_MARGIN) ($end_time + ShiftCalendarRenderer::TIME_MARGIN)
/ ShiftCalendarRenderer::SECONDS_PER_ROW / ShiftCalendarRenderer::SECONDS_PER_ROW
); );
} }
/** /**

View File

@ -136,7 +136,8 @@ class ShiftCalendarShiftRenderer
if (auth()->can('user_shifts_admin')) { if (auth()->can('user_shifts_admin')) {
$html .= '<li class="list-group-item d-flex align-items-center ' . $this->classBg() . '">'; $html .= '<li class="list-group-item d-flex align-items-center ' . $this->classBg() . '">';
$html .= button(shift_entry_create_link_admin($shift), $html .= button(
shift_entry_create_link_admin($shift),
icon('plus-lg') . __('Add more angels'), icon('plus-lg') . __('Add more angels'),
'btn-sm' 'btn-sm'
); );
@ -195,7 +196,8 @@ class ShiftCalendarShiftRenderer
. '</a> ' . '</a> '
. button( . button(
shift_entry_create_link($shift, $angeltype), shift_entry_create_link($shift, $angeltype),
__('Sign up'), 'btn-sm btn-primary text-nowrap d-print-none' __('Sign up'),
'btn-sm btn-primary text-nowrap d-print-none'
); );
break; break;

View File

@ -93,7 +93,8 @@ function ShiftEntry_create_view_admin($shift, Room $room, $angeltype, $angeltype
form_select('user_id', __('User'), $users_select, $signup_user->id), form_select('user_id', __('User'), $users_select, $signup_user->id),
form_submit('submit', icon('check-lg') . __('Save')) form_submit('submit', icon('check-lg') . __('Save'))
]) ])
]); ]
);
} }
/** /**
@ -108,17 +109,21 @@ function ShiftEntry_create_view_admin($shift, Room $room, $angeltype, $angeltype
*/ */
function ShiftEntry_create_view_supporter($shift, Room $room, $angeltype, $signup_user, $users_select) function ShiftEntry_create_view_supporter($shift, Room $room, $angeltype, $signup_user, $users_select)
{ {
return page_with_title(ShiftEntry_create_title() . ': ' . $shift['name'] return page_with_title(
ShiftEntry_create_title() . ': ' . $shift['name']
. ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>',
[ [
Shift_view_header($shift, $room), Shift_view_header($shift, $room),
info(sprintf(__('Do you want to sign up the following user for this shift as %s?'), info(sprintf(
AngelType_name_render($angeltype)), true), __('Do you want to sign up the following user for this shift as %s?'),
AngelType_name_render($angeltype)
), true),
form([ form([
form_select('user_id', __('User'), $users_select, $signup_user->id), form_select('user_id', __('User'), $users_select, $signup_user->id),
form_submit('submit', icon('check-lg') . __('Save')) form_submit('submit', icon('check-lg') . __('Save'))
]) ])
]); ]
);
} }
/** /**
@ -132,7 +137,8 @@ function ShiftEntry_create_view_supporter($shift, Room $room, $angeltype, $signu
*/ */
function ShiftEntry_create_view_user($shift, Room $room, $angeltype, $comment) function ShiftEntry_create_view_user($shift, Room $room, $angeltype, $comment)
{ {
return page_with_title(ShiftEntry_create_title() . ': ' . $shift['name'] return page_with_title(
ShiftEntry_create_title() . ': ' . $shift['name']
. ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>',
[ [
Shift_view_header($shift, $room), Shift_view_header($shift, $room),
@ -141,7 +147,8 @@ function ShiftEntry_create_view_user($shift, Room $room, $angeltype, $comment)
form_textarea('comment', __('Comment (for your eyes only):'), $comment), form_textarea('comment', __('Comment (for your eyes only):'), $comment),
form_submit('submit', icon('check-lg') . __('Save')) form_submit('submit', icon('check-lg') . __('Save'))
]) ])
]); ]
);
} }
/** /**

View File

@ -93,8 +93,10 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null)
} elseif (empty($user_angeltype)) { } elseif (empty($user_angeltype)) {
return button( return button(
page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]), page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
sprintf(__('Become %s'), sprintf(
$angeltype['name']) __('Become %s'),
$angeltype['name']
)
); );
} }
return ''; return '';
@ -284,10 +286,10 @@ function shift_length($shift)
{ {
$length = floor(($shift['end'] - $shift['start']) / (60 * 60)) . ':'; $length = floor(($shift['end'] - $shift['start']) / (60 * 60)) . ':';
$length .= str_pad( $length .= str_pad(
(($shift['end'] - $shift['start']) % (60 * 60)) / 60, (($shift['end'] - $shift['start']) % (60 * 60)) / 60,
2, 2,
'0', '0',
STR_PAD_LEFT STR_PAD_LEFT
) . 'h'; ) . 'h';
return $length; return $length;
} }

View File

@ -21,7 +21,10 @@ class UserHintsRenderer
$icon = $this->important ? 'exclamation-triangle' : 'info-circle'; $icon = $this->important ? 'exclamation-triangle' : 'info-circle';
return toolbar_popover( return toolbar_popover(
$icon . ' text-white', '', $this->hints, 'bg-' . $hint_class $icon . ' text-white',
'',
$this->hints,
'bg-' . $hint_class
); );
} }

View File

@ -357,7 +357,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) {
@ -579,8 +579,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) . ' ' . htmlspecialchars($user_source->personalData->last_name $user_source->personalData->first_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(
@ -709,9 +709,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() : ''
] ]