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/model/AngelType_model.php | 4 ++-- includes/model/EventConfig_model.php | 5 +++-- includes/model/Message_model.php | 2 +- includes/model/Room_model.php | 2 +- includes/model/ShiftEntry_model.php | 2 +- includes/model/ShiftTypes_model.php | 2 +- includes/model/Shifts_model.php | 12 ++++++------ includes/model/UserAngelTypes_model.php | 4 ++-- includes/model/UserDriverLicenses_model.php | 2 +- includes/model/User_model.php | 16 ++++++++-------- 10 files changed, 26 insertions(+), 25 deletions(-) (limited to 'includes/model') diff --git a/includes/model/AngelType_model.php b/includes/model/AngelType_model.php index 6feb9dd0..642d3d70 100644 --- a/includes/model/AngelType_model.php +++ b/includes/model/AngelType_model.php @@ -159,7 +159,7 @@ function AngelType_validate_name($name, $angeltype) if ($name == '') { return new ValidationResult(false, ''); } - if ($angeltype != null && isset($angeltype['id'])) { + if (!empty($angeltype) && isset($angeltype['id'])) { $valid = (count(DB::select(' SELECT `id` FROM `AngelTypes` @@ -225,7 +225,7 @@ function AngelType_ids() * Returns angelType by id. * * @param int $angeltype_id angelType ID - * @return array|null + * @return array */ function AngelType($angeltype_id) { diff --git a/includes/model/EventConfig_model.php b/includes/model/EventConfig_model.php index 8a29482b..6d782ec4 100644 --- a/includes/model/EventConfig_model.php +++ b/includes/model/EventConfig_model.php @@ -5,7 +5,7 @@ use Engelsystem\Database\DB; /** * Get event config. * - * @return array|null + * @return array */ function EventConfig() { @@ -31,7 +31,8 @@ function EventConfig_update( $teardown_end_date, $event_welcome_msg ) { - if (EventConfig() == null) { + $eventConfig = EventConfig(); + if (empty($eventConfig)) { return DB::insert(' INSERT INTO `EventConfig` ( `event_name`, diff --git a/includes/model/Message_model.php b/includes/model/Message_model.php index 5185785a..9bd7d6ef 100644 --- a/includes/model/Message_model.php +++ b/includes/model/Message_model.php @@ -16,7 +16,7 @@ function Message_ids() * Returns message by id. * * @param int $message_id message ID - * @return array|null + * @return array */ function Message($message_id) { diff --git a/includes/model/Room_model.php b/includes/model/Room_model.php index f153cd52..36a375aa 100644 --- a/includes/model/Room_model.php +++ b/includes/model/Room_model.php @@ -148,7 +148,7 @@ function Room_update($room_id, $name, $from_frab, $map_url, $description) * Returns room by id. * * @param int $room_id RID - * @return array|false + * @return array */ function Room($room_id) { diff --git a/includes/model/ShiftEntry_model.php b/includes/model/ShiftEntry_model.php index bb9db49d..02eace1e 100644 --- a/includes/model/ShiftEntry_model.php +++ b/includes/model/ShiftEntry_model.php @@ -134,7 +134,7 @@ function ShiftEntry_update($shift_entry) * Get a shift entry. * * @param int $shift_entry_id - * @return array|null + * @return array */ function ShiftEntry($shift_entry_id) { diff --git a/includes/model/ShiftTypes_model.php b/includes/model/ShiftTypes_model.php index 3d2dc9fe..0e8ef3a4 100644 --- a/includes/model/ShiftTypes_model.php +++ b/includes/model/ShiftTypes_model.php @@ -66,7 +66,7 @@ function ShiftType_create($name, $angeltype_id, $description) * Get a shift type by id. * * @param int $shifttype_id - * @return array|null + * @return array */ function ShiftType($shifttype_id) { diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index 62335882..5719a8e1 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -182,7 +182,7 @@ function NeededAngeltypes_by_ShiftsFilter(ShiftsFilter $shiftsFilter) /** * @param array $shift * @param array $angeltype - * @return array|null + * @return array */ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype) { @@ -323,7 +323,7 @@ function Shift_signup_allowed_angel( return new ShiftSignupState(ShiftSignupState::NOT_ARRIVED, $free_entries); } - if ($user_shifts == null) { + if (empty($user_shifts)) { $user_shifts = Shifts_by_user($user); } @@ -349,14 +349,14 @@ function Shift_signup_allowed_angel( return new ShiftSignupState(ShiftSignupState::OCCUPIED, $free_entries); } - if ($user_angeltype == null) { + if (empty($user_angeltype)) { $user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype); } if ( - $user_angeltype == null - || ($angeltype['no_self_signup'] == 1 && $user_angeltype != null) - || ($angeltype['restricted'] == 1 && $user_angeltype != null && !isset($user_angeltype['confirm_user_id'])) + empty($user_angeltype) + || ($angeltype['no_self_signup'] == 1 && !empty($user_angeltype)) + || ($angeltype['restricted'] == 1 && !empty($user_angeltype) && !isset($user_angeltype['confirm_user_id'])) ) { // you cannot join if user is not of this angel type // you cannot join if you are not confirmed diff --git a/includes/model/UserAngelTypes_model.php b/includes/model/UserAngelTypes_model.php index 71901b97..c744cdd7 100644 --- a/includes/model/UserAngelTypes_model.php +++ b/includes/model/UserAngelTypes_model.php @@ -193,7 +193,7 @@ function UserAngelType_create($user, $angeltype) * Get an UserAngelType by its id. * * @param int $user_angeltype_id - * @return array|null + * @return array */ function UserAngelType($user_angeltype_id) { @@ -209,7 +209,7 @@ function UserAngelType($user_angeltype_id) * * @param array $user * @param array $angeltype - * @return array|null + * @return array */ function UserAngelType_by_User_and_AngelType($user, $angeltype) { diff --git a/includes/model/UserDriverLicenses_model.php b/includes/model/UserDriverLicenses_model.php index dc38368b..a1476f95 100644 --- a/includes/model/UserDriverLicenses_model.php +++ b/includes/model/UserDriverLicenses_model.php @@ -41,7 +41,7 @@ function UserDriverLicense_valid($user_driver_license) * Get a users driver license information * * @param int $user_id The users id - * @return array|null + * @return array */ function UserDriverLicense($user_id) { diff --git a/includes/model/User_model.php b/includes/model/User_model.php index 5a31e7b8..a439b199 100644 --- a/includes/model/User_model.php +++ b/includes/model/User_model.php @@ -347,12 +347,12 @@ function User_validate_jabber($jabber) */ function User_validate_planned_arrival_date($planned_arrival_date) { - if ($planned_arrival_date == null) { + if (is_null($planned_arrival_date)) { // null is not okay return new ValidationResult(false, time()); } $event_config = EventConfig(); - if ($event_config == null) { + if (empty($event_config)) { // Nothing to validate against return new ValidationResult(true, $planned_arrival_date); } @@ -376,7 +376,7 @@ function User_validate_planned_arrival_date($planned_arrival_date) */ function User_validate_planned_departure_date($planned_arrival_date, $planned_departure_date) { - if ($planned_departure_date == null) { + if (is_null($planned_departure_date)) { // null is okay return new ValidationResult(true, null); } @@ -385,7 +385,7 @@ function User_validate_planned_departure_date($planned_arrival_date, $planned_de return new ValidationResult(false, $planned_arrival_date); } $event_config = EventConfig(); - if ($event_config == null) { + if (empty($event_config )) { // Nothing to validate against return new ValidationResult(true, $planned_departure_date); } @@ -404,7 +404,7 @@ function User_validate_planned_departure_date($planned_arrival_date, $planned_de * Returns user by id. * * @param int $user_id UID - * @return array|null + * @return array */ function User($user_id) { @@ -415,7 +415,7 @@ function User($user_id) * Returns User by api_key. * * @param string $api_key User api key - * @return array|null Matching user, null if not found + * @return array Matching user, empty if not found */ function User_by_api_key($api_key) { @@ -426,7 +426,7 @@ function User_by_api_key($api_key) * Returns User by email. * * @param string $email - * @return array|null Matching user, null on error + * @return array Matching user, empty on error */ function User_by_email($email) { @@ -437,7 +437,7 @@ function User_by_email($email) * Returns User by password token. * * @param string $token - * @return array|null Matching user, null when not found + * @return array Matching user, empty when not found */ function User_by_password_recovery_token($token) { -- cgit v1.2.3-54-g00ecf