Function view_user_shifts
has a Cognitive Complexity of 324 (exceeds 5 allowed). Consider refactoring.
function view_user_shifts() {
global $user, $privileges;
global $ical_shifts;
$ical_shifts = array();
Function user_shifts
has a Cognitive Complexity of 287 (exceeds 5 allowed). Consider refactoring.
function user_shifts() {
global $user, $privileges;
$timezone_identifiers = DateTimeZone::listIdentifiers();
$timezone = $user['timezone'];
date_default_timezone_set ("$timezone_identifiers[$timezone]");
Method user_shifts
has 452 lines of code (exceeds 25 allowed). Consider refactoring.
function user_shifts() {
global $user, $privileges;
$timezone_identifiers = DateTimeZone::listIdentifiers();
$timezone = $user['timezone'];
date_default_timezone_set ("$timezone_identifiers[$timezone]");
File user_shifts_controller.php
has 874 lines of code (exceeds 250 allowed). Consider refactoring.
<?php
function shifts_title() {
return _("Shifts");
}
Method view_user_shifts
has 382 lines of code (exceeds 25 allowed). Consider refactoring.
function view_user_shifts() {
global $user, $privileges;
global $ical_shifts;
$ical_shifts = array();
Avoid deeply nested control flow statements.
if (in_array('user_shifts_admin', $privileges))
$shifts_row .= ' ' . button(page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'], _("Add more angels"), 'btn-xs');
Avoid deeply nested control flow statements.
if ($ownshift['start'] >= $shift['start'] && $ownshift['start'] < $shift['end'] || $ownshift['end'] > $shift['start'] && $ownshift['end'] <= $shift['end'] || $ownshift['start'] < $shift['start'] && $ownshift['end'] > $shift['end']) {
$collides = true;
break;
}
Avoid deeply nested control flow statements.
if ($entry['freeloaded']) {
$freeloader ++;
$style = " text-decoration: line-through;";
}
Avoid deeply nested control flow statements.
if ($angeltype['count'] - count($entries) - $freeloader > 0) {
$inner_text = sprintf(ngettext("%d helper needed", "%d helpers needed", $angeltype['count'] - count($entries)), $angeltype['count'] - count($entries));
$user_may_join_shift = true;
Consider simplifying this complex logical expression.
if ($ownshift['start'] >= $shift['start'] && $ownshift['start'] < $shift['end'] || $ownshift['end'] > $shift['start'] && $ownshift['end'] <= $shift['end'] || $ownshift['start'] < $shift['start'] && $ownshift['end'] > $shift['end']) {
$collides = true;
break;
}
Avoid too many return
statements within this method.
return ShiftEntry_edit_view($user_text, date("Y-m-d H:i", $shift['start']) . ' – ' . date('Y-m-d H:i', $shift['end']) . ' (' . shift_length($shift) . ')', $shift['Name'], $shift['name'], $angeltyppe_select, "", false, null, in_array('user_shifts_admin', $privileges));
Avoid too many return
statements within this method.
return view_user_shifts();
Similar blocks of code found in 2 locations. Consider refactoring.
elseif (isset($_REQUEST['save'])) {
if (! is_array($_SESSION['admin_shifts_shifts']) || ! is_array($_SESSION['admin_shifts_types']))
redirect(page_link_to('admin_shifts'));
foreach ($_SESSION['admin_shifts_shifts'] as $shift) {
Similar blocks of code found in 2 locations. Consider refactoring.
return page_with_title(_("Preview"), array(
form(array(
$hidden_types,
form_hidden('shifttype_id', $shifttype_id),
form_hidden('title', $title),
Identical blocks of code found in 2 locations. Consider refactoring.
foreach ($shifts as $shift) {
$shifts_table_entry = [
'timeslot' => '<span class="glyphicon glyphicon-time"></span> ' . date("Y-m-d H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']) . '<br />' . Room_name_render(Room($shift['RID'])),
'title' => ShiftType_name_render(ShiftType($shifttype_id)) . ($shift['title'] ? '<br />' . $shift['title'] : ''),
'needed_angels' => ''
Identical blocks of code found in 2 locations. Consider refactoring.
foreach ($types as $type) {
if (isset($_REQUEST['type_' . $type['id']]) && preg_match("/^[0-9]+$/", trim($_REQUEST['type_' . $type['id']]))) {
$needed_angel_types[$type['id']] = trim($_REQUEST['type_' . $type['id']]);
} else {
$ok = false;
Identical blocks of code found in 2 locations. Consider refactoring.
if (isset($_REQUEST['shifttype_id'])) {
$shifttype = ShiftType($_REQUEST['shifttype_id']);
if ($shifttype === false)
engelsystem_error('Unable to load shift type.');
if ($shifttype == null) {
includes/controller/admin_shifts_controller.php on lines 48..60 Similar blocks of code found in 2 locations. Consider refactoring.
$shifts_row .= '<div class="pull-right">' . table_buttons(array(
button(page_link_to('user_shifts') . '&edit_shift=' . $shift['SID'], glyph('edit'), 'btn-xs'),
button(page_link_to('user_shifts') . '&delete_shift=' . $shift['SID'], glyph('trash'), 'btn-xs'),
form_checkbox('del_shifts[] btn-xs', '', '', $value = $shift['SID'], false)
)). '</div>';
Similar blocks of code found in 2 locations. Consider refactoring.
$shift_row['info'] .= ' ' . table_buttons(array(
button(page_link_to('user_shifts') . '&edit_shift=' . $shift['SID'], glyph('edit'), 'btn-xs'),
button(page_link_to('user_shifts') . '&delete_shift=' . $shift['SID'], glyph('trash'), 'btn-xs'),
form_checkbox('del_shifts[] btn-xs', '', '', $value = $shift['SID'], false)
));
Identical blocks of code found in 2 locations. Consider refactoring.
if (isset($_REQUEST['rid']) && preg_match("/^[0-9]+$/", $_REQUEST['rid']) && isset($room_array[$_REQUEST['rid']]))
$rid = $_REQUEST['rid'];
else {
$ok = false;
$rid = $rooms[0]['RID'];
includes/controller/admin_shifts_controller.php on lines 66..72 There are no issues that match your filters.