remove unused code

This commit is contained in:
msquare 2016-12-28 12:11:35 +01:00
parent 363cc8f6b5
commit 0603d0dd4e
5 changed files with 21 additions and 19 deletions

View File

@ -11,7 +11,7 @@ use Engelsystem\ShiftCalendarRenderer;
* View a room with its shifts. * View a room with its shifts.
*/ */
function room_controller() { function room_controller() {
global $privileges, $user; global $privileges;
if (! in_array('view_rooms', $privileges)) { if (! in_array('view_rooms', $privileges)) {
redirect(page_link_to()); redirect(page_link_to());
@ -43,9 +43,9 @@ function room_controller() {
$shiftsFilterRenderer = new ShiftsFilterRenderer($shiftsFilter); $shiftsFilterRenderer = new ShiftsFilterRenderer($shiftsFilter);
$shiftsFilterRenderer->enableDaySelection($days); $shiftsFilterRenderer->enableDaySelection($days);
$shifts = Shifts_by_ShiftsFilter($shiftsFilter, $user); $shifts = Shifts_by_ShiftsFilter($shiftsFilter);
$needed_angeltypes = NeededAngeltypes_by_ShiftsFilter($shiftsFilter, $user); $needed_angeltypes = NeededAngeltypes_by_ShiftsFilter($shiftsFilter);
$shift_entries = ShiftEntries_by_ShiftsFilter($shiftsFilter, $user); $shift_entries = ShiftEntries_by_ShiftsFilter($shiftsFilter);
return [ return [
$room['Name'], $room['Name'],

View File

@ -10,7 +10,7 @@ function Shifts_by_room($room) {
return $result; return $result;
} }
function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter, $user) { function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) {
$SQL = "SELECT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` as `room_name` $SQL = "SELECT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` as `room_name`
FROM `Shifts` FROM `Shifts`
JOIN `Room` USING (`RID`) JOIN `Room` USING (`RID`)
@ -69,7 +69,7 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter, $user) {
return $result; return $result;
} }
function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter, $user) { function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter) {
$SQL = "SELECT `NeededAngelTypes`.*, `Shifts`.`SID`, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup` $SQL = "SELECT `NeededAngelTypes`.*, `Shifts`.`SID`, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
FROM `Shifts` FROM `Shifts`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID` JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`
@ -121,7 +121,7 @@ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype) {
return $result[0]; return $result[0];
} }
function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter, $user) { function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter) {
$SQL = "SELECT `User`.`Nick`, `User`.`email`, `User`.`email_shiftinfo`, `User`.`Sprache`, `User`.`Gekommen`, `ShiftEntry`.`UID`, `ShiftEntry`.`TID`, `ShiftEntry`.`SID`, `ShiftEntry`.`Comment`, `ShiftEntry`.`freeloaded` $SQL = "SELECT `User`.`Nick`, `User`.`email`, `User`.`email_shiftinfo`, `User`.`Sprache`, `User`.`Gekommen`, `ShiftEntry`.`UID`, `ShiftEntry`.`TID`, `ShiftEntry`.`SID`, `ShiftEntry`.`Comment`, `ShiftEntry`.`freeloaded`
FROM `Shifts` FROM `Shifts`
JOIN `ShiftEntry` ON `ShiftEntry`.`SID`=`Shifts`.`SID` JOIN `ShiftEntry` ON `ShiftEntry`.`SID`=`Shifts`.`SID`
@ -235,7 +235,7 @@ function Shift_signup_allowed_angel($user, $shift, $angeltype, $user_angeltype,
/** /**
* Check if an angeltype supporter can sign up a user to a shift. * Check if an angeltype supporter can sign up a user to a shift.
*/ */
function Shift_signup_allowed_angeltype_supporter($shift, $angeltype, $needed_angeltype, $shift_entries) { function Shift_signup_allowed_angeltype_supporter($angeltype, $needed_angeltype, $shift_entries) {
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries); $free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
if ($free_entries == 0) { if ($free_entries == 0) {
return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries); return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries);
@ -252,7 +252,7 @@ function Shift_signup_allowed_angeltype_supporter($shift, $angeltype, $needed_an
* @param AngelType $angeltype * @param AngelType $angeltype
* The angeltype to which the user wants to sign up * The angeltype to which the user wants to sign up
*/ */
function Shift_signup_allowed_admin($shift, $angeltype, $needed_angeltype, $shift_entries) { function Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries) {
$free_entries = Shift_free_entries($needed_angeltype, $shift_entries); $free_entries = Shift_free_entries($needed_angeltype, $shift_entries);
if ($free_entries == 0) { if ($free_entries == 0) {
// User shift admins may join anybody in every shift // User shift admins may join anybody in every shift
@ -276,11 +276,11 @@ function Shift_signup_allowed($signup_user, $shift, $angeltype, $user_angeltype
global $user, $privileges; global $user, $privileges;
if (in_array('user_shifts_admin', $privileges)) { if (in_array('user_shifts_admin', $privileges)) {
return Shift_signup_allowed_admin($shift, $angeltype, $needed_angeltype, $shift_entries); return Shift_signup_allowed_admin($angeltype, $needed_angeltype, $shift_entries);
} }
if (in_array('shiftentry_edit_angeltype_supporter', $privileges) && User_is_AngelType_supporter($user, $angeltype)) { if (in_array('shiftentry_edit_angeltype_supporter', $privileges) && User_is_AngelType_supporter($user, $angeltype)) {
return Shift_signup_allowed_angeltype_supporter($shift, $angeltype, $needed_angeltype, $shift_entries); return Shift_signup_allowed_angeltype_supporter($angeltype, $needed_angeltype, $shift_entries);
} }
return Shift_signup_allowed_angel($signup_user, $shift, $angeltype, $user_angeltype, $user_shifts, $needed_angeltype, $shift_entries); return Shift_signup_allowed_angel($signup_user, $shift, $angeltype, $user_angeltype, $user_shifts, $needed_angeltype, $shift_entries);

View File

@ -129,7 +129,7 @@ function sql_select_db($db_name) {
* @return Result array or false on error * @return Result array or false on error
*/ */
function sql_select($query) { function sql_select($query) {
global $sql_connection, $query_count; global $sql_connection;
// echo $query . ";\n"; // echo $query . ";\n";
// echo debug_string_backtrace() . "\n"; // echo debug_string_backtrace() . "\n";

View File

@ -122,16 +122,18 @@ function view_user_shifts() {
$types = load_types(); $types = load_types();
if (! isset($_SESSION['ShiftsFilter'])) { if (! isset($_SESSION['ShiftsFilter'])) {
$room_ids = array_map('get_ids_from_array', $rooms); $room_ids = [
$rooms[0]['id']
];
$type_ids = array_map('get_ids_from_array', $types); $type_ids = array_map('get_ids_from_array', $types);
$_SESSION['ShiftsFilter'] = new ShiftsFilter(in_array('user_shifts_admin', $privileges), [$rooms[0]['id']], $type_ids); $_SESSION['ShiftsFilter'] = new ShiftsFilter(in_array('user_shifts_admin', $privileges), $room_ids, $type_ids);
} }
update_ShiftsFilter($_SESSION['ShiftsFilter'], in_array('user_shifts_admin', $privileges), $days); update_ShiftsFilter($_SESSION['ShiftsFilter'], in_array('user_shifts_admin', $privileges), $days);
$shiftsFilter = $_SESSION['ShiftsFilter']; $shiftsFilter = $_SESSION['ShiftsFilter'];
$shifts = Shifts_by_ShiftsFilter($shiftsFilter, $user); $shifts = Shifts_by_ShiftsFilter($shiftsFilter);
$needed_angeltypes = NeededAngeltypes_by_ShiftsFilter($shiftsFilter, $user); $needed_angeltypes = NeededAngeltypes_by_ShiftsFilter($shiftsFilter);
$shift_entries = ShiftEntries_by_ShiftsFilter($shiftsFilter, $user); $shift_entries = ShiftEntries_by_ShiftsFilter($shiftsFilter);
if ($user['api_key'] == "") { if ($user['api_key'] == "") {
User_reset_api_key($user, false); User_reset_api_key($user, false);

View File

@ -12,9 +12,9 @@ function Shift_editor_info_render($shift) {
return join('<br />', $info); return join('<br />', $info);
} }
function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null, $user_shifts = null) { function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null) {
global $user; global $user;
if ($user_angeltype == null) { if ($user_angeltype == null) {
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype); $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
} }