diff --git a/includes/controller/angeltypes_controller.php b/includes/controller/angeltypes_controller.php
index cb2bb2fb..cd938893 100644
--- a/includes/controller/angeltypes_controller.php
+++ b/includes/controller/angeltypes_controller.php
@@ -71,9 +71,6 @@ function angeltype_delete_controller() {
}
$angeltype = AngelType($_REQUEST['angeltype_id']);
- if ($angeltype === false) {
- engelsystem_error("Unable to load angeltype.");
- }
if ($angeltype == null) {
redirect(page_link_to('angeltypes'));
}
@@ -109,9 +106,6 @@ function angeltype_edit_controller() {
if (isset($_REQUEST['angeltype_id'])) {
$angeltype = AngelType($_REQUEST['angeltype_id']);
- if ($angeltype === false) {
- engelsystem_error("Unable to load angeltype.");
- }
if ($angeltype == null) {
redirect(page_link_to('angeltypes'));
}
@@ -196,17 +190,11 @@ function angeltype_controller() {
}
$angeltype = AngelType($_REQUEST['angeltype_id']);
- if ($angeltype === false) {
- engelsystem_error("Unable to load angeltype.");
- }
if ($angeltype == null) {
redirect(page_link_to('angeltypes'));
}
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
- if ($user_angeltype === false) {
- engelsystem_error("Unable to load user angeltype.");
- }
$user_driver_license = UserDriverLicense($user['UID']);
if ($user_driver_license === false) {
@@ -277,9 +265,6 @@ function load_angeltype() {
}
$angeltype = AngelType($_REQUEST['angeltype_id']);
- if ($angeltype === false) {
- engelsystem_error("Unable to load angeltype.");
- }
if ($angeltype == null) {
error(_("Angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
diff --git a/includes/controller/shifttypes_controller.php b/includes/controller/shifttypes_controller.php
index 88feffed..5e547895 100644
--- a/includes/controller/shifttypes_controller.php
+++ b/includes/controller/shifttypes_controller.php
@@ -128,9 +128,6 @@ function shifttype_controller() {
$angeltype = null;
if ($shifttype['angeltype_id'] != null) {
$angeltype = AngelType($shifttype['angeltype_id']);
- if ($angeltype === false) {
- engelsystem_error('Unable to load angeltype.');
- }
}
return [
diff --git a/includes/controller/user_angeltypes_controller.php b/includes/controller/user_angeltypes_controller.php
index 418f21f9..663f7826 100644
--- a/includes/controller/user_angeltypes_controller.php
+++ b/includes/controller/user_angeltypes_controller.php
@@ -7,9 +7,6 @@ function user_angeltypes_unconfirmed_hint() {
global $user;
$unconfirmed_user_angeltypes = User_unconfirmed_AngelTypes($user);
- if ($unconfirmed_user_angeltypes === false) {
- engelsystem_error("Unable to load user angeltypes.");
- }
if (count($unconfirmed_user_angeltypes) == 0) {
return '';
}
@@ -34,9 +31,6 @@ function user_angeltypes_delete_all_controller() {
}
$angeltype = AngelType($_REQUEST['angeltype_id']);
- if ($angeltype === false) {
- engelsystem_error("Unable to load angeltype.");
- }
if ($angeltype == null) {
error(_("Angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
@@ -48,10 +42,7 @@ function user_angeltypes_delete_all_controller() {
}
if (isset($_REQUEST['confirmed'])) {
- $result = UserAngelTypes_delete_all($angeltype['id']);
- if ($result === false) {
- engelsystem_error("Unable to confirm all users.");
- }
+ UserAngelTypes_delete_all($angeltype['id']);
engelsystem_log(sprintf("Denied all users for angeltype %s", AngelType_name_render($angeltype)));
success(sprintf(_("Denied all users for angeltype %s."), AngelType_name_render($angeltype)));
@@ -76,18 +67,12 @@ function user_angeltypes_confirm_all_controller() {
}
$angeltype = AngelType($_REQUEST['angeltype_id']);
- if ($angeltype === false) {
- engelsystem_error("Unable to load angeltype.");
- }
if ($angeltype == null) {
error(_("Angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
}
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
- if ($user_angeltype === false) {
- engelsystem_error("Unable to load user angeltype.");
- }
if ($user_angeltype == null) {
error(_("User angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
@@ -99,10 +84,7 @@ function user_angeltypes_confirm_all_controller() {
}
if (isset($_REQUEST['confirmed'])) {
- $result = UserAngelTypes_confirm_all($angeltype['id'], $user);
- if ($result === false) {
- engelsystem_error("Unable to confirm all users.");
- }
+ UserAngelTypes_confirm_all($angeltype['id'], $user);
engelsystem_log(sprintf("Confirmed all users for angeltype %s", AngelType_name_render($angeltype)));
success(sprintf(_("Confirmed all users for angeltype %s."), AngelType_name_render($angeltype)));
@@ -127,18 +109,12 @@ function user_angeltype_confirm_controller() {
}
$user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
- if ($user_angeltype === false) {
- engelsystem_error("Unable to load user angeltype.");
- }
if ($user_angeltype == null) {
error(_("User angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
}
$angeltype = AngelType($user_angeltype['angeltype_id']);
- if ($angeltype === false) {
- engelsystem_error("Unable to load angeltype.");
- }
if ($angeltype == null) {
error(_("Angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
@@ -150,9 +126,6 @@ function user_angeltype_confirm_controller() {
}
$user_source = User($user_angeltype['user_id']);
- if ($user_source === false) {
- engelsystem_error("Unable to load user.");
- }
if ($user_source == null) {
error(_("User doesn't exist."));
redirect(page_link_to('angeltypes'));
@@ -187,27 +160,18 @@ function user_angeltype_delete_controller() {
}
$user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
- if ($user_angeltype === false) {
- engelsystem_error("Unable to load user angeltype.");
- }
if ($user_angeltype == null) {
error(_("User angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
}
$angeltype = AngelType($user_angeltype['angeltype_id']);
- if ($angeltype === false) {
- engelsystem_error("Unable to load angeltype.");
- }
if ($angeltype == null) {
error(_("Angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
}
$user_source = User($user_angeltype['user_id']);
- if ($user_source === false) {
- engelsystem_error("Unable to load user.");
- }
if ($user_source == null) {
error(_("User doesn't exist."));
redirect(page_link_to('angeltypes'));
@@ -261,37 +225,25 @@ function user_angeltype_update_controller() {
}
$user_angeltype = UserAngelType($_REQUEST['user_angeltype_id']);
- if ($user_angeltype === false) {
- engelsystem_error("Unable to load user angeltype.");
- }
if ($user_angeltype == null) {
error(_("User angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
}
$angeltype = AngelType($user_angeltype['angeltype_id']);
- if ($angeltype === false) {
- engelsystem_error("Unable to load angeltype.");
- }
if ($angeltype == null) {
error(_("Angeltype doesn't exist."));
redirect(page_link_to('angeltypes'));
}
$user_source = User($user_angeltype['user_id']);
- if ($user_source === false) {
- engelsystem_error("Unable to load user.");
- }
if ($user_source == null) {
error(_("User doesn't exist."));
redirect(page_link_to('angeltypes'));
}
if (isset($_REQUEST['confirmed'])) {
- $result = UserAngelType_update($user_angeltype['id'], $coordinator);
- if ($result === false) {
- engelsystem_error("Unable to update coordinator rights.");
- }
+ UserAngelType_update($user_angeltype['id'], $coordinator);
$success_message = sprintf($coordinator ? _("Added coordinator rights for %s to %s.") : _("Removed coordinator rights for %s from %s."), AngelType_name_render($angeltype), User_Nick_render($user_source));
engelsystem_log($success_message);
@@ -326,26 +278,17 @@ function user_angeltype_add_controller() {
// Load possible users, that are not in the angeltype already
$users_source = Users_by_angeltype_inverted($angeltype);
- if ($users_source === false) {
- engelsystem_error("Unable to load users.");
- }
if (isset($_REQUEST['submit'])) {
$user_source = load_user();
if (! UserAngelType_exists($user_source, $angeltype)) {
$user_angeltype_id = UserAngelType_create($user_source, $angeltype);
- if ($user_angeltype_id === false) {
- engelsystem_error("Unable to create user angeltype.");
- }
engelsystem_log(sprintf("User %s added to %s.", User_Nick_render($user_source), AngelType_name_render($angeltype)));
success(sprintf(_("User %s added to %s."), User_Nick_render($user_source), AngelType_name_render($angeltype)));
- $result = UserAngelType_confirm($user_angeltype_id, $user_source);
- if ($result === false) {
- engelsystem_error("Unable to confirm user angeltype.");
- }
+ UserAngelType_confirm($user_angeltype_id, $user_source);
engelsystem_log(sprintf("User %s confirmed as %s.", User_Nick_render($user), AngelType_name_render($angeltype)));
redirect(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id']);
@@ -365,9 +308,6 @@ function user_angeltype_join_controller($angeltype) {
global $user, $privileges;
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
- if ($user_angeltype === false) {
- engelsystem_error("Unable to load user angeltype.");
- }
if ($user_angeltype != null) {
error(sprintf(_("You are already a %s."), $angeltype['name']));
redirect(page_link_to('angeltypes'));
@@ -375,19 +315,13 @@ function user_angeltype_join_controller($angeltype) {
if (isset($_REQUEST['confirmed'])) {
$user_angeltype_id = UserAngelType_create($user, $angeltype);
- if ($user_angeltype_id === false) {
- engelsystem_error("Unable to 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)));
success($success_message);
if (in_array('admin_user_angeltypes', $privileges)) {
- $result = UserAngelType_confirm($user_angeltype_id, $user);
- if ($result === false) {
- engelsystem_error("Unable to confirm user angeltype.");
- }
+ UserAngelType_confirm($user_angeltype_id, $user);
engelsystem_log(sprintf("User %s confirmed as %s.", User_Nick_render($user), AngelType_name_render($angeltype)));
}
diff --git a/includes/controller/user_driver_licenses_controller.php b/includes/controller/user_driver_licenses_controller.php
index 5c629777..88d25395 100644
--- a/includes/controller/user_driver_licenses_controller.php
+++ b/includes/controller/user_driver_licenses_controller.php
@@ -73,9 +73,6 @@ function user_driver_license_edit_controller() {
if (isset($_REQUEST['user_id'])) {
$user_source = User($_REQUEST['user_id']);
- if ($user_source === false) {
- engelsystem_error('Unable to load angeltype.');
- }
if ($user_source == null) {
redirect(user_driver_license_edit_link());
}
diff --git a/includes/controller/users_controller.php b/includes/controller/users_controller.php
index 9ead4bca..beaf2538 100644
--- a/includes/controller/users_controller.php
+++ b/includes/controller/users_controller.php
@@ -142,17 +142,13 @@ function user_edit_vouchers_controller() {
function user_controller() {
global $privileges, $user;
+ $user_source = $user;
if (isset($_REQUEST['user_id'])) {
$user_source = User($_REQUEST['user_id']);
- if ($user_source === false) {
- engelsystem_error("Unable to load user.");
- }
if ($user_source == null) {
error(_("User not found."));
redirect('?');
}
- } else {
- $user_source = $user;
}
$shifts = Shifts_by_user($user_source);
diff --git a/includes/model/AngelType_model.php b/includes/model/AngelType_model.php
index 73b746f0..a87dd461 100644
--- a/includes/model/AngelType_model.php
+++ b/includes/model/AngelType_model.php
@@ -135,7 +135,7 @@ function AngelType_ids() {
function AngelType($angeltype_id) {
$angelType_source = sql_select("SELECT * FROM `AngelTypes` WHERE `id`='" . sql_escape($angeltype_id) . "' LIMIT 1");
if ($angelType_source === false) {
- return false;
+ engelsystem_error("Unable to load angeltype.");
}
if (count($angelType_source) > 0) {
return $angelType_source[0];
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php
index b83d1a00..26dbbecb 100644
--- a/includes/model/Shifts_model.php
+++ b/includes/model/Shifts_model.php
@@ -98,9 +98,6 @@ function Shift_signup_allowed($shift, $angeltype, $user_angeltype = null, $user_
if ($user_angeltype == null) {
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
- if ($user_angeltype === false) {
- engelsystem_error('Unable to load user angeltype.');
- }
}
$signed_up = false;
diff --git a/includes/model/UserAngelTypes_model.php b/includes/model/UserAngelTypes_model.php
index fe5293f8..74b298cc 100644
--- a/includes/model/UserAngelTypes_model.php
+++ b/includes/model/UserAngelTypes_model.php
@@ -42,7 +42,7 @@ function User_angeltypes($user) {
* @param User $user
*/
function User_unconfirmed_AngelTypes($user) {
- return sql_select("
+ $result = sql_select("
SELECT
`UserAngelTypes`.*,
`AngelTypes`.`name`,
@@ -56,6 +56,10 @@ function User_unconfirmed_AngelTypes($user) {
AND `UnconfirmedMembers`.`confirm_user_id` IS NULL
GROUP BY `UserAngelTypes`.`angeltype_id`
ORDER BY `AngelTypes`.`name`");
+ if ($result === false) {
+ engelsystem_error("Unable to load user angeltypes.");
+ }
+ return $result;
}
/**
@@ -81,11 +85,15 @@ function User_is_AngelType_coordinator($user, $angeltype) {
* @param bool $coordinator
*/
function UserAngelType_update($user_angeltype_id, $coordinator) {
- return sql_query("
+ $result = sql_query("
UPDATE `UserAngelTypes`
SET `coordinator`=" . sql_bool($coordinator) . "
WHERE `id`='" . sql_escape($user_angeltype_id) . "'
LIMIT 1");
+ if ($result === false) {
+ engelsystem_error("Unable to update coordinator rights.");
+ }
+ return $result;
}
/**
@@ -94,10 +102,14 @@ function UserAngelType_update($user_angeltype_id, $coordinator) {
* @param int $angeltype_id
*/
function UserAngelTypes_delete_all($angeltype_id) {
- return sql_query("
+ $result = sql_query("
DELETE FROM `UserAngelTypes`
WHERE `angeltype_id`='" . sql_escape($angeltype_id) . "'
AND `confirm_user_id` IS NULL");
+ if ($result === false) {
+ engelsystem_error("Unable to delete all unconfirmed users.");
+ }
+ return $result;
}
/**
@@ -107,11 +119,15 @@ function UserAngelTypes_delete_all($angeltype_id) {
* @param User $confirm_user
*/
function UserAngelTypes_confirm_all($angeltype_id, $confirm_user) {
- return sql_query("
+ $result = sql_query("
UPDATE `UserAngelTypes`
SET `confirm_user_id`='" . sql_escape($confirm_user['UID']) . "'
WHERE `angeltype_id`='" . sql_escape($angeltype_id) . "'
AND `confirm_user_id` IS NULL");
+ if ($result === false) {
+ engelsystem_error("Unable to confirm all users.");
+ }
+ return $result;
}
/**
@@ -121,11 +137,15 @@ function UserAngelTypes_confirm_all($angeltype_id, $confirm_user) {
* @param User $confirm_user
*/
function UserAngelType_confirm($user_angeltype_id, $confirm_user) {
- return sql_query("
+ $result = sql_query("
UPDATE `UserAngelTypes`
SET `confirm_user_id`='" . sql_escape($confirm_user['UID']) . "'
WHERE `id`='" . sql_escape($user_angeltype_id) . "'
LIMIT 1");
+ if ($result === false) {
+ engelsystem_error("Unable to confirm user angeltype.");
+ }
+ return $result;
}
/**
@@ -152,7 +172,7 @@ function UserAngelType_create($user, $angeltype) {
`user_id`='" . sql_escape($user['UID']) . "',
`angeltype_id`='" . sql_escape($angeltype['id']) . "'");
if ($result === false) {
- return false;
+ engelsystem_error("Unable to create user angeltype.");
}
return sql_id();
}
@@ -169,7 +189,7 @@ function UserAngelType($user_angeltype_id) {
WHERE `id`='" . sql_escape($user_angeltype_id) . "'
LIMIT 1");
if ($angeltype === false) {
- return false;
+ engelsystem_error("Unable to load user angeltype.");
}
if (count($angeltype) == 0) {
return null;
@@ -191,7 +211,7 @@ function UserAngelType_by_User_and_AngelType($user, $angeltype) {
AND `angeltype_id`='" . sql_escape($angeltype['id']) . "'
LIMIT 1");
if ($angeltype === false) {
- return false;
+ engelsystem_error("Unable to load user angeltype.");
}
if (count($angeltype) == 0) {
return null;
diff --git a/includes/model/User_model.php b/includes/model/User_model.php
index 576bb3f5..ee849f72 100644
--- a/includes/model/User_model.php
+++ b/includes/model/User_model.php
@@ -113,12 +113,16 @@ function User_is_freeloader($user) {
* @param Angeltype $angeltype
*/
function Users_by_angeltype_inverted($angeltype) {
- return sql_select("
+ $result = sql_select("
SELECT `User`.*
FROM `User`
LEFT JOIN `UserAngelTypes` ON (`User`.`UID`=`UserAngelTypes`.`user_id` AND `angeltype_id`='" . sql_escape($angeltype['id']) . "')
WHERE `UserAngelTypes`.`id` IS NULL
ORDER BY `Nick`");
+ if ($result === false) {
+ engelsystem_error("Unable to load users.");
+ }
+ return $result;
}
/**
@@ -165,7 +169,7 @@ function User_validate_Nick($nick) {
function User($user_id) {
$user_source = sql_select("SELECT * FROM `User` WHERE `UID`='" . sql_escape($user_id) . "' LIMIT 1");
if ($user_source === false) {
- return false;
+ engelsystem_error("Unable to load user.");
}
if (count($user_source) > 0) {
return $user_source[0];
diff --git a/includes/pages/admin_news.php b/includes/pages/admin_news.php
index 4226e6ba..553473eb 100644
--- a/includes/pages/admin_news.php
+++ b/includes/pages/admin_news.php
@@ -22,9 +22,6 @@ function admin_news() {
list($news) = $news;
$user_source = User($news['UID']);
- if ($user_source === false) {
- engelsystem_error("Unable to load user.");
- }
$html .= form([
form_info(_("Date"), date("Y-m-d H:i", $news['Datum'])),
diff --git a/includes/pages/admin_questions.php b/includes/pages/admin_questions.php
index 8e7507da..8c16255c 100644
--- a/includes/pages/admin_questions.php
+++ b/includes/pages/admin_questions.php
@@ -26,9 +26,6 @@ function admin_questions() {
$questions = sql_select("SELECT * FROM `Questions` WHERE `AID` IS NULL");
foreach ($questions as $question) {
$user_source = User($question['UID']);
- if ($user_source === false) {
- engelsystem_error("Unable to load user.");
- }
$unanswered_questions_table[] = [
'from' => User_Nick_render($user_source),
@@ -45,14 +42,7 @@ function admin_questions() {
$questions = sql_select("SELECT * FROM `Questions` WHERE NOT `AID` IS NULL");
foreach ($questions as $question) {
$user_source = User($question['UID']);
- if ($user_source === false) {
- engelsystem_error("Unable to load user.");
- }
-
$answer_user_source = User($question['AID']);
- if ($answer_user_source === false) {
- engelsystem_error("Unable to load user.");
- }
$answered_questions_table[] = [
'from' => User_Nick_render($user_source),
'question' => str_replace("\n", "
", $question['Question']),
diff --git a/includes/pages/admin_rooms.php b/includes/pages/admin_rooms.php
index 61c0a2c0..186a676e 100644
--- a/includes/pages/admin_rooms.php
+++ b/includes/pages/admin_rooms.php
@@ -114,9 +114,6 @@ function admin_rooms() {
$needed_angeltype_info = [];
foreach ($angeltypes_count as $angeltype_id => $angeltype_count) {
$angeltype = AngelType($angeltype_id);
- if ($angeltype === false) {
- engelsystem_error("Unable to load angeltype.");
- }
if ($angeltype != null) {
NeededAngelType_add(null, $angeltype_id, $room_id, $angeltype_count);
$needed_angeltype_info[] = $angeltype['name'] . ": " . $angeltype_count;
diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php
index 56987e12..ef4eb2de 100644
--- a/includes/pages/admin_user.php
+++ b/includes/pages/admin_user.php
@@ -16,9 +16,6 @@ function admin_user() {
$user_id = $_REQUEST['id'];
if (! isset($_REQUEST['action'])) {
$user_source = User($user_id);
- if ($user_source === false) {
- engelsystem_error('Unable to load user.');
- }
if ($user_source == null) {
error(_('This user does not exist.'));
redirect(users_link());
diff --git a/includes/pages/user_messages.php b/includes/pages/user_messages.php
index 4af2a0cb..eb07deea 100644
--- a/includes/pages/user_messages.php
+++ b/includes/pages/user_messages.php
@@ -47,13 +47,7 @@ function user_messages() {
foreach ($messages as $message) {
$sender_user_source = User($message['SUID']);
- if ($sender_user_source === false) {
- engelsystem_error(_("Unable to load user."));
- }
$receiver_user_source = User($message['RUID']);
- if ($receiver_user_source === false) {
- engelsystem_error(_("Unable to load user."));
- }
$messages_table_entry = [
'new' => $message['isRead'] == 'N' ? '' : '',
diff --git a/includes/pages/user_news.php b/includes/pages/user_news.php
index c5791134..97f7ec83 100644
--- a/includes/pages/user_news.php
+++ b/includes/pages/user_news.php
@@ -62,9 +62,6 @@ function display_news($news) {
$html .= ' ' . date("Y-m-d H:i", $news['Datum']) . ' ';
$user_source = User($news['UID']);
- if ($user_source === false) {
- engelsystem_error(_("Unable to load user."));
- }
$html .= User_Nick_render($user_source);
if ($page != "news_comments") {
@@ -94,9 +91,6 @@ function user_news_comments() {
$comments = sql_select("SELECT * FROM `NewsComments` WHERE `Refid`='" . sql_escape($nid) . "' ORDER BY 'ID'");
foreach ($comments as $comment) {
$user_source = User($comment['UID']);
- if ($user_source === false) {
- engelsystem_error(_("Unable to load user."));
- }
$html .= '