diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index 7b645edc..8018543b 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -42,7 +42,7 @@ before_script: .test_template: &test_definition stage: test artifacts: - name: "${CI_JOB_NAME}_${CI_PROJECT_ID}_${PHP_VERSION}" + name: "${CI_JOB_NAME}_${CI_PROJECT_ID}" expire_in: 1 week paths: - ./coverage/ diff --git a/README.md b/README.md index b5716436..662d994c 100644 --- a/README.md +++ b/README.md @@ -24,7 +24,7 @@ To report bugs use [engelsystem/issues](https://github.com/engelsystem/engelsyst On production systems it is recommended to use ```bash composer install --no-dev - composerdump-autoload --optimize + composer dump-autoload --optimize ``` to install the engelsystem * The webserver must have write access to the 'import' directory and read access for all other directories diff --git a/db/update.sql b/db/update.sql index 6e1c6dc5..212cd97e 100644 --- a/db/update.sql +++ b/db/update.sql @@ -41,11 +41,11 @@ ALTER TABLE `Room` DROP `Number`; ALTER TABLE `Room` DROP `show`; ALTER TABLE `Room` DROP `Man`; ALTER TABLE `Room` ADD `from_frab` BOOLEAN NOT NULL AFTER `FromPentabarf`; -update Room set `from_frab`=(`FromPentabarf`='Y'); +UPDATE Room SET `from_frab` = (`FromPentabarf` = 'Y'); ALTER TABLE `Room` DROP `FromPentabarf`; ALTER TABLE `Room` ADD `map_url` VARCHAR(300) NULL AFTER `from_frab`; ALTER TABLE `Room` ADD `description` TEXT NULL AFTER `map_url`; -- Dashboard ALTER TABLE `AngelTypes` ADD `show_on_dashboard` BOOLEAN NOT NULL AFTER `contact_email`; -UPDATE `AngelTypes` SET `show_on_dashboard`=TRUE; +UPDATE `AngelTypes` SET `show_on_dashboard` = TRUE; diff --git a/includes/controller/angeltypes_controller.php b/includes/controller/angeltypes_controller.php index 48b81b9f..399930c2 100644 --- a/includes/controller/angeltypes_controller.php +++ b/includes/controller/angeltypes_controller.php @@ -2,6 +2,7 @@ use Engelsystem\ShiftsFilter; use Engelsystem\ShiftsFilterRenderer; + /** * Text for Angeltype related links. * @@ -39,8 +40,8 @@ function angeltypes_controller() /** * Path to angeltype view. * - * @param int $angeltype_id AngelType id - * @param array $params additional params + * @param int $angeltype_id AngelType id + * @param array $params additional params * @return string */ function angeltype_link($angeltype_id, $params = []) @@ -187,17 +188,18 @@ function angeltype_controller() $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype); $user_driver_license = UserDriverLicense($user['UID']); $members = Users_by_angeltype($angeltype); - + $days = angeltype_controller_shiftsFilterDays($angeltype); $shiftsFilter = angeltype_controller_shiftsFilter($angeltype, $days); - + $shiftsFilterRenderer = new ShiftsFilterRenderer($shiftsFilter); $shiftsFilterRenderer->enableDaySelection($days); - + $shiftCalendarRenderer = shiftCalendarRendererByShiftFilter($shiftsFilter); $request = request(); $tab = 0; - if($request->has('shifts_filter_day')) { + + if ($request->has('shifts_filter_day')) { $tab = 1; } @@ -221,11 +223,12 @@ function angeltype_controller() /** * On which days do shifts for this angeltype occur? Needed for shiftCalendar. - * - * @param Angeltype $angeltype + * + * @param array $angeltype * @return array */ -function angeltype_controller_shiftsFilterDays($angeltype) { +function angeltype_controller_shiftsFilterDays($angeltype) +{ $all_shifts = Shifts_by_angeltype($angeltype); $days = []; foreach ($all_shifts as $shift) { @@ -239,20 +242,21 @@ function angeltype_controller_shiftsFilterDays($angeltype) { /** * Sets up the shift filter for the angeltype. - * - * @param Angeltype $angeltype + * + * @param array $angeltype * @param array $days * @return ShiftsFilter */ -function angeltype_controller_shiftsFilter($angeltype, $days) { +function angeltype_controller_shiftsFilter($angeltype, $days) +{ global $privileges; - + $request = request(); $shiftsFilter = new ShiftsFilter( in_array('user_shifts_admin', $privileges), Room_ids(), [$angeltype['id']] - ); + ); $selected_day = date('Y-m-d'); if (!empty($days)) { $selected_day = $days[0]; @@ -262,7 +266,7 @@ function angeltype_controller_shiftsFilter($angeltype, $days) { } $shiftsFilter->setStartTime(parse_date('Y-m-d H:i', $selected_day . ' 00:00')); $shiftsFilter->setEndTime(parse_date('Y-m-d H:i', $selected_day . ' 23:59')); - + return $shiftsFilter; } diff --git a/includes/controller/event_config_controller.php b/includes/controller/event_config_controller.php index aa328802..4422f046 100644 --- a/includes/controller/event_config_controller.php +++ b/includes/controller/event_config_controller.php @@ -101,9 +101,10 @@ function event_config_edit_controller() ); engelsystem_log( - sprintf('Changed event config: %s, %s, %s, %s, %s, %s', - $event_name, - $event_welcome_msg, + sprintf( + 'Changed event config: %s, %s, %s, %s, %s, %s', + $event_name, + $event_welcome_msg, date('Y-m-d', $buildup_start_date), date('Y-m-d', $event_start_date), date('Y-m-d', $event_end_date), diff --git a/includes/controller/public_dashboard_controller.php b/includes/controller/public_dashboard_controller.php index 7d652a64..23d5a4d6 100644 --- a/includes/controller/public_dashboard_controller.php +++ b/includes/controller/public_dashboard_controller.php @@ -2,25 +2,27 @@ /** * Loads all data for the public dashboard + * + * @return array */ function public_dashboard_controller() { $stats = [ 'needed-3-hours' => stats_angels_needed_three_hours(), - 'needed-night' => stats_angels_needed_for_nightshifts(), + 'needed-night' => stats_angels_needed_for_nightshifts(), 'angels-working' => stats_currently_working(), - 'hours-to-work' => stats_hours_to_work() + 'hours-to-work' => stats_hours_to_work() ]; - + $free_shifts_source = Shifts_free(time(), time() + 12 * 60 * 60); $free_shifts = []; foreach ($free_shifts_source as $shift) { $free_shift = public_dashboard_controller_free_shift($shift); - if(count($free_shift['needed_angels']) > 0) { + if (count($free_shift['needed_angels']) > 0) { $free_shifts[] = $free_shift; } } - + return [ _('Public Dashboard'), public_dashboard_view($stats, $free_shifts) @@ -30,41 +32,43 @@ function public_dashboard_controller() /** * Gathers information for free shifts to display. * - * @param array $shift + * @param array $shift + * @return array */ function public_dashboard_controller_free_shift($shift) { $shifttype = ShiftType($shift['shifttype_id']); $room = Room($shift['RID']); - + $free_shift = [ - 'SID' => $shift['SID'], - 'style' => 'default', - 'start' => date('H:i', $shift['start']), - 'end' => date('H:i', $shift['end']), - 'duration' => round(($shift['end'] - $shift['start']) / 3600), + 'SID' => $shift['SID'], + 'style' => 'default', + 'start' => date('H:i', $shift['start']), + 'end' => date('H:i', $shift['end']), + 'duration' => round(($shift['end'] - $shift['start']) / 3600), 'shifttype_name' => $shifttype['name'], - 'title' => $shift['title'], - 'room_name' => $room['Name'], - 'needed_angels' => [] + 'title' => $shift['title'], + 'room_name' => $room['Name'], + 'needed_angels' => [] ]; - + if (time() + 3 * 60 * 60 > $shift['start']) { $free_shift['style'] = 'warning'; } if (time() > $shift['start']) { $free_shift['style'] = 'danger'; } - + $free_shift['needed_angels'] = public_dashboard_needed_angels($shift['NeedAngels']); - + return $free_shift; } /** * Gathers information for needed angels on dashboard * - * @param array $needed_angels + * @param array $needed_angels + * @return array */ function public_dashboard_needed_angels($needed_angels) { @@ -75,7 +79,7 @@ function public_dashboard_needed_angels($needed_angels) $angeltype = AngelType($needed_angel['TID']); if ($angeltype['show_on_dashboard']) { $result[] = [ - 'need' => $need, + 'need' => $need, 'angeltype_name' => $angeltype['name'] ]; } @@ -86,9 +90,10 @@ function public_dashboard_needed_angels($needed_angels) /** * Returns url to public dashboard + * + * @return string */ function public_dashboard_link() { return page_link_to('public-dashboard'); } -?> \ No newline at end of file diff --git a/includes/controller/shift_entries_controller.php b/includes/controller/shift_entries_controller.php index 8dbf03ef..c20e48b4 100644 --- a/includes/controller/shift_entries_controller.php +++ b/includes/controller/shift_entries_controller.php @@ -1,18 +1,21 @@ input('shift_id')); if ($shift == null) { redirect(user_link($user)); } - + $angeltype = AngelType($request->input('angeltype_id')); - + if (in_array('user_shifts_admin', $privileges)) { return shift_entry_create_controller_admin($shift, $angeltype); } - + if ($angeltype == null) { redirect(user_link($user)); } - + if (User_is_AngelType_supporter($user, $angeltype)) { return shift_entry_create_controller_supporter($shift, $angeltype); } - + return shift_entry_create_controller_user($shift, $angeltype); } @@ -61,58 +66,59 @@ function shift_entry_create_controller() * Sign up for a shift. * Case: Admin * - * @param array $shift - * @param array $angeltype + * @param array $shift + * @param array $angeltype + * @return array */ function shift_entry_create_controller_admin($shift, $angeltype) { global $user; $request = request(); - + $signup_user = $user; if ($request->has('user_id')) { $signup_user = User($request->input('user_id')); } - if($signup_user == null) { + if ($signup_user == null) { redirect(shift_link($shift)); } - + $angeltypes = AngelTypes(); - if($request->has('angeltype_id')) { + if ($request->has('angeltype_id')) { $angeltype = AngelType($request->input('angeltype_id')); } - if($angeltype == null) { - if(count($angeltypes) == 0) { + if ($angeltype == null) { + if (count($angeltypes) == 0) { redirect(shift_link($shift)); } $angeltype = $angeltypes[0]; } - + if ($request->has('submit')) { ShiftEntry_create([ - 'SID' => $shift['SID'], - 'TID' => $angeltype['id'], - 'UID' => $signup_user['UID'], - 'Comment' => '', - 'freeloaded' => false, + 'SID' => $shift['SID'], + 'TID' => $angeltype['id'], + 'UID' => $signup_user['UID'], + 'Comment' => '', + 'freeloaded' => false, 'freeload_comment' => '' ]); - + success(sprintf(_('%s has been subscribed to the shift.'), User_Nick_render($signup_user))); redirect(shift_link($shift)); } - + $users = Users(); $users_select = []; foreach ($users as $u) { $users_select[$u['UID']] = $u['Nick']; } - + $angeltypes_select = []; - foreach($angeltypes as $a) { + foreach ($angeltypes as $a) { $angeltypes_select[$a['id']] = $a['name']; } - + $room = Room($shift['RID']); return [ ShiftEntry_create_title(), @@ -124,53 +130,62 @@ function shift_entry_create_controller_admin($shift, $angeltype) * Sign up for a shift. * Case: Supporter * - * @param array $shift - * @param array $angeltype + * @param array $shift + * @param array $angeltype + * @return array */ function shift_entry_create_controller_supporter($shift, $angeltype) { global $user; $request = request(); - + $signup_user = $user; if ($request->has('user_id')) { $signup_user = User($request->input('user_id')); } - if (! UserAngelType_exists($signup_user, $angeltype)) { + if (!UserAngelType_exists($signup_user, $angeltype)) { error(_('User is not in angeltype.')); redirect(shift_link($shift)); } - + $needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype); $shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $angeltype['id']); - $shift_signup_state = Shift_signup_allowed($signup_user, $shift, $angeltype, null, null, $needed_angeltype, $shift_entries); - if (! $shift_signup_state->isSignupAllowed()) { + $shift_signup_state = Shift_signup_allowed( + $signup_user, + $shift, + $angeltype, + null, + null, + $needed_angeltype, + $shift_entries + ); + if (!$shift_signup_state->isSignupAllowed()) { if ($shift_signup_state->getState() == ShiftSignupState::OCCUPIED) { error(_('This shift is already occupied.')); } redirect(shift_link($shift)); } - + if ($request->has('submit')) { ShiftEntry_create([ - 'SID' => $shift['SID'], - 'TID' => $angeltype['id'], - 'UID' => $signup_user['UID'], - 'Comment' => '', - 'freeloaded' => false, + 'SID' => $shift['SID'], + 'TID' => $angeltype['id'], + 'UID' => $signup_user['UID'], + 'Comment' => '', + 'freeloaded' => false, 'freeload_comment' => '' ]); - + success(sprintf(_('%s has been subscribed to the shift.'), User_Nick_render($signup_user))); redirect(shift_link($shift)); } - + $users = Users_by_angeltype($angeltype); $users_select = []; foreach ($users as $u) { $users_select[$u['UID']] = $u['Nick']; } - + $room = Room($shift['RID']); return [ ShiftEntry_create_title(), @@ -180,9 +195,11 @@ function shift_entry_create_controller_supporter($shift, $angeltype) /** * Generates an error message for the given shift signup state. + * * @param ShiftSignupState $shift_signup_state */ -function shift_entry_error_message(ShiftSignupState $shift_signup_state) { +function shift_entry_error_message(ShiftSignupState $shift_signup_state) +{ if ($shift_signup_state->getState() == ShiftSignupState::ANGELTYPE) { error(_('You need be accepted member of the angeltype.')); } elseif ($shift_signup_state->getState() == ShiftSignupState::COLLIDES) { @@ -202,43 +219,52 @@ function shift_entry_error_message(ShiftSignupState $shift_signup_state) { * Sign up for a shift. * Case: User * - * @param array $shift - * @param array $angeltype + * @param array $shift + * @param array $angeltype + * @return array */ function shift_entry_create_controller_user($shift, $angeltype) { global $user; $request = request(); - + $signup_user = $user; $needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype); $shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $angeltype['id']); - $shift_signup_state = Shift_signup_allowed($signup_user, $shift, $angeltype, null, null, $needed_angeltype, $shift_entries); - if (! $shift_signup_state->isSignupAllowed()) { + $shift_signup_state = Shift_signup_allowed( + $signup_user, + $shift, + $angeltype, + null, + null, + $needed_angeltype, + $shift_entries + ); + if (!$shift_signup_state->isSignupAllowed()) { shift_entry_error_message($shift_signup_state); redirect(shift_link($shift)); } - + $comment = ''; if ($request->has('submit')) { $comment = strip_request_item_nl('comment'); ShiftEntry_create([ - 'SID' => $shift['SID'], - 'TID' => $angeltype['id'], - 'UID' => $signup_user['UID'], - 'Comment' => $comment, - 'freeloaded' => false, + 'SID' => $shift['SID'], + 'TID' => $angeltype['id'], + 'UID' => $signup_user['UID'], + 'Comment' => $comment, + 'freeloaded' => false, 'freeload_comment' => '' ]); - - if ($angeltype['restricted'] == false && ! UserAngelType_exists($signup_user, $angeltype)) { + + if ($angeltype['restricted'] == false && !UserAngelType_exists($signup_user, $angeltype)) { UserAngelType_create($signup_user, $angeltype); } - + success(_('You are subscribed. Thank you!')); redirect(shift_link($shift)); } - + $room = Room($shift['RID']); return [ ShiftEntry_create_title(), @@ -249,13 +275,16 @@ function shift_entry_create_controller_user($shift, $angeltype) /** * Link to create a shift entry. * + * @param array $shift + * @param array $angeltype + * @param array $params * @return string URL */ function shift_entry_create_link($shift, $angeltype, $params = []) { $params = array_merge([ - 'action' => 'create', - 'shift_id' => $shift['SID'], + 'action' => 'create', + 'shift_id' => $shift['SID'], 'angeltype_id' => $angeltype['id'] ], $params); return page_link_to('shift_entries', $params); @@ -264,12 +293,14 @@ function shift_entry_create_link($shift, $angeltype, $params = []) /** * Link to create a shift entry as admin. * + * @param array $shift + * @param array $params * @return string URL */ function shift_entry_create_link_admin($shift, $params = []) { $params = array_merge([ - 'action' => 'create', + 'action' => 'create', 'shift_id' => $shift['SID'] ], $params); return page_link_to('shift_entries', $params); @@ -277,12 +308,14 @@ function shift_entry_create_link_admin($shift, $params = []) /** * Load a shift entry from get parameter shift_entry_id. + * + * @return array */ function shift_entry_load() { $request = request(); - - if (! $request->has('shift_entry_id') || ! test_request_int('shift_entry_id')) { + + if (!$request->has('shift_entry_id') || !test_request_int('shift_entry_id')) { redirect(page_link_to('user_shifts')); } $shiftEntry = ShiftEntry($request->input('shift_entry_id')); @@ -290,19 +323,21 @@ function shift_entry_load() error(_('Shift entry not found.')); redirect(page_link_to('user_shifts')); } - + return $shiftEntry; } /** * Remove somebody from a shift. + * + * @return array */ function shift_entry_delete_controller() { global $user; $request = request(); $shiftEntry = shift_entry_load(); - + $shift = Shift($shiftEntry['SID']); $angeltype = AngelType($shiftEntry['TID']); $signout_user = User($shiftEntry['UID']); @@ -310,20 +345,20 @@ function shift_entry_delete_controller() error(_('You are not allowed to remove this shift entry. If necessary, ask your supporter or heaven to do so.')); redirect(user_link($signout_user)); } - + if ($request->has('continue')) { ShiftEntry_delete($shiftEntry); success(_('Shift entry removed.')); redirect(shift_link($shift)); } - + if ($user['UID'] == $signout_user['UID']) { return [ ShiftEntry_delete_title(), ShiftEntry_delete_view($shiftEntry, $shift, $angeltype, $signout_user) ]; } - + return [ ShiftEntry_delete_title(), ShiftEntry_delete_view_admin($shiftEntry, $shift, $angeltype, $signout_user) @@ -333,14 +368,14 @@ function shift_entry_delete_controller() /** * Link to delete a shift entry. * - * @param array $shiftEntry - * + * @param array $shiftEntry + * @param array $params * @return string URL */ function shift_entry_delete_link($shiftEntry, $params = []) { $params = array_merge([ - 'action' => 'delete', + 'action' => 'delete', 'shift_entry_id' => $shiftEntry['id'] ], $params); return page_link_to('shift_entries', $params); diff --git a/includes/controller/shifts_controller.php b/includes/controller/shifts_controller.php index 28e35a1a..5930595e 100644 --- a/includes/controller/shifts_controller.php +++ b/includes/controller/shifts_controller.php @@ -45,7 +45,6 @@ function shift_edit_controller() { global $privileges; - // Schicht bearbeiten $msg = ''; $valid = true; $request = request(); @@ -65,7 +64,11 @@ function shift_edit_controller() $angeltypes = select_array(AngelTypes(), 'id', 'name'); $shifttypes = select_array(ShiftTypes(), 'id', 'name'); - $needed_angel_types = select_array(NeededAngelTypes_by_shift($shift_id), 'angel_type_id', 'count'); + $needed_angel_types = select_array( + NeededAngelTypes_by_shift($shift_id), + 'angel_type_id', + 'count' + ); foreach (array_keys($angeltypes) as $angeltype_id) { if (!isset($needed_angel_types[$angeltype_id])) { $needed_angel_types[$angeltype_id] = 0; @@ -149,7 +152,7 @@ function shift_edit_controller() $needed_angel_types_info = []; foreach ($needed_angel_types as $type_id => $count) { NeededAngelType_add($shift_id, $type_id, null, $count); - if($count > 0) { + if ($count > 0) { $needed_angel_types_info[] = $angeltypes[$type_id] . ': ' . $count; } } @@ -178,7 +181,9 @@ function shift_edit_controller() shifts_title(), [ msg(), - '', + '', form([ form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id), form_text('title', _('Title'), $title), @@ -310,8 +315,9 @@ function shifts_controller() switch ($request->input('action')) { case 'view': return shift_controller(); + /** @noinspection PhpMissingBreakStatementInspection */ case 'next': - return shift_next_controller(); + shift_next_controller(); default: redirect(page_link_to('/')); } diff --git a/includes/controller/user_angeltypes_controller.php b/includes/controller/user_angeltypes_controller.php index 543ba150..fb63cda8 100644 --- a/includes/controller/user_angeltypes_controller.php +++ b/includes/controller/user_angeltypes_controller.php @@ -273,7 +273,10 @@ function user_angeltype_update_controller() UserAngelType_update($user_angeltype['id'], $supporter); $success_message = sprintf( - $supporter ? _('Added supporter rights for %s to %s.') : _('Removed supporter rights for %s from %s.'), + $supporter + ? _('Added supporter rights for %s to %s.') + : _('Removed supporter rights for %s from %s.') + , AngelType_name_render($angeltype), User_Nick_render($user_source) ); @@ -291,6 +294,8 @@ function user_angeltype_update_controller() /** * User joining an Angeltype (Or supporter doing this for him). + * + * @return array */ function user_angeltype_add_controller() { @@ -364,7 +369,11 @@ function user_angeltype_join_controller($angeltype) $user_angeltype_id = UserAngelType_create($user, $angeltype); $success_message = sprintf(_('You joined %s.'), $angeltype['name']); - engelsystem_log(sprintf('User %s joined %s.', User_Nick_render($user), AngelType_name_render($angeltype))); + engelsystem_log(sprintf( + 'User %s joined %s.', + User_Nick_render($user), + AngelType_name_render($angeltype) + )); success($success_message); if (in_array('admin_user_angeltypes', $privileges)) { diff --git a/includes/controller/users_controller.php b/includes/controller/users_controller.php index b1ef517e..e206176f 100644 --- a/includes/controller/users_controller.php +++ b/includes/controller/users_controller.php @@ -271,7 +271,7 @@ function users_list_controller() User_arrived_count(), User_active_count(), User_force_active_count(), - ShiftEntries_freeleaded_count(), + ShiftEntries_freeloaded_count(), User_tshirts_count(), User_got_voucher_count() ) @@ -464,7 +464,10 @@ function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter) if (in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled()) && $taken < $needed_angels_count) { $filtered_shifts[] = $shift; } - if (in_array(ShiftsFilter::FILLED_FILLED, $shiftsFilter->getFilled()) && $taken >= $needed_angels_count) { + if ( + in_array(ShiftsFilter::FILLED_FILLED, $shiftsFilter->getFilled()) + && $taken >= $needed_angels_count + ) { $filtered_shifts[] = $shift; } } diff --git a/includes/helper/email_helper.php b/includes/helper/email_helper.php index dad27b39..a8b933f3 100644 --- a/includes/helper/email_helper.php +++ b/includes/helper/email_helper.php @@ -39,7 +39,10 @@ function engelsystem_email($address, $title, $message) $address, $title, $message, - sprintf("Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem <%s>", config('no_reply_email')) + sprintf( + "Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem <%s>", + config('no_reply_email') + ) ); if ($result === false) { diff --git a/includes/includes.php b/includes/includes.php index b6bd41cf..e8e5ce29 100644 --- a/includes/includes.php +++ b/includes/includes.php @@ -84,6 +84,7 @@ $includeFiles = [ __DIR__ . '/../includes/pages/user_settings.php', __DIR__ . '/../includes/pages/user_shifts.php', ]; + foreach ($includeFiles as $file) { require_once realpath($file); } diff --git a/includes/mailer/shifts_mailer.php b/includes/mailer/shifts_mailer.php index 5c0e4310..a69aab3a 100644 --- a/includes/mailer/shifts_mailer.php +++ b/includes/mailer/shifts_mailer.php @@ -63,7 +63,12 @@ function mail_shift_change($old_shift, $new_shift) foreach ($users as $user) { if ($user['email_shiftinfo']) { - engelsystem_email_to_user($user, '[engelsystem] ' . _('Your Shift has changed'), $message, true); + engelsystem_email_to_user( + $user, + '[engelsystem] ' . _('Your Shift has changed'), + $message, + true + ); } } } @@ -111,6 +116,10 @@ function mail_shift_assign($user, $shift) engelsystem_email_to_user($user, '[engelsystem] ' . _('Assigned to Shift'), $message, true); } +/** + * @param array $user + * @param array $shift + */ function mail_shift_removed($user, $shift) { if (!$user['email_shiftinfo']) { diff --git a/includes/model/AngelType_model.php b/includes/model/AngelType_model.php index f6e2a9cf..3641f125 100644 --- a/includes/model/AngelType_model.php +++ b/includes/model/AngelType_model.php @@ -25,13 +25,14 @@ function AngelType_new() /** * Checks if the angeltype has any contact information. - * - * @param Angeltype $angeltype + * + * @param array $angeltype Angeltype * @return bool */ -function AngelType_has_contact_info($angeltype) { - return !empty($angeltype['contact_name']) - || !empty($angeltype['contact_dect']) +function AngelType_has_contact_info($angeltype) +{ + return !empty($angeltype['contact_name']) + || !empty($angeltype['contact_dect']) || !empty($angeltype['contact_email']); } @@ -139,6 +140,7 @@ function AngelType_create($angeltype) . $angeltype['contact_email'] . ', ' . $angeltype['show_on_dashboard'] ); + return $angeltype; } @@ -172,6 +174,7 @@ function AngelType_validate_name($name, $angeltype) FROM `AngelTypes` WHERE `name`=? LIMIT 1', [$name])) == 0); + return new ValidationResult($valid, $name); } diff --git a/includes/model/NeededAngelTypes_model.php b/includes/model/NeededAngelTypes_model.php index 53313fe8..53f783c1 100644 --- a/includes/model/NeededAngelTypes_model.php +++ b/includes/model/NeededAngelTypes_model.php @@ -56,11 +56,12 @@ function NeededAngelTypes_delete_by_room($room_id) /** * Returns all needed angeltypes by room. - * + * * @param int $room_id * @return array */ -function NeededAngelTypes_by_room($room_id) { +function NeededAngelTypes_by_room($room_id) +{ return DB::select( 'SELECT `angel_type_id`, `count` FROM `NeededAngelTypes` WHERE `room_id`=?', [$room_id] @@ -76,7 +77,12 @@ function NeededAngelTypes_by_room($room_id) { function NeededAngelTypes_by_shift($shiftId) { $needed_angeltypes_source = DB::select(' - SELECT `NeededAngelTypes`.*, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup` + SELECT + `NeededAngelTypes`.*, + `AngelTypes`.`id`, + `AngelTypes`.`name`, + `AngelTypes`.`restricted`, + `AngelTypes`.`no_self_signup` FROM `NeededAngelTypes` JOIN `AngelTypes` ON `AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id` WHERE `shift_id` = ? diff --git a/includes/model/Room_model.php b/includes/model/Room_model.php index b23e35d1..f153cd52 100644 --- a/includes/model/Room_model.php +++ b/includes/model/Room_model.php @@ -1,14 +1,13 @@ 0) { + $name, + $room_id + ])) > 0) { $valid = false; } return new ValidationResult($valid, $name); @@ -50,7 +50,7 @@ function Room_ids() /** * Delete a room * - * @param int $room_id + * @param int $room_id */ function Room_delete($room_id) { @@ -64,7 +64,7 @@ function Room_delete($room_id) /** * Delete a room by its name * - * @param string $name + * @param string $name */ function Room_delete_by_name($name) { @@ -77,14 +77,10 @@ function Room_delete_by_name($name) /** * Create a new room * - * @param string $name - * Name of the room - * @param boolean $from_frab - * Is this a frab imported room? - * @param string $map_url - * URL to a map tha can be displayed in an iframe - * @param - * description markdown description + * @param string $name Name of the room + * @param boolean $from_frab Is this a frab imported room? + * @param string $map_url URL to a map tha can be displayed in an iframe + * @param string description Markdown description * @return false|int */ function Room_create($name, $from_frab, $map_url, $description) @@ -94,33 +90,31 @@ function Room_create($name, $from_frab, $map_url, $description) VALUES (?, ?, ?, ?) ', [ $name, - (int) $from_frab, + (int)$from_frab, $map_url, $description ]); $result = DB::getPdo()->lastInsertId(); - + engelsystem_log( 'Room created: ' . $name . ', frab import: ' . ($from_frab ? 'Yes' : '') . ', map_url: ' . $map_url . ', description: ' . $description ); - + return $result; } /** * update a room * - * @param string $name - * Name of the room - * @param boolean $from_frab - * Is this a frab imported room? - * @param string $map_url - * URL to a map tha can be displayed in an iframe - * @param - * description markdown description + * @param int $room_id The rooms id + * @param string $name Name of the room + * @param boolean $from_frab Is this a frab imported room? + * @param string $map_url URL to a map tha can be displayed in an iframe + * @param string $description Markdown description + * @return int */ function Room_update($room_id, $name, $from_frab, $map_url, $description) { @@ -134,28 +128,26 @@ function Room_update($room_id, $name, $from_frab, $map_url, $description) WHERE `RID`=? LIMIT 1', [ $name, - (int) $from_frab, + (int)$from_frab, $map_url, $description, $room_id ]); - + engelsystem_log( - 'Room updated: ' . $name . - ', frab import: ' . ($from_frab ? 'Yes' : '') . - ', map_url: ' . $map_url . + 'Room updated: ' . $name . + ', frab import: ' . ($from_frab ? 'Yes' : '') . + ', map_url: ' . $map_url . ', description: ' . $description ); - + return $result; } /** * Returns room by id. * - * @param int $room_id - * RID - * @param bool $onlyVisible + * @param int $room_id RID * @return array|false */ function Room($room_id) diff --git a/includes/model/ShiftEntry_model.php b/includes/model/ShiftEntry_model.php index 38db5959..bb9db49d 100644 --- a/includes/model/ShiftEntry_model.php +++ b/includes/model/ShiftEntry_model.php @@ -26,7 +26,7 @@ function ShiftEntry_new() * * @return int */ -function ShiftEntries_freeleaded_count() +function ShiftEntries_freeloaded_count() { $result = DB::selectOne('SELECT COUNT(*) FROM `ShiftEntry` WHERE `freeloaded` = 1'); @@ -38,7 +38,7 @@ function ShiftEntries_freeleaded_count() } /** - * List users subsribed to a given shift. + * List users subscribed to a given shift. * * @param int $shift_id * @return array @@ -102,7 +102,8 @@ function ShiftEntry_create($shift_entry) . ' signed up for shift ' . $shift['name'] . ' from ' . date('Y-m-d H:i', $shift['start']) . ' to ' . date('Y-m-d H:i', $shift['end']) - ); + ); + return $result; } @@ -149,20 +150,20 @@ function ShiftEntry_delete($shiftEntry) { mail_shift_removed(User($shiftEntry['UID']), Shift($shiftEntry['SID'])); DB::delete('DELETE FROM `ShiftEntry` WHERE `id` = ?', [$shiftEntry['id']]); - + $signout_user = User($shiftEntry['UID']); $shift = Shift($shiftEntry['SID']); $shifttype = ShiftType($shift['shifttype_id']); $room = Room($shift['RID']); $angeltype = AngelType($shiftEntry['TID']); - + engelsystem_log( - 'Shift signout: '. User_Nick_render($signout_user) . ' from shift ' . $shifttype['name'] + 'Shift signout: ' . User_Nick_render($signout_user) . ' from shift ' . $shifttype['name'] . ' at ' . $room['Name'] . ' from ' . date('Y-m-d H:i', $shift['start']) . ' to ' . date('Y-m-d H:i', $shift['end']) . ' as ' . $angeltype['name'] - ); + ); } /** diff --git a/includes/model/ShiftSignupState.php b/includes/model/ShiftSignupState.php index 1ab7c362..8d588de3 100644 --- a/includes/model/ShiftSignupState.php +++ b/includes/model/ShiftSignupState.php @@ -42,12 +42,12 @@ class ShiftSignupState * User is already signed up */ const SIGNED_UP = 'SIGNED_UP'; - + /** * User has to be arrived */ const NOT_ARRIVED = 'NOT_ARRIVED'; - + /** @var string */ private $state; @@ -69,8 +69,7 @@ class ShiftSignupState /** * Combine this state with another state from the same shift. * - * @param ShiftSignupState $shiftSignupState - * The other state to combine + * @param ShiftSignupState $shiftSignupState The other state to combine */ public function combineWith(ShiftSignupState $shiftSignupState) { @@ -122,6 +121,7 @@ class ShiftSignupState case ShiftSignupState::ADMIN: return true; } + return false; } diff --git a/includes/model/ShiftTypes_model.php b/includes/model/ShiftTypes_model.php index 227df367..3d2dc9fe 100644 --- a/includes/model/ShiftTypes_model.php +++ b/includes/model/ShiftTypes_model.php @@ -76,7 +76,7 @@ function ShiftType($shifttype_id) /** * Get all shift types. * - * @return array + * @return array[] */ function ShiftTypes() { diff --git a/includes/model/ShiftsFilter.php b/includes/model/ShiftsFilter.php index 3b691b55..5ad7a9b3 100644 --- a/includes/model/ShiftsFilter.php +++ b/includes/model/ShiftsFilter.php @@ -50,7 +50,6 @@ class ShiftsFilter */ public function __construct($user_shifts_admin, $rooms, $types) { - $this->user_shifts_admin = $user_shifts_admin; $this->rooms = $rooms; $this->types = $types; diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index fd229be6..62335882 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -8,7 +8,8 @@ use Engelsystem\ShiftSignupState; * @param array $angeltype * @return array */ -function Shifts_by_angeltype($angeltype) { +function Shifts_by_angeltype($angeltype) +{ return DB::select(' SELECT DISTINCT `Shifts`.* FROM `Shifts` JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id` = `Shifts`.`SID` @@ -27,7 +28,11 @@ function Shifts_by_angeltype($angeltype) { } /** - * Returns every shift with needed angels in the given time range. + * Returns every shift with needed angels in the given time range. + * + * @param int $start timestamp + * @param int $end timestamp + * @return array */ function Shifts_free($start, $end) { @@ -48,14 +53,14 @@ function Shifts_free($start, $end) AND (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`) > (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0) AND NOT `Shifts`.`PSID` IS NULL - ) as `tmp` + ) AS `tmp` ORDER BY `tmp`.`start` ", [ - $start, - $end, - $start, - $end - ]); + $start, + $end, + $start, + $end + ]); $free_shifts = []; foreach ($shifts as $shift) { $free_shifts[] = Shift($shift['SID']); @@ -65,14 +70,17 @@ function Shifts_free($start, $end) /** * Returns all shifts with a PSID (from frab import) + * + * @return array[] */ -function Shifts_from_frab() { +function Shifts_from_frab() +{ return DB::select('SELECT * FROM `Shifts` WHERE `PSID` IS NOT NULL ORDER BY `start`'); } /** * @param array $room - * @return array + * @return array[] */ function Shifts_by_room($room) { @@ -220,7 +228,7 @@ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype) /** * @param ShiftsFilter $shiftsFilter - * @return array + * @return array[] */ function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter) { @@ -404,33 +412,33 @@ function Shift_signup_allowed_admin($needed_angeltype, $shift_entries) /** * Check if an angel can signout from a shift. - * - * @param $shift The shift - * @param $angeltype The angeltype - * @param $signout_user The user that was signed up for the shift - * + * + * @param array $shift The shift + * @param array $angeltype The angeltype + * @param array $signout_user The user that was signed up for the shift * @return bool */ -function Shift_signout_allowed($shift, $angeltype, $signout_user) { +function Shift_signout_allowed($shift, $angeltype, $signout_user) +{ global $user, $privileges; - + // user shifts admin can sign out any user at any time if (in_array('user_shifts_admin', $privileges)) { return true; } - + // angeltype supporter can sign out any user at any time from their supported angeltype if ( in_array('shiftentry_edit_angeltype_supporter', $privileges) && User_is_AngelType_supporter($user, $angeltype) - ) { + ) { return true; } - - if($signout_user['UID'] == $user['UID'] && $shift['start'] > time() + config('last_unsubscribe') * 3600) { + + if ($signout_user['UID'] == $user['UID'] && $shift['start'] > time() + config('last_unsubscribe') * 3600) { return true; } - + return false; } @@ -496,9 +504,8 @@ function Shift_delete_by_psid($shift_psid) */ function Shift_delete($shift_id) { - mail_shift_delete(Shift($shift_id)); - DB::delete('DELETE FROM `Shifts` WHERE `SID`=?', [$shift_id]); + mail_shift_delete(Shift($shift_id)); } /** @@ -606,15 +613,23 @@ function Shift_create($shift) * * @param array $user * @param bool $include_freeload_comments - * @return array + * @return array[] */ function Shifts_by_user($user, $include_freeload_comments = false) { return DB::select(' - 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`.* + 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`) JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`) diff --git a/includes/model/Stats.php b/includes/model/Stats.php index 0c581fa9..4ff376c6 100644 --- a/includes/model/Stats.php +++ b/includes/model/Stats.php @@ -1,36 +1,43 @@ = ? AND `start` <= ?)", [ time(), time() ]); + if (empty($result['count'])) { return '-'; } + return $result['count']; } /** * Return the number of hours still to work. + * + * @return int|string */ function stats_hours_to_work() { $result = Db::selectOne(" - SELECT ROUND(SUM(`count`)) as `count` FROM ( + SELECT ROUND(SUM(`count`)) AS `count` FROM ( SELECT (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`) - * (`Shifts`.`end` - `Shifts`.`start`)/3600 as `count` + * (`Shifts`.`end` - `Shifts`.`start`)/3600 AS `count` FROM `Shifts` WHERE `end` >= ? AND `Shifts`.`PSID` IS NULL @@ -39,11 +46,11 @@ function stats_hours_to_work() SELECT (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`) - * (`Shifts`.`end` - `Shifts`.`start`)/3600 as `count` + * (`Shifts`.`end` - `Shifts`.`start`)/3600 AS `count` FROM `Shifts` WHERE `end` >= ? AND NOT `Shifts`.`PSID` IS NULL - ) as `tmp` + ) AS `tmp` ", [ time(), time() @@ -56,17 +63,19 @@ function stats_hours_to_work() /** * Returns the number of needed angels in the next 3 hours + * + * @return int|string */ function stats_angels_needed_three_hours() { $now = time(); $in3hours = $now + 3 * 60 * 60; $result = Db::selectOne(" - SELECT SUM(`count`) as `count` FROM ( + SELECT SUM(`count`) AS `count` FROM ( SELECT (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`) - (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0) - as `count` + AS `count` FROM `Shifts` WHERE `end` > ? AND `start` < ? AND `Shifts`.`PSID` IS NULL @@ -76,11 +85,11 @@ function stats_angels_needed_three_hours() SELECT (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`) - (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0) - as `count` + AS `count` FROM `Shifts` WHERE `end` > ? AND `start` < ? AND NOT `Shifts`.`PSID` IS NULL - ) as `tmp`", [ + ) AS `tmp`", [ $now, $in3hours, $now, @@ -94,17 +103,22 @@ function stats_angels_needed_three_hours() /** * Returns the number of needed angels for nightshifts (between 2 and 8) + * + * @return int|string */ function stats_angels_needed_for_nightshifts() { - $night_start = parse_date('Y-m-d H:i', date('Y-m-d', time() + 12 * 60 * 60) . ' 02:00'); + $night_start = parse_date( + 'Y-m-d H:i', + date('Y-m-d', time() + 12 * 60 * 60) . ' 02:00' + ); $night_end = $night_start + 6 * 60 * 60; $result = Db::selectOne(" - SELECT SUM(`count`) as `count` FROM ( + SELECT SUM(`count`) AS `count` FROM ( SELECT (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`) - (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0) - as `count` + AS `count` FROM `Shifts` WHERE `end` > ? AND `start` < ? AND `Shifts`.`PSID` IS NULL @@ -114,11 +128,11 @@ function stats_angels_needed_for_nightshifts() SELECT (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`) - (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0) - as `count` + AS `count` FROM `Shifts` WHERE `end` > ? AND `start` < ? AND NOT `Shifts`.`PSID` IS NULL - ) as `tmp`", [ + ) AS `tmp`", [ $night_start, $night_end, $night_start, @@ -129,5 +143,3 @@ function stats_angels_needed_for_nightshifts() } return $result['count']; } - -?> \ No newline at end of file diff --git a/includes/model/UserAngelTypes_model.php b/includes/model/UserAngelTypes_model.php index 42742f54..7b22e347 100644 --- a/includes/model/UserAngelTypes_model.php +++ b/includes/model/UserAngelTypes_model.php @@ -27,7 +27,7 @@ function UserAngelType_exists($user, $angeltype) * List users angeltypes. * * @param array $user - * @return array + * @return array[] */ function User_angeltypes($user) { @@ -43,7 +43,7 @@ function User_angeltypes($user) * Gets unconfirmed user angeltypes for angeltypes of which the given user is a supporter. * * @param array $user - * @return array + * @return array[] */ function User_unconfirmed_AngelTypes($user) { @@ -76,6 +76,7 @@ function User_is_AngelType_supporter(&$user, $angeltype) if (!isset($user['privileges'])) { $user['privileges'] = privileges_for_user($user['UID']); } + return (count(DB::select(' SELECT `id` FROM `UserAngelTypes` @@ -105,7 +106,7 @@ function UserAngelType_update($user_angeltype_id, $supporter) SET `supporter`=? WHERE `id`=? LIMIT 1 - ', [(int) $supporter, $user_angeltype_id]); + ', [(int)$supporter, $user_angeltype_id]); } /** @@ -143,7 +144,6 @@ function UserAngelTypes_confirm_all($angeltype_id, $confirm_user) * * @param int $user_angeltype_id * @param array $confirm_user - * @return bool */ function UserAngelType_confirm($user_angeltype_id, $confirm_user) { diff --git a/includes/model/UserGroups_model.php b/includes/model/UserGroups_model.php index d4baf638..9d67770c 100644 --- a/includes/model/UserGroups_model.php +++ b/includes/model/UserGroups_model.php @@ -6,7 +6,7 @@ use Engelsystem\Database\DB; * Returns users groups * * @param array $user - * @return array + * @return array[] */ function User_groups($user) { diff --git a/includes/model/User_model.php b/includes/model/User_model.php index 2d1767e6..33fca639 100644 --- a/includes/model/User_model.php +++ b/includes/model/User_model.php @@ -209,7 +209,7 @@ function User_is_freeloader($user) * Returns all users that are not member of given angeltype. * * @param array $angeltype Angeltype - * @return array + * @return array[] */ function Users_by_angeltype_inverted($angeltype) { @@ -231,7 +231,7 @@ function Users_by_angeltype_inverted($angeltype) * Returns all members of given angeltype. * * @param array $angeltype - * @return array + * @return array[] */ function Users_by_angeltype($angeltype) { @@ -258,7 +258,7 @@ function Users_by_angeltype($angeltype) /** * Returns User id array * - * @return array + * @return array[] */ function User_ids() { @@ -268,6 +268,7 @@ function User_ids() /** * Strip unwanted characters from a users nick. Allowed are letters, numbers, connecting punctuation and simple space. * Nick is trimmed. + * * @param string $nick * @return string */ @@ -279,8 +280,7 @@ function User_validate_Nick($nick) /** * Validate user email address. * - * @param string $mail - * The email address to validate + * @param string $mail The email address to validate * @return ValidationResult */ function User_validate_mail($mail) @@ -292,8 +292,7 @@ function User_validate_mail($mail) /** * Validate user jabber address * - * @param string $jabber - * Jabber-ID to validate + * @param string $jabber Jabber-ID to validate * @return ValidationResult */ function User_validate_jabber($jabber) @@ -337,10 +336,8 @@ function User_validate_planned_arrival_date($planned_arrival_date) /** * Validate the planned departure date * - * @param int $planned_arrival_date - * Unix timestamp - * @param int $planned_departure_date - * Unix timestamp + * @param int $planned_arrival_date Unix timestamp + * @param int $planned_departure_date Unix timestamp * @return ValidationResult */ function User_validate_planned_departure_date($planned_arrival_date, $planned_departure_date) @@ -383,8 +380,7 @@ function User($user_id) /** * Returns User by api_key. * - * @param string $api_key - * User api key + * @param string $api_key User api key * @return array|null Matching user, null if not found */ function User_by_api_key($api_key) @@ -396,7 +392,7 @@ function User_by_api_key($api_key) * Returns User by email. * * @param string $email - * @return array|null Matching user, null or false on error + * @return array|null Matching user, null on error */ function User_by_email($email) { @@ -460,7 +456,9 @@ function User_generate_password_recovery_token(&$user) $user['UID'], ] ); + engelsystem_log('Password recovery for ' . User_Nick_render($user) . ' started.'); + return $user['password_recovery_token']; } @@ -474,10 +472,10 @@ function User_get_eligable_voucher_count(&$user) $shifts_done = count(ShiftEntries_finished_by_user($user)); $earned_vouchers = $user['got_voucher'] - $voucher_settings['initial_vouchers']; - $elegible_vouchers = $shifts_done / $voucher_settings['shifts_per_voucher'] - $earned_vouchers; - if ($elegible_vouchers < 0) { + $eligable_vouchers = $shifts_done / $voucher_settings['shifts_per_voucher'] - $earned_vouchers; + if ($eligable_vouchers < 0) { return 0; } - return $elegible_vouchers; + return $eligable_vouchers; } diff --git a/includes/pages/admin_active.php b/includes/pages/admin_active.php index 0612202f..576cdc49 100644 --- a/includes/pages/admin_active.php +++ b/includes/pages/admin_active.php @@ -173,7 +173,8 @@ function admin_active() } $usr['nick'] = User_Nick_render($usr); $usr['shirt_size'] = $tshirt_sizes[$usr['Size']]; - $usr['work_time'] = round($usr['shift_length'] / 60) . ' min (' . round($usr['shift_length'] / 3600) . ' h)'; + $usr['work_time'] = round($usr['shift_length'] / 60) + . ' min (' . round($usr['shift_length'] / 3600) . ' h)'; $usr['active'] = glyph_bool($usr['Aktiv'] == 1); $usr['force_active'] = glyph_bool($usr['force_active'] == 1); $usr['tshirt'] = glyph_bool($usr['Tshirt'] == 1); diff --git a/includes/pages/admin_groups.php b/includes/pages/admin_groups.php index e0260320..92b6a3ea 100644 --- a/includes/pages/admin_groups.php +++ b/includes/pages/admin_groups.php @@ -85,7 +85,11 @@ function admin_groups() 'privilege-' . $privilege['name'] ); $privileges_html .= sprintf( - '