summaryrefslogtreecommitdiff
path: root/includes/controller/shift_entries_controller.php
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2017-07-28 20:11:09 +0200
committermsquare <msquare@notrademark.de>2017-07-28 20:11:09 +0200
commitf82e5456d22af7e39a22a9a64e74072cf01e0a31 (patch)
treec024194bd11621e1956a659a0ec91ee7c747b40c /includes/controller/shift_entries_controller.php
parent69a1ee2bfefb43a802dea8cf0f833cbe0a00369c (diff)
dried code by introducing selectOne for select queries with only one result line expected
Diffstat (limited to 'includes/controller/shift_entries_controller.php')
-rw-r--r--includes/controller/shift_entries_controller.php9
1 files changed, 3 insertions, 6 deletions
diff --git a/includes/controller/shift_entries_controller.php b/includes/controller/shift_entries_controller.php
index 03d7a27f..72189869 100644
--- a/includes/controller/shift_entries_controller.php
+++ b/includes/controller/shift_entries_controller.php
@@ -43,7 +43,7 @@ function shift_entry_add_controller()
$type = AngelType($type_id);
} else {
// TODO: Move queries to model
- $type = DB::select('
+ $type = DB::selectOne('
SELECT *
FROM `UserAngelTypes`
JOIN `AngelTypes` ON (`UserAngelTypes`.`angeltype_id` = `AngelTypes`.`id`)
@@ -56,7 +56,6 @@ function shift_entry_add_controller()
)
)
', [$type_id, $user['UID']]);
- $type = array_shift($type);
}
if (empty($type)) {
@@ -241,7 +240,7 @@ function shift_entry_delete_controller()
}
$entry_id = $request->input('entry_id');
- $shift_entry_source = DB::select('
+ $shift_entry_source = DB::selectOne('
SELECT
`User`.`Nick`,
`ShiftEntry`.`Comment`,
@@ -260,9 +259,7 @@ function shift_entry_delete_controller()
WHERE `ShiftEntry`.`id`=?',
[$entry_id]
);
- if (count($shift_entry_source) > 0) {
- $shift_entry_source = array_shift($shift_entry_source);
-
+ if (!empty($shift_entry_source)) {
if (!in_array('user_shifts_admin', $privileges) && (!in_array('shiftentry_edit_angeltype_supporter',
$privileges) || !User_is_AngelType_supporter($user, AngelType($shift_entry_source['angeltype_id'])))
) {