diff --git a/config/config.default.php b/config/config.default.php index 437399e3..c7a79fc4 100644 --- a/config/config.default.php +++ b/config/config.default.php @@ -59,7 +59,7 @@ return [ // multiply 'night shifts' and freeloaded shifts (start or end between 2 and 6 exclusive) by 2 'shift_sum_formula' => ' SUM( - (1 + + (1 + ( (HOUR(FROM_UNIXTIME(`Shifts`.`end`)) > 2 AND HOUR(FROM_UNIXTIME(`Shifts`.`end`)) < 6) OR (HOUR(FROM_UNIXTIME(`Shifts`.`start`)) > 2 AND HOUR(FROM_UNIXTIME(`Shifts`.`start`)) < 6) diff --git a/includes/model/AngelType_model.php b/includes/model/AngelType_model.php index 411c69ea..d437f526 100644 --- a/includes/model/AngelType_model.php +++ b/includes/model/AngelType_model.php @@ -82,7 +82,7 @@ function AngelType_contact_info($angeltype) function AngelType_delete($angeltype) { $result = DB::delete(' - DELETE FROM `AngelTypes` + DELETE FROM `AngelTypes` WHERE `id`=? LIMIT 1 ', [$angeltype['id']]); @@ -102,8 +102,8 @@ function AngelType_delete($angeltype) function AngelType_update($angeltype) { $result = DB::update(' - UPDATE `AngelTypes` SET - `name` = ?, + UPDATE `AngelTypes` SET + `name` = ?, `restricted` = ?, `description` = ?, `requires_driver_license` = ?, @@ -201,7 +201,7 @@ function AngelType_validate_name($name, $angeltype) if ($angeltype != null && isset($angeltype['id'])) { $valid = (count(DB::select(' SELECT `id` - FROM `AngelTypes` + FROM `AngelTypes` WHERE `name`=? AND NOT `id`=? LIMIT 1 @@ -209,8 +209,8 @@ function AngelType_validate_name($name, $angeltype) return new ValidationResult($valid, $name); } $valid = (count(DB::select(' - SELECT `id` - FROM `AngelTypes` + SELECT `id` + FROM `AngelTypes` WHERE `name`=? LIMIT 1', [$name])) == 0); return new ValidationResult($valid, $name); @@ -225,12 +225,12 @@ function AngelType_validate_name($name, $angeltype) function AngelTypes_with_user($user) { $result = DB::select(' - SELECT `AngelTypes`.*, + SELECT `AngelTypes`.*, `UserAngelTypes`.`id` AS `user_angeltype_id`, `UserAngelTypes`.`confirm_user_id`, `UserAngelTypes`.`supporter` - FROM `AngelTypes` - LEFT JOIN `UserAngelTypes` ON `AngelTypes`.`id`=`UserAngelTypes`.`angeltype_id` + FROM `AngelTypes` + LEFT JOIN `UserAngelTypes` ON `AngelTypes`.`id`=`UserAngelTypes`.`angeltype_id` AND `UserAngelTypes`.`user_id` = ? ORDER BY `name`', [$user['UID']]); @@ -248,8 +248,8 @@ function AngelTypes_with_user($user) function AngelTypes() { $result = DB::select(' - SELECT * - FROM `AngelTypes` + SELECT * + FROM `AngelTypes` ORDER BY `name`'); if (DB::getStm()->errorCode() != '00000') { diff --git a/includes/model/EventConfig_model.php b/includes/model/EventConfig_model.php index 773ee2e0..f5846870 100644 --- a/includes/model/EventConfig_model.php +++ b/includes/model/EventConfig_model.php @@ -70,7 +70,7 @@ function EventConfig_update( `buildup_start_date` = ?, `event_start_date` = ?, `event_end_date` = ?, - `teardown_end_date` = ?, + `teardown_end_date` = ?, `event_welcome_msg` = ? ', [ diff --git a/includes/model/ShiftTypes_model.php b/includes/model/ShiftTypes_model.php index 4919875b..96a823d4 100644 --- a/includes/model/ShiftTypes_model.php +++ b/includes/model/ShiftTypes_model.php @@ -26,7 +26,7 @@ function ShiftType_update($shifttype_id, $name, $angeltype_id, $description) { DB::update(' UPDATE `ShiftTypes` SET - `name`=?, + `name`=?, `angeltype_id`=?, `description`=? WHERE `id`=? diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index c70ba830..faa37d59 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -35,9 +35,9 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) AND `NeededAngelTypes`.`angel_type_id` IN (' . implode(',', $shiftsFilter->getTypes()) . ') AND `NeededAngelTypes`.`count` > 0 AND `Shifts`.`PSID` IS NULL - + UNION - + SELECT DISTINCT `Shifts`.*, `ShiftTypes`.`name`, `Room`.`Name` AS `room_name` FROM `Shifts` JOIN `Room` USING (`RID`) @@ -48,7 +48,7 @@ function Shifts_by_ShiftsFilter(ShiftsFilter $shiftsFilter) AND `NeededAngelTypes`.`angel_type_id` IN (' . implode(',', $shiftsFilter->getTypes()) . ') AND `NeededAngelTypes`.`count` > 0 AND NOT `Shifts`.`PSID` IS NULL) AS tmp_shifts - + ORDER BY `start`'; $result = DB::select($sql); if (DB::getStm()->errorCode() != '00000') { @@ -122,9 +122,9 @@ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype) WHERE `Shifts`.`SID`=? AND `AngelTypes`.`id`=? AND `Shifts`.`PSID` IS NULL - + UNION - + SELECT `NeededAngelTypes`.*, `Shifts`.`SID`, @@ -532,12 +532,12 @@ function Shifts_by_user($user, $include_freeload_comments = false) SELECT `ShiftTypes`.`id` AS `shifttype_id`, `ShiftTypes`.`name`, `ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`, ' . ($include_freeload_comments ? '`ShiftEntry`.`freeload_comment`, ' : '') . ' - `Shifts`.*, `Room`.* - FROM `ShiftEntry` - JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) + `Shifts`.*, `Room`.* + FROM `ShiftEntry` + JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`) JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`) - JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) - WHERE `UID` = ? + JOIN `Room` ON (`Shifts`.`RID` = `Room`.`RID`) + WHERE `UID` = ? ORDER BY `start` ', [ @@ -560,7 +560,7 @@ function Shift($shift_id) { $shifts_source = DB::select(' SELECT `Shifts`.*, `ShiftTypes`.`name` - FROM `Shifts` + FROM `Shifts` JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`) WHERE `SID`=?', [$shift_id]); @@ -603,7 +603,7 @@ function Shift($shift_id) function Shifts() { $shifts_source = DB::select(' - SELECT `ShiftTypes`.`name`, `Shifts`.*, `Room`.`RID`, `Room`.`Name` AS `room_name` + SELECT `ShiftTypes`.`name`, `Shifts`.*, `Room`.`RID`, `Room`.`Name` AS `room_name` FROM `Shifts` JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`) JOIN `Room` ON `Room`.`RID` = `Shifts`.`RID` diff --git a/includes/model/UserAngelTypes_model.php b/includes/model/UserAngelTypes_model.php index b27724c3..82f390ee 100644 --- a/includes/model/UserAngelTypes_model.php +++ b/includes/model/UserAngelTypes_model.php @@ -16,7 +16,7 @@ use Engelsystem\Database\DB; function UserAngelType_exists($user, $angeltype) { return count(DB::select(' - SELECT `id` + SELECT `id` FROM `UserAngelTypes` WHERE `UserAngelTypes`.`user_id`=? AND `angeltype_id`=? @@ -55,10 +55,10 @@ function User_angeltypes($user) function User_unconfirmed_AngelTypes($user) { $result = DB::select(' - SELECT - `UserAngelTypes`.*, - `AngelTypes`.`name`, - count(`UnconfirmedMembers`.`user_id`) AS `count` + SELECT + `UserAngelTypes`.*, + `AngelTypes`.`name`, + count(`UnconfirmedMembers`.`user_id`) AS `count` FROM `UserAngelTypes` JOIN `AngelTypes` ON `UserAngelTypes`.`angeltype_id`=`AngelTypes`.`id` JOIN `UserAngelTypes` AS `UnconfirmedMembers` ON `UserAngelTypes`.`angeltype_id`=`UnconfirmedMembers`.`angeltype_id` @@ -90,8 +90,8 @@ function User_is_AngelType_supporter(&$user, $angeltype) $user['privileges'] = privileges_for_user($user['UID']); } return (count(DB::select(' - SELECT `id` - FROM `UserAngelTypes` + SELECT `id` + FROM `UserAngelTypes` WHERE `user_id`=? AND `angeltype_id`=? AND `supporter`=TRUE @@ -201,7 +201,7 @@ function UserAngelType_confirm($user_angeltype_id, $confirm_user) function UserAngelType_delete($user_angeltype) { return (bool)DB::delete(' - DELETE FROM `UserAngelTypes` + DELETE FROM `UserAngelTypes` WHERE `id`=? LIMIT 1', [$user_angeltype['id']]); } diff --git a/includes/model/User_model.php b/includes/model/User_model.php index 53b4ce1e..2913c1a1 100644 --- a/includes/model/User_model.php +++ b/includes/model/User_model.php @@ -486,8 +486,7 @@ function User_by_password_recovery_token($token) function User_reset_api_key(&$user, $log = true) { $user['api_key'] = md5($user['Nick'] . time() . rand()); - DB::update( - ' + DB::update(' UPDATE `User` SET `api_key`=? WHERE `UID`=? diff --git a/includes/pages/admin_active.php b/includes/pages/admin_active.php index 8cb66e6e..d21afabe 100644 --- a/includes/pages/admin_active.php +++ b/includes/pages/admin_active.php @@ -53,8 +53,7 @@ function admin_active() } if (isset($_REQUEST['ack'])) { DB::update('UPDATE `User` SET `Aktiv` = 0 WHERE `Tshirt` = 0'); - $users = DB::select(sprintf( - ' + $users = DB::select(sprintf(' SELECT `User`.*, COUNT(`ShiftEntry`.`id`) AS `shift_count`, @@ -137,11 +136,11 @@ function admin_active() `User`.*, COUNT(`ShiftEntry`.`id`) AS `shift_count`, %s AS `shift_length` - FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` + FROM `User` LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` LEFT JOIN `Shifts` ON `ShiftEntry`.`SID` = `Shifts`.`SID` ' . ($show_all_shifts ? '' : 'AND (`Shifts`.`end` < ' . time() . " OR `Shifts`.`end` IS NULL)") . ' WHERE `User`.`Gekommen` = 1 - GROUP BY `User`.`UID` + GROUP BY `User`.`UID` ORDER BY `force_active` DESC, `shift_length` DESC %s ', diff --git a/includes/pages/admin_free.php b/includes/pages/admin_free.php index 630603ba..daaead22 100644 --- a/includes/pages/admin_free.php +++ b/includes/pages/admin_free.php @@ -44,10 +44,10 @@ function admin_free() } $users = DB::select(' - SELECT `User`.* - FROM `User` + SELECT `User`.* + FROM `User` ' . $angelTypeSearch . ' - LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` + LEFT JOIN `ShiftEntry` ON `User`.`UID` = `ShiftEntry`.`UID` LEFT JOIN `Shifts` ON ( `ShiftEntry`.`SID` = `Shifts`.`SID` @@ -55,8 +55,8 @@ function admin_free() AND `Shifts`.`end` > ? ) WHERE `User`.`Gekommen` = 1 - AND `Shifts`.`SID` IS NULL - GROUP BY `User`.`UID` + AND `Shifts`.`SID` IS NULL + GROUP BY `User`.`UID` ORDER BY `Nick` ', [ diff --git a/includes/pages/admin_news.php b/includes/pages/admin_news.php index a814bc33..bc242831 100644 --- a/includes/pages/admin_news.php +++ b/includes/pages/admin_news.php @@ -46,7 +46,7 @@ function admin_news() case 'save': DB::update(' - UPDATE `News` SET + UPDATE `News` SET `Datum`=?, `Betreff`=?, `Text`=?, diff --git a/includes/pages/admin_questions.php b/includes/pages/admin_questions.php index 4c84e4f8..098701e3 100644 --- a/includes/pages/admin_questions.php +++ b/includes/pages/admin_questions.php @@ -116,8 +116,7 @@ function admin_questions() )); if ($answer != '') { - DB::update( - ' + DB::update(' UPDATE `Questions` SET `AID`=?, `Answer`=? WHERE `QID`=? diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php index 2ab40cca..60349676 100644 --- a/includes/pages/admin_user.php +++ b/includes/pages/admin_user.php @@ -247,7 +247,7 @@ function admin_user() $force_active = $_REQUEST['force_active']; } $sql = ' - UPDATE `User` SET + UPDATE `User` SET `Nick` = ?, `Name` = ?, `Vorname` = ?, diff --git a/includes/pages/user_atom.php b/includes/pages/user_atom.php index 5574e8eb..d7c77d52 100644 --- a/includes/pages/user_atom.php +++ b/includes/pages/user_atom.php @@ -24,7 +24,7 @@ function user_atom() $news = DB::select(' SELECT * - FROM `News` + FROM `News` ' . (empty($_REQUEST['meetings']) ? '' : 'WHERE `Treffen` = 1 ') . ' ORDER BY `ID` DESC LIMIT ' . (int)config('display_news') diff --git a/includes/pages/user_myshifts.php b/includes/pages/user_myshifts.php index 62d87d27..6048093a 100644 --- a/includes/pages/user_myshifts.php +++ b/includes/pages/user_myshifts.php @@ -132,8 +132,8 @@ function user_myshifts() $user_id = $_REQUEST['cancel']; $shift = DB::select(' SELECT * - FROM `Shifts` - INNER JOIN `ShiftEntry` USING (`SID`) + FROM `Shifts` + INNER JOIN `ShiftEntry` USING (`SID`) WHERE `ShiftEntry`.`id`=? AND `UID`=? ', [ diff --git a/includes/sys_template.php b/includes/sys_template.php index 107609ad..7aa458b8 100644 --- a/includes/sys_template.php +++ b/includes/sys_template.php @@ -186,10 +186,10 @@ function toolbar_popover($glyphicon, $label, $content, $class = '')