Manually migrate /includes code to be phpcs compliant

This commit is contained in:
Michael Weimann 2022-10-18 19:30:36 +02:00
parent f7d499b362
commit 88c727bf8e
No known key found for this signature in database
GPG Key ID: 34F0524D4DA694A1
8 changed files with 32 additions and 46 deletions

View File

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

View File

@ -7,4 +7,6 @@ if (!is_readable(__DIR__ . '/../vendor/autoload.php')) {
}
// Include composer autoloader
// phpcs:disable SlevomatCodingStandard.Variables.UnusedVariable.UnusedVariable
$loader = require __DIR__ . '/../vendor/autoload.php';
// phpcs:enable

View File

@ -46,7 +46,6 @@ function shift_edit_link($shift)
*/
function shift_edit_controller()
{
$msg = '';
$valid = true;
$request = request();
@ -105,33 +104,33 @@ function shift_edit_controller()
$rid = $request->input('rid');
} else {
$valid = false;
$msg .= error(__('Please select a room.'), true);
error(__('Please select a room.'), true);
}
if ($request->has('shifttype_id') && isset($shifttypes[$request->input('shifttype_id')])) {
$shifttype_id = $request->input('shifttype_id');
} else {
$valid = false;
$msg .= error(__('Please select a shifttype.'), true);
error(__('Please select a shifttype.'), true);
}
if ($request->has('start') && $tmp = parse_date('Y-m-d H:i', $request->input('start'))) {
$start = $tmp;
} else {
$valid = false;
$msg .= error(__('Please enter a valid starting time for the shifts.'), true);
error(__('Please enter a valid starting time for the shifts.'), true);
}
if ($request->has('end') && $tmp = parse_date('Y-m-d H:i', $request->input('end'))) {
$end = $tmp;
} else {
$valid = false;
$msg .= error(__('Please enter a valid ending time for the shifts.'), true);
error(__('Please enter a valid ending time for the shifts.'), true);
}
if ($start >= $end) {
$valid = false;
$msg .= error(__('The ending time has to be after the starting time.'), true);
error(__('The ending time has to be after the starting time.'), true);
}
foreach ($needed_angel_types as $needed_angeltype_id => $count) {
@ -143,7 +142,7 @@ function shift_edit_controller()
$needed_angel_types[$needed_angeltype_id] = trim($request->input($queryKey));
} else {
$valid = false;
$msg .= error(sprintf(
error(sprintf(
__('Please check your input for needed angels of type %s.'),
$angeltypes[$needed_angeltype_id]
), true);
@ -351,6 +350,7 @@ function shifts_controller()
/** @noinspection PhpMissingBreakStatementInspection */
case 'next':
shift_next_controller();
// fall through
default:
throw_redirect(page_link_to('/'));
}

View File

@ -11,47 +11,47 @@ class ShiftSignupState
/**
* Shift has free places
*/
const FREE = 'FREE';
public const FREE = 'FREE';
/**
* Shift collides with users shifts
*/
const COLLIDES = 'COLLIDES';
public const COLLIDES = 'COLLIDES';
/**
* User cannot join because of a restricted angeltype or user is not in the angeltype
*/
const ANGELTYPE = 'ANGELTYPE';
public const ANGELTYPE = 'ANGELTYPE';
/**
* Shift is full
*/
const OCCUPIED = 'OCCUPIED';
public const OCCUPIED = 'OCCUPIED';
/**
* User is admin and can do what he wants.
*/
const ADMIN = 'ADMIN';
public const ADMIN = 'ADMIN';
/**
* Shift has already ended, no signup
*/
const SHIFT_ENDED = 'SHIFT_ENDED';
public const SHIFT_ENDED = 'SHIFT_ENDED';
/**
* Shift is not available yet
*/
const NOT_YET = 'NOT_YET';
public const NOT_YET = 'NOT_YET';
/**
* User is already signed up
*/
const SIGNED_UP = 'SIGNED_UP';
public const SIGNED_UP = 'SIGNED_UP';
/**
* User has to be arrived
*/
const NOT_ARRIVED = 'NOT_ARRIVED';
public const NOT_ARRIVED = 'NOT_ARRIVED';
/** @var string */
private $state;

View File

@ -12,12 +12,12 @@ class ShiftsFilter
/**
* Shift is completely full.
*/
const FILLED_FILLED = 1;
public const FILLED_FILLED = 1;
/**
* Shift has some free slots.
*/
const FILLED_FREE = 0;
public const FILLED_FREE = 0;
/**
* Has the user "user shifts admin" privilege?

View File

@ -77,7 +77,6 @@ function admin_groups()
)
ORDER BY `Privileges`.`name`
', [$group_id]);
$privileges_html = '';
$privileges_form = [];
foreach ($privileges as $privilege) {
$privileges_form[] = form_checkbox(
@ -87,17 +86,6 @@ function admin_groups()
$privilege['id'],
'privilege-' . $privilege['name']
);
$privileges_html .= sprintf(
'<tr>'
. '<td><input type="checkbox" name="privileges[]" value="%s" %s /></td>'
. '<td>%s</td>'
. '<td>%s</td>'
. '</tr>',
$privilege['id'],
($privilege['group_id'] != '' ? 'checked="checked"' : ''),
$privilege['name'],
$privilege['desc']
);
}
$privileges_form[] = form_submit('submit', __('Save'));

View File

@ -126,7 +126,7 @@ function admin_user()
$html .= '<hr />';
$my_highest_group = Db::selectOne(
$my_highest_group = DB::selectOne(
'SELECT group_id FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id` LIMIT 1',
[$user->id]
);
@ -134,7 +134,7 @@ function admin_user()
$my_highest_group = $my_highest_group['group_id'];
}
$his_highest_group = Db::selectOne(
$his_highest_group = DB::selectOne(
'SELECT `group_id` FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id` LIMIT 1',
[$user_id]
);
@ -152,7 +152,7 @@ function admin_user()
$html .= form_csrf();
$html .= '<table>';
$groups = Db::select(
$groups = DB::select(
'
SELECT *
FROM `Groups`
@ -191,11 +191,11 @@ function admin_user()
switch ($request->input('action')) {
case 'save_groups':
if ($user_id != $user->id || auth()->can('admin_groups')) {
$my_highest_group = Db::selectOne(
$my_highest_group = DB::selectOne(
'SELECT * FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id`',
[$user->id]
);
$his_highest_group = Db::selectOne(
$his_highest_group = DB::selectOne(
'SELECT * FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id`',
[$user_id]
);
@ -207,7 +207,7 @@ function admin_user()
|| ($my_highest_group['group_id'] <= $his_highest_group['group_id'])
)
) {
$groups_source = Db::select(
$groups_source = DB::select(
'
SELECT *
FROM `Groups`
@ -235,11 +235,11 @@ function admin_user()
$groupsRequest = [];
}
Db::delete('DELETE FROM `UserGroups` WHERE `uid`=?', [$user_id]);
DB::delete('DELETE FROM `UserGroups` WHERE `uid`=?', [$user_id]);
$user_groups_info = [];
foreach ($groupsRequest as $group) {
if (in_array($group, $grouplist)) {
Db::insert(
DB::insert(
'INSERT INTO `UserGroups` (`uid`, `group_id`) VALUES (?, ?)',
[$user_id, $group]
);

View File

@ -9,23 +9,23 @@ class ShiftCalendarRenderer
/**
* 15m * 60s/m = 900s
*/
const SECONDS_PER_ROW = 900;
public const SECONDS_PER_ROW = 900;
/**
* Height of a block in pixel.
* Do not change - corresponds with theme/css
*/
const BLOCK_HEIGHT = 30;
public const BLOCK_HEIGHT = 30;
/**
* Distance between two shifts in pixels
*/
const MARGIN = 5;
public const MARGIN = 5;
/**
* Seconds added to the start and end time
*/
const TIME_MARGIN = 1800;
public const TIME_MARGIN = 1800;
/** @var array */
private $lanes;