Manually migrate /includes code to be phpcs compliant
This commit is contained in:
parent
f7d499b362
commit
88c727bf8e
|
@ -3,10 +3,6 @@
|
||||||
use Engelsystem\Application;
|
use Engelsystem\Application;
|
||||||
use Engelsystem\Config\Config;
|
use Engelsystem\Config\Config;
|
||||||
|
|
||||||
/**
|
|
||||||
* Include the autoloader
|
|
||||||
*/
|
|
||||||
|
|
||||||
require_once __DIR__ . '/autoload.php';
|
require_once __DIR__ . '/autoload.php';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -7,4 +7,6 @@ if (!is_readable(__DIR__ . '/../vendor/autoload.php')) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include composer autoloader
|
// Include composer autoloader
|
||||||
|
// phpcs:disable SlevomatCodingStandard.Variables.UnusedVariable.UnusedVariable
|
||||||
$loader = require __DIR__ . '/../vendor/autoload.php';
|
$loader = require __DIR__ . '/../vendor/autoload.php';
|
||||||
|
// phpcs:enable
|
||||||
|
|
|
@ -46,7 +46,6 @@ function shift_edit_link($shift)
|
||||||
*/
|
*/
|
||||||
function shift_edit_controller()
|
function shift_edit_controller()
|
||||||
{
|
{
|
||||||
$msg = '';
|
|
||||||
$valid = true;
|
$valid = true;
|
||||||
$request = request();
|
$request = request();
|
||||||
|
|
||||||
|
@ -105,33 +104,33 @@ function shift_edit_controller()
|
||||||
$rid = $request->input('rid');
|
$rid = $request->input('rid');
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$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')])) {
|
if ($request->has('shifttype_id') && isset($shifttypes[$request->input('shifttype_id')])) {
|
||||||
$shifttype_id = $request->input('shifttype_id');
|
$shifttype_id = $request->input('shifttype_id');
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$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'))) {
|
if ($request->has('start') && $tmp = parse_date('Y-m-d H:i', $request->input('start'))) {
|
||||||
$start = $tmp;
|
$start = $tmp;
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$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'))) {
|
if ($request->has('end') && $tmp = parse_date('Y-m-d H:i', $request->input('end'))) {
|
||||||
$end = $tmp;
|
$end = $tmp;
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$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) {
|
if ($start >= $end) {
|
||||||
$valid = false;
|
$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) {
|
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));
|
$needed_angel_types[$needed_angeltype_id] = trim($request->input($queryKey));
|
||||||
} else {
|
} else {
|
||||||
$valid = false;
|
$valid = false;
|
||||||
$msg .= error(sprintf(
|
error(sprintf(
|
||||||
__('Please check your input for needed angels of type %s.'),
|
__('Please check your input for needed angels of type %s.'),
|
||||||
$angeltypes[$needed_angeltype_id]
|
$angeltypes[$needed_angeltype_id]
|
||||||
), true);
|
), true);
|
||||||
|
@ -351,6 +350,7 @@ function shifts_controller()
|
||||||
/** @noinspection PhpMissingBreakStatementInspection */
|
/** @noinspection PhpMissingBreakStatementInspection */
|
||||||
case 'next':
|
case 'next':
|
||||||
shift_next_controller();
|
shift_next_controller();
|
||||||
|
// fall through
|
||||||
default:
|
default:
|
||||||
throw_redirect(page_link_to('/'));
|
throw_redirect(page_link_to('/'));
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,47 +11,47 @@ class ShiftSignupState
|
||||||
/**
|
/**
|
||||||
* Shift has free places
|
* Shift has free places
|
||||||
*/
|
*/
|
||||||
const FREE = 'FREE';
|
public const FREE = 'FREE';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shift collides with users shifts
|
* 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
|
* 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
|
* Shift is full
|
||||||
*/
|
*/
|
||||||
const OCCUPIED = 'OCCUPIED';
|
public const OCCUPIED = 'OCCUPIED';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User is admin and can do what he wants.
|
* User is admin and can do what he wants.
|
||||||
*/
|
*/
|
||||||
const ADMIN = 'ADMIN';
|
public const ADMIN = 'ADMIN';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shift has already ended, no signup
|
* Shift has already ended, no signup
|
||||||
*/
|
*/
|
||||||
const SHIFT_ENDED = 'SHIFT_ENDED';
|
public const SHIFT_ENDED = 'SHIFT_ENDED';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shift is not available yet
|
* Shift is not available yet
|
||||||
*/
|
*/
|
||||||
const NOT_YET = 'NOT_YET';
|
public const NOT_YET = 'NOT_YET';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User is already signed up
|
* User is already signed up
|
||||||
*/
|
*/
|
||||||
const SIGNED_UP = 'SIGNED_UP';
|
public const SIGNED_UP = 'SIGNED_UP';
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* User has to be arrived
|
* User has to be arrived
|
||||||
*/
|
*/
|
||||||
const NOT_ARRIVED = 'NOT_ARRIVED';
|
public const NOT_ARRIVED = 'NOT_ARRIVED';
|
||||||
|
|
||||||
/** @var string */
|
/** @var string */
|
||||||
private $state;
|
private $state;
|
||||||
|
|
|
@ -12,12 +12,12 @@ class ShiftsFilter
|
||||||
/**
|
/**
|
||||||
* Shift is completely full.
|
* Shift is completely full.
|
||||||
*/
|
*/
|
||||||
const FILLED_FILLED = 1;
|
public const FILLED_FILLED = 1;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shift has some free slots.
|
* Shift has some free slots.
|
||||||
*/
|
*/
|
||||||
const FILLED_FREE = 0;
|
public const FILLED_FREE = 0;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Has the user "user shifts admin" privilege?
|
* Has the user "user shifts admin" privilege?
|
||||||
|
|
|
@ -77,7 +77,6 @@ function admin_groups()
|
||||||
)
|
)
|
||||||
ORDER BY `Privileges`.`name`
|
ORDER BY `Privileges`.`name`
|
||||||
', [$group_id]);
|
', [$group_id]);
|
||||||
$privileges_html = '';
|
|
||||||
$privileges_form = [];
|
$privileges_form = [];
|
||||||
foreach ($privileges as $privilege) {
|
foreach ($privileges as $privilege) {
|
||||||
$privileges_form[] = form_checkbox(
|
$privileges_form[] = form_checkbox(
|
||||||
|
@ -87,17 +86,6 @@ function admin_groups()
|
||||||
$privilege['id'],
|
$privilege['id'],
|
||||||
'privilege-' . $privilege['name']
|
'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'));
|
$privileges_form[] = form_submit('submit', __('Save'));
|
||||||
|
|
|
@ -126,7 +126,7 @@ function admin_user()
|
||||||
|
|
||||||
$html .= '<hr />';
|
$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',
|
'SELECT group_id FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id` LIMIT 1',
|
||||||
[$user->id]
|
[$user->id]
|
||||||
);
|
);
|
||||||
|
@ -134,7 +134,7 @@ function admin_user()
|
||||||
$my_highest_group = $my_highest_group['group_id'];
|
$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',
|
'SELECT `group_id` FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id` LIMIT 1',
|
||||||
[$user_id]
|
[$user_id]
|
||||||
);
|
);
|
||||||
|
@ -152,7 +152,7 @@ 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`
|
||||||
|
@ -191,11 +191,11 @@ function admin_user()
|
||||||
switch ($request->input('action')) {
|
switch ($request->input('action')) {
|
||||||
case 'save_groups':
|
case 'save_groups':
|
||||||
if ($user_id != $user->id || auth()->can('admin_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`',
|
'SELECT * FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id`',
|
||||||
[$user->id]
|
[$user->id]
|
||||||
);
|
);
|
||||||
$his_highest_group = Db::selectOne(
|
$his_highest_group = DB::selectOne(
|
||||||
'SELECT * FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id`',
|
'SELECT * FROM `UserGroups` WHERE `uid`=? ORDER BY `group_id`',
|
||||||
[$user_id]
|
[$user_id]
|
||||||
);
|
);
|
||||||
|
@ -207,7 +207,7 @@ 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`
|
||||||
|
@ -235,11 +235,11 @@ function admin_user()
|
||||||
$groupsRequest = [];
|
$groupsRequest = [];
|
||||||
}
|
}
|
||||||
|
|
||||||
Db::delete('DELETE FROM `UserGroups` WHERE `uid`=?', [$user_id]);
|
DB::delete('DELETE FROM `UserGroups` WHERE `uid`=?', [$user_id]);
|
||||||
$user_groups_info = [];
|
$user_groups_info = [];
|
||||||
foreach ($groupsRequest as $group) {
|
foreach ($groupsRequest as $group) {
|
||||||
if (in_array($group, $grouplist)) {
|
if (in_array($group, $grouplist)) {
|
||||||
Db::insert(
|
DB::insert(
|
||||||
'INSERT INTO `UserGroups` (`uid`, `group_id`) VALUES (?, ?)',
|
'INSERT INTO `UserGroups` (`uid`, `group_id`) VALUES (?, ?)',
|
||||||
[$user_id, $group]
|
[$user_id, $group]
|
||||||
);
|
);
|
||||||
|
|
|
@ -9,23 +9,23 @@ class ShiftCalendarRenderer
|
||||||
/**
|
/**
|
||||||
* 15m * 60s/m = 900s
|
* 15m * 60s/m = 900s
|
||||||
*/
|
*/
|
||||||
const SECONDS_PER_ROW = 900;
|
public const SECONDS_PER_ROW = 900;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Height of a block in pixel.
|
* Height of a block in pixel.
|
||||||
* Do not change - corresponds with theme/css
|
* Do not change - corresponds with theme/css
|
||||||
*/
|
*/
|
||||||
const BLOCK_HEIGHT = 30;
|
public const BLOCK_HEIGHT = 30;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Distance between two shifts in pixels
|
* Distance between two shifts in pixels
|
||||||
*/
|
*/
|
||||||
const MARGIN = 5;
|
public const MARGIN = 5;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Seconds added to the start and end time
|
* Seconds added to the start and end time
|
||||||
*/
|
*/
|
||||||
const TIME_MARGIN = 1800;
|
public const TIME_MARGIN = 1800;
|
||||||
|
|
||||||
/** @var array */
|
/** @var array */
|
||||||
private $lanes;
|
private $lanes;
|
||||||
|
|
Loading…
Reference in New Issue