summaryrefslogtreecommitdiff
path: root/includes
diff options
context:
space:
mode:
Diffstat (limited to 'includes')
-rw-r--r--includes/controller/shifts_controller.php6
-rw-r--r--includes/controller/user_driver_licenses_controller.php4
-rw-r--r--includes/model/Shifts_model.php3
-rw-r--r--includes/mysqli_provider.php10
-rw-r--r--includes/pages/admin_import.php4
-rw-r--r--includes/pages/admin_news.php3
-rw-r--r--includes/pages/user_myshifts.php3
-rw-r--r--includes/pages/user_shifts.php7
-rw-r--r--includes/sys_page.php4
-rw-r--r--includes/sys_template.php2
-rw-r--r--includes/view/AngelTypes_view.php3
-rw-r--r--includes/view/User_view.php8
12 files changed, 30 insertions, 27 deletions
diff --git a/includes/controller/shifts_controller.php b/includes/controller/shifts_controller.php
index 52162b9e..b29a819f 100644
--- a/includes/controller/shifts_controller.php
+++ b/includes/controller/shifts_controller.php
@@ -137,12 +137,12 @@ function shifts_json_export_all_controller() {
function shifts_json_export_controller() {
global $ical_shifts, $user;
- if (isset($_REQUEST['key']) && preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
- $key = $_REQUEST['key'];
- } else {
+ if (! isset($_REQUEST['key']) || ! preg_match("/^[0-9a-f]{32}$/", $_REQUEST['key'])) {
engelsystem_error("Missing key.");
}
+ $key = $_REQUEST['key'];
+
$user = User_by_api_key($key);
if ($user === false) {
engelsystem_error("Unable to find user.");
diff --git a/includes/controller/user_driver_licenses_controller.php b/includes/controller/user_driver_licenses_controller.php
index d1c770ba..5c629777 100644
--- a/includes/controller/user_driver_licenses_controller.php
+++ b/includes/controller/user_driver_licenses_controller.php
@@ -69,6 +69,8 @@ function user_driver_license_edit_link($user = null) {
function user_driver_license_edit_controller() {
global $privileges, $user;
+ $user_source = $user;
+
if (isset($_REQUEST['user_id'])) {
$user_source = User($_REQUEST['user_id']);
if ($user_source === false) {
@@ -82,8 +84,6 @@ function user_driver_license_edit_controller() {
if ($user['UID'] != $user_source['UID'] && ! in_array('admin_user', $privileges)) {
redirect(user_driver_license_edit_link());
}
- } else {
- $user_source = $user;
}
$wants_to_drive = false;
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php
index 2f90ae48..a827c6b5 100644
--- a/includes/model/Shifts_model.php
+++ b/includes/model/Shifts_model.php
@@ -61,8 +61,9 @@ function Shift_signup_allowed($shift, $angeltype, $user_angeltype = null, $user_
// you canot join if shift is full
foreach ($needed_angeltypes as $needed_angeltype) {
if ($needed_angeltype['angel_type_id'] == $angeltype['id']) {
- if ($needed_angeltype['taken'] >= $needed_angeltype['count'])
+ if ($needed_angeltype['taken'] >= $needed_angeltype['count']) {
$user_may_join_shift = false;
+ }
break;
}
}
diff --git a/includes/mysqli_provider.php b/includes/mysqli_provider.php
index 0315c0f1..af05ca41 100644
--- a/includes/mysqli_provider.php
+++ b/includes/mysqli_provider.php
@@ -50,9 +50,9 @@ function sql_transaction_rollback() {
if (-- $sql_nested_transaction_level == 0) {
return sql_query("ROLLBACK");
- } else {
- return true;
}
+
+ return true;
}
/**
@@ -81,14 +81,14 @@ function sql_error($message) {
* Username
* @param string $pass
* Password
- * @param string $db
+ * @param string $db_name
* DB to select
* @return mysqli The connection handler
*/
-function sql_connect($host, $user, $pass, $db) {
+function sql_connect($host, $user, $pass, $db_name) {
global $sql_connection;
- $sql_connection = new mysqli($host, $user, $pass, $db);
+ $sql_connection = new mysqli($host, $user, $pass, $db_name);
if ($sql_connection->connect_errno) {
error("Unable to connect to MySQL: " . $sql_connection->connect_error);
return sql_error("Unable to connect to MySQL: " . $sql_connection->connect_error);
diff --git a/includes/pages/admin_import.php b/includes/pages/admin_import.php
index 8643dc55..2c36e681 100644
--- a/includes/pages/admin_import.php
+++ b/includes/pages/admin_import.php
@@ -385,7 +385,7 @@ function shifts_printable($shifts, $shifttypes) {
return $shifts_printable;
}
-function shift_sort($a, $b) {
- return ($a['start'] < $b['start']) ? - 1 : 1;
+function shift_sort($shift_a, $shift_b) {
+ return ($shift_a['start'] < $shift_b['start']) ? - 1 : 1;
}
?>
diff --git a/includes/pages/admin_news.php b/includes/pages/admin_news.php
index af7046c9..4226e6ba 100644
--- a/includes/pages/admin_news.php
+++ b/includes/pages/admin_news.php
@@ -62,8 +62,9 @@ function admin_news() {
redirect(page_link_to("news"));
break;
}
- } else
+ } else {
return error("No News found.", true);
+ }
}
return $html . '</div>';
}
diff --git a/includes/pages/user_myshifts.php b/includes/pages/user_myshifts.php
index b60d2ed8..3cf0c571 100644
--- a/includes/pages/user_myshifts.php
+++ b/includes/pages/user_myshifts.php
@@ -82,8 +82,9 @@ function user_myshifts() {
}
return ShiftEntry_edit_view(User_Nick_render($shifts_user), date("Y-m-d H:i", $shift['start']) . ', ' . shift_length($shift), $shift['Name'], $shift['name'], $shift['angel_type'], $shift['Comment'], $shift['freeloaded'], $shift['freeload_comment'], in_array("user_shifts_admin", $privileges));
- } else
+ } else {
redirect(page_link_to('user_myshifts'));
+ }
} elseif (isset($_REQUEST['cancel']) && preg_match("/^[0-9]*$/", $_REQUEST['cancel'])) {
$user_id = $_REQUEST['cancel'];
$shift = sql_select("
diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php
index 52167f14..9ad532ca 100644
--- a/includes/pages/user_shifts.php
+++ b/includes/pages/user_shifts.php
@@ -679,10 +679,11 @@ function view_user_shifts() {
$user_may_join_shift &= isset($angeltype['user_id']);
// you cannot join if you are not confirmed
- if ($angeltype['restricted'] == 1 && isset($angeltype['user_id']))
+ if ($angeltype['restricted'] == 1 && isset($angeltype['user_id'])) {
$user_may_join_shift &= isset($angeltype['confirm_user_id']);
-
- // you can only join if the shift is in future or running
+ }
+
+ // you can only join if the shift is in future or running
$user_may_join_shift &= time() < $shift['start'];
// User shift admins may join anybody in every shift
diff --git a/includes/sys_page.php b/includes/sys_page.php
index a6daaae1..e336261d 100644
--- a/includes/sys_page.php
+++ b/includes/sys_page.php
@@ -3,8 +3,8 @@
/**
* Leitet den Browser an die übergebene URL weiter und hält das Script an.
*/
-function redirect($to) {
- header("Location: " . $to, true, 302);
+function redirect($url) {
+ header("Location: " . $url, true, 302);
raw_output("");
}
diff --git a/includes/sys_template.php b/includes/sys_template.php
index bf2e7027..2faf98c3 100644
--- a/includes/sys_template.php
+++ b/includes/sys_template.php
@@ -41,7 +41,7 @@ function glyph_bool($boolean) {
return '<span class="text-' . ($boolean ? 'success' : 'danger') . '">' . glyph($boolean ? 'ok' : 'remove') . '</span>';
}
-function div($class, $content = array(), $dom_id = "") {
+function div($class, $content = [], $dom_id = "") {
$dom_id = $dom_id != '' ? ' id="' . $dom_id . '"' : '';
return '<div' . $dom_id . ' class="' . $class . '">' . join("\n", $content) . '</div>';
}
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
index 7e8663a1..cdaa9f12 100644
--- a/includes/view/AngelTypes_view.php
+++ b/includes/view/AngelTypes_view.php
@@ -153,7 +153,7 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
'actions' => ''
];
- if ($angeltype['requires_driver_license'] && ($coordinator || $admin_angeltypes))
+ if ($angeltype['requires_driver_license'] && ($coordinator || $admin_angeltypes)) {
$table_headers = [
'Nick' => _("Nick"),
'DECT' => _("DECT"),
@@ -166,6 +166,7 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
'has_license_forklift' => _("Forklift"),
'actions' => ''
];
+ }
if (count($coordinators) > 0) {
$page[] = '<h3>' . _("Coordinators") . '</h3>';
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index 3e365ea2..a620aa80 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -152,17 +152,15 @@ function User_shift_state_render($user) {
if ($upcoming_shifts[0]['start'] > time()) {
if ($upcoming_shifts[0]['start'] - time() > 3600) {
return '<span class="text-success moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Next shift %c") . '</span>';
- } else {
- return '<span class="text-warning moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Next shift %c") . '</span>';
}
+ return '<span class="text-warning moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Next shift %c") . '</span>';
}
$halfway = ($upcoming_shifts[0]['start'] + $upcoming_shifts[0]['end']) / 2;
if (time() < $halfway) {
return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Shift starts %c") . '</span>';
- } else {
- return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['end'] . '">' . _("Shift ends %c") . '</span>';
}
+ return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['end'] . '">' . _("Shift ends %c") . '</span>';
}
function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me) {
@@ -340,7 +338,7 @@ function User_angeltypes_render($user_angeltypes) {
}
function User_groups_render($user_groups) {
- $output = array();
+ $output = [];
foreach ($user_groups as $group) {
$output[] = substr($group['Name'], 2);
}