From fe58e4f4220d6685b91bf516374e33936e1075e3 Mon Sep 17 00:00:00 2001 From: Igor Scheller Date: Sun, 14 Jan 2018 17:47:26 +0100 Subject: database: updated checks for selectOne --- includes/view/AngelTypes_view.php | 14 +++++++------- includes/view/EventConfig_view.php | 26 +++++++++++++------------- includes/view/ShiftCalendarRenderer.php | 2 +- includes/view/ShiftCalendarShiftRenderer.php | 4 ++-- includes/view/Shifts_view.php | 8 ++++---- includes/view/UserHintsRenderer.php | 2 +- includes/view/User_view.php | 12 ++++++------ 7 files changed, 34 insertions(+), 34 deletions(-) (limited to 'includes/view') diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php index 6cefbb24..93fa03b5 100644 --- a/includes/view/AngelTypes_view.php +++ b/includes/view/AngelTypes_view.php @@ -28,9 +28,9 @@ function AngelType_name_render($angeltype) */ function AngelType_render_membership($user_angeltype) { - if ($user_angeltype['user_angeltype_id'] != null) { + if (!empty($user_angeltype['user_angeltype_id'])) { if ($user_angeltype['restricted']) { - if ($user_angeltype['confirm_user_id'] == null) { + if (empty($user_angeltype['confirm_user_id'])) { return glyph('lock') . _('Unconfirmed'); } elseif ($user_angeltype['supporter']) { return glyph_bool(true) . _('Supporter'); @@ -145,18 +145,18 @@ function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, ); } - if ($user_angeltype == null) { + if (is_null($user_angeltype)) { $buttons[] = button( page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]), _('join'), 'add' ); } else { - if ($angeltype['requires_driver_license'] && $user_driver_license == null) { + if ($angeltype['requires_driver_license'] && empty($user_driver_license)) { error(_('This angeltype requires a driver license. Please enter your driver license information!')); } - if ($angeltype['restricted'] && $user_angeltype['confirm_user_id'] == null) { + if ($angeltype['restricted'] && empty($user_angeltype['confirm_user_id'])) { error(sprintf( _('You are unconfirmed for this angeltype. Please go to the introduction for %s to get confirmed.'), $angeltype['name'] @@ -212,7 +212,7 @@ function AngelType_view_members($angeltype, $members, $admin_user_angeltypes, $a $member['has_license_forklift'] = glyph_bool($member['has_license_forklift']); } - if ($angeltype['restricted'] && $member['confirm_user_id'] == null) { + if ($angeltype['restricted'] && empty($member['confirm_user_id'])) { $member['actions'] = table_buttons([ button( page_link_to( @@ -526,7 +526,7 @@ function AngelTypes_about_view_angeltype($angeltype) if (isset($angeltype['user_angeltype_id'])) { $buttons = []; - if ($angeltype['user_angeltype_id'] != null) { + if (!empty($angeltype['user_angeltype_id'])) { $buttons[] = button( page_link_to( 'user_angeltypes', diff --git a/includes/view/EventConfig_view.php b/includes/view/EventConfig_view.php index 25c4b225..fe6de670 100644 --- a/includes/view/EventConfig_view.php +++ b/includes/view/EventConfig_view.php @@ -8,7 +8,7 @@ */ function EventConfig_countdown_page($event_config) { - if ($event_config == null) { + if (empty($event_config)) { return div('col-md-12 text-center', [ heading(sprintf(_('Welcome to the %s!'), ' ENGELSYSTEM'), 2) ]); @@ -16,7 +16,7 @@ function EventConfig_countdown_page($event_config) $elements = []; - if ($event_config['event_name'] != null) { + if (!is_null($event_config['event_name'])) { $elements[] = div('col-sm-12 text-center', [ heading(sprintf( _('Welcome to the %s!'), @@ -25,7 +25,7 @@ function EventConfig_countdown_page($event_config) ]); } - if ($event_config['buildup_start_date'] != null && time() < $event_config['buildup_start_date']) { + if (!is_null($event_config['buildup_start_date']) && time() < $event_config['buildup_start_date']) { $elements[] = div('col-sm-3 text-center hidden-xs', [ heading(_('Buildup starts'), 4), '%c', @@ -33,7 +33,7 @@ function EventConfig_countdown_page($event_config) ]); } - if ($event_config['event_start_date'] != null && time() < $event_config['event_start_date']) { + if (!is_null($event_config['event_start_date']) && time() < $event_config['event_start_date']) { $elements[] = div('col-sm-3 text-center hidden-xs', [ heading(_('Event starts'), 4), '%c', @@ -41,7 +41,7 @@ function EventConfig_countdown_page($event_config) ]); } - if ($event_config['event_end_date'] != null && time() < $event_config['event_end_date']) { + if (!is_null($event_config['event_end_date']) && time() < $event_config['event_end_date']) { $elements[] = div('col-sm-3 text-center hidden-xs', [ heading(_('Event ends'), 4), '%c', @@ -49,7 +49,7 @@ function EventConfig_countdown_page($event_config) ]); } - if ($event_config['teardown_end_date'] != null && time() < $event_config['teardown_end_date']) { + if (!is_null($event_config['teardown_end_date']) && time() < $event_config['teardown_end_date']) { $elements[] = div('col-sm-3 text-center hidden-xs', [ heading(_('Teardown ends'), 4), '%c', @@ -68,15 +68,15 @@ function EventConfig_countdown_page($event_config) */ function EventConfig_info($event_config) { - if ($event_config == null) { + if (empty($event_config)) { return ''; } // Event name, start+end date are set if ( - $event_config['event_name'] != null - && $event_config['event_start_date'] != null - && $event_config['event_end_date'] != null + !is_null($event_config['event_name']) + && !is_null($event_config['event_start_date']) + && !is_null($event_config['event_end_date']) ) { return sprintf( _('%s, from %s to %s'), @@ -87,7 +87,7 @@ function EventConfig_info($event_config) } // Event name, start date are set - if ($event_config['event_name'] != null && $event_config['event_start_date'] != null) { + if (!is_null($event_config['event_name']) && !is_null($event_config['event_start_date'])) { return sprintf( _('%s, starting %s'), $event_config['event_name'], date(_('Y-m-d'), $event_config['event_start_date']) @@ -95,7 +95,7 @@ function EventConfig_info($event_config) } // Event start+end date are set - if ($event_config['event_start_date'] != null && $event_config['event_end_date'] != null) { + if (!is_null($event_config['event_start_date']) && !is_null($event_config['event_end_date'])) { return sprintf( _('Event from %s to %s'), date(_('Y-m-d'), $event_config['event_start_date']), @@ -104,7 +104,7 @@ function EventConfig_info($event_config) } // Only event name is set - if ($event_config['event_name'] != null) { + if (!is_null($event_config['event_name'])) { return sprintf($event_config['event_name']); } diff --git a/includes/view/ShiftCalendarRenderer.php b/includes/view/ShiftCalendarRenderer.php index 98f40d49..731d063a 100644 --- a/includes/view/ShiftCalendarRenderer.php +++ b/includes/view/ShiftCalendarRenderer.php @@ -129,7 +129,7 @@ class ShiftCalendarRenderer */ public function getBlocksPerSlot() { - if ($this->blocksPerSlot == null) { + if (is_null($this->blocksPerSlot)) { $this->blocksPerSlot = $this->calcBlocksPerSlot(); } return $this->blocksPerSlot; diff --git a/includes/view/ShiftCalendarShiftRenderer.php b/includes/view/ShiftCalendarShiftRenderer.php index 8bfb18ea..9643f195 100644 --- a/includes/view/ShiftCalendarShiftRenderer.php +++ b/includes/view/ShiftCalendarShiftRenderer.php @@ -116,7 +116,7 @@ class ShiftCalendarShiftRenderer $angeltype, $user ); - if ($shift_signup_state == null) { + if (is_null($shift_signup_state)) { $shift_signup_state = $angeltype_signup_state; } else { $shift_signup_state->combineWith($angeltype_signup_state); @@ -124,7 +124,7 @@ class ShiftCalendarShiftRenderer $html .= $angeltype_html; } } - if ($shift_signup_state == null) { + if (is_null($shift_signup_state)) { $shift_signup_state = new ShiftSignupState(ShiftSignupState::SHIFT_ENDED, 0); } diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php index 755fab74..c5680578 100644 --- a/includes/view/Shifts_view.php +++ b/includes/view/Shifts_view.php @@ -50,14 +50,14 @@ function Shift_view_header($shift, $room) function Shift_editor_info_render($shift) { $info = []; - if ($shift['created_by_user_id'] != null) { + if (!empty($shift['created_by_user_id'])) { $info[] = sprintf( glyph('plus') . _('created at %s by %s'), date('Y-m-d H:i', $shift['created_at_timestamp']), User_Nick_render(User($shift['created_by_user_id'])) ); } - if ($shift['edited_by_user_id'] != null) { + if (!empty($shift['edited_by_user_id'])) { $info[] = sprintf( glyph('pencil') . _('edited at %s by %s'), date('Y-m-d H:i', $shift['edited_at_timestamp']), @@ -77,13 +77,13 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null) { global $user; - if ($user_angeltype == null) { + if (empty($user_angeltype)) { $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype); } if ($angeltype['shift_signup_state']->isSignupAllowed()) { return button(shift_entry_create_link($shift, $angeltype), _('Sign up')); - } elseif ($user_angeltype == null) { + } elseif (empty($user_angeltype)) { return button( page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]), sprintf(_('Become %s'), diff --git a/includes/view/UserHintsRenderer.php b/includes/view/UserHintsRenderer.php index a2bc62f9..8d749ee9 100644 --- a/includes/view/UserHintsRenderer.php +++ b/includes/view/UserHintsRenderer.php @@ -36,7 +36,7 @@ class UserHintsRenderer */ public function addHint($hint, $important = false) { - if ($hint != null && $hint != '') { + if (!empty($hint)) { if ($important) { $this->important = true; $this->hints[] = error($hint, true); diff --git a/includes/view/User_view.php b/includes/view/User_view.php index 2f53e641..cc468bd2 100644 --- a/includes/view/User_view.php +++ b/includes/view/User_view.php @@ -472,7 +472,7 @@ function User_view_worklog($worklog, $admin_user_worklog_privilege) { ) ]); } - + return [ 'date' => glyph('calendar') . date('Y-m-d', $worklog['work_timestamp']), 'duration' => '' . sprintf('%.2f', $worklog['work_hours']) . '', @@ -480,8 +480,8 @@ function User_view_worklog($worklog, $admin_user_worklog_privilege) { 'shift_info' => _('Work log entry'), 'comment' => $worklog['comment'] . '
' . sprintf( - _('Added by %s at %s'), - User_Nick_render(User($worklog['created_user_id'])), + _('Added by %s at %s'), + User_Nick_render(User($worklog['created_user_id'])), date('Y-m-d H:i', $worklog['created_timestamp']) ), 'actions' => $actions @@ -748,7 +748,7 @@ function User_angeltypes_render($user_angeltypes) $output = []; foreach ($user_angeltypes as $angeltype) { $class = 'text-success'; - if ($angeltype['restricted'] == 1 && $angeltype['confirm_user_id'] == null) { + if ($angeltype['restricted'] == 1 && empty($angeltype['confirm_user_id'])) { $class = 'text-warning'; } $output[] = '' @@ -821,7 +821,7 @@ function render_user_departure_date_hint() { global $user; - if (!isset($user['planned_departure_date']) || $user['planned_departure_date'] == null) { + if (!isset($user['planned_departure_date']) || empty($user['planned_departure_date'])) { $text = _('Please enter your planned date of departure on your settings page to give us a feeling for teardown capacities.'); return render_profile_link($text, null, 'alert-link'); } @@ -857,7 +857,7 @@ function render_user_arrived_hint() if ($user['Gekommen'] == 0) { $event_config = EventConfig(); - if (!is_null($event_config) + if (!empty($event_config) && !is_null($event_config['buildup_start_date']) && time() > $event_config['buildup_start_date']) { return _('You are not marked as arrived. Please go to heaven\'s desk, get your angel badge and/or tell them that you arrived already.'); -- cgit v1.2.3-54-g00ecf