summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--includes/model/AngelType_model.php38
-rw-r--r--includes/model/EventConfig_model.php6
-rw-r--r--includes/model/Message_model.php10
-rw-r--r--includes/model/NeededAngelTypes_model.php15
-rw-r--r--includes/model/Room_model.php9
-rw-r--r--includes/model/ShiftEntry_model.php10
-rw-r--r--includes/model/ShiftTypes_model.php9
-rw-r--r--includes/model/Shifts_model.php60
-rw-r--r--includes/model/UserAngelTypes_model.php15
-rw-r--r--includes/model/UserDriverLicenses_model.php6
-rw-r--r--includes/model/User_model.php60
-rw-r--r--includes/view/AngelTypes_view.php119
-rw-r--r--includes/view/Questions_view.php22
-rw-r--r--includes/view/Rooms_view.php3
-rw-r--r--includes/view/ShiftEntry_view.php14
-rw-r--r--includes/view/ShiftTypes_view.php17
-rw-r--r--includes/view/Shifts_view.php30
-rw-r--r--includes/view/UserAngelTypes_view.php66
-rw-r--r--includes/view/User_view.php141
19 files changed, 371 insertions, 279 deletions
diff --git a/includes/model/AngelType_model.php b/includes/model/AngelType_model.php
index e4aef450..47c13667 100644
--- a/includes/model/AngelType_model.php
+++ b/includes/model/AngelType_model.php
@@ -47,8 +47,9 @@ function AngelType_create($name, $restricted, $description, $requires_driver_lic
`restricted`=" . sql_bool($restricted) . ",
`description`='" . sql_escape($description) . "',
`requires_driver_license`=" . sql_bool($requires_driver_license));
- if ($result === false)
+ if ($result === false) {
return false;
+ }
return sql_id();
}
@@ -61,13 +62,14 @@ function AngelType_create($name, $restricted, $description, $requires_driver_lic
*/
function AngelType_validate_name($name, $angeltype) {
$name = strip_item($name);
- if ($name == "")
- return array(
+ if ($name == "") {
+ return [
false,
$name
- );
- if (isset($angeltype) && isset($angeltype['id']))
- return array(
+ ];
+ }
+ if (isset($angeltype) && isset($angeltype['id'])) {
+ return [
sql_num_query("
SELECT *
FROM `AngelTypes`
@@ -75,16 +77,16 @@ function AngelType_validate_name($name, $angeltype) {
AND NOT `id`='" . sql_escape($angeltype['id']) . "'
LIMIT 1") == 0,
$name
- );
- else
- return array(
- sql_num_query("
+ ];
+ }
+ return [
+ sql_num_query("
SELECT `id`
FROM `AngelTypes`
WHERE `name`='" . sql_escape($name) . "'
LIMIT 1") == 0,
- $name
- );
+ $name
+ ];
}
/**
@@ -119,10 +121,12 @@ function AngelTypes() {
*/
function AngelType_ids() {
$angelType_source = sql_select("SELECT `id` FROM `AngelTypes`");
- if ($angelType_source === false)
+ if ($angelType_source === false) {
return false;
- if (count($angelType_source) > 0)
+ }
+ if (count($angelType_source) > 0) {
return $angelType_source;
+ }
return null;
}
@@ -134,10 +138,12 @@ function AngelType_ids() {
*/
function AngelType($id) {
$angelType_source = sql_select("SELECT * FROM `AngelTypes` WHERE `id`='" . sql_escape($id) . "' LIMIT 1");
- if ($angelType_source === false)
+ if ($angelType_source === false) {
return false;
- if (count($angelType_source) > 0)
+ }
+ if (count($angelType_source) > 0) {
return $angelType_source[0];
+ }
return null;
}
diff --git a/includes/model/EventConfig_model.php b/includes/model/EventConfig_model.php
index 0529c286..ac8d5e72 100644
--- a/includes/model/EventConfig_model.php
+++ b/includes/model/EventConfig_model.php
@@ -5,10 +5,12 @@
*/
function EventConfig() {
$event_config = sql_select("SELECT * FROM `EventConfig` LIMIT 1");
- if ($event_config === false)
+ if ($event_config === false) {
return false;
- if (count($event_config) > 0)
+ }
+ if (count($event_config) > 0) {
return $event_config[0];
+ }
return null;
}
diff --git a/includes/model/Message_model.php b/includes/model/Message_model.php
index 7bae0dd4..92b76a80 100644
--- a/includes/model/Message_model.php
+++ b/includes/model/Message_model.php
@@ -1,7 +1,7 @@
<?php
-/**
- * Returns Message id array
+/**
+ * Returns Message id array
*/
function Message_ids() {
return sql_select("SELECT `id` FROM `Messages`");
@@ -15,10 +15,12 @@ function Message_ids() {
*/
function Message($id) {
$message_source = sql_select("SELECT * FROM `Messages` WHERE `id`='" . sql_escape($id) . "' LIMIT 1");
- if ($message_source === false)
+ if ($message_source === false) {
return false;
- if (count($message_source) > 0)
+ }
+ if (count($message_source) > 0) {
return $message_source[0];
+ }
return null;
}
diff --git a/includes/model/NeededAngelTypes_model.php b/includes/model/NeededAngelTypes_model.php
index 8d6b8cce..96ceca83 100644
--- a/includes/model/NeededAngelTypes_model.php
+++ b/includes/model/NeededAngelTypes_model.php
@@ -14,10 +14,11 @@ function NeededAngelTypes_by_shift($shiftId) {
AND `count` > 0
ORDER BY `room_id` DESC
");
- if ($needed_angeltypes_source === false)
+ if ($needed_angeltypes_source === false) {
return false;
-
- // Use settings from room
+ }
+
+ // Use settings from room
if (count($needed_angeltypes_source) == 0) {
$needed_angeltypes_source = sql_select("
SELECT `NeededAngelTypes`.*, `AngelTypes`.`name`, `AngelTypes`.`restricted`
@@ -28,15 +29,17 @@ function NeededAngelTypes_by_shift($shiftId) {
AND `count` > 0
ORDER BY `room_id` DESC
");
- if ($needed_angeltypes_source === false)
+ if ($needed_angeltypes_source === false) {
return false;
+ }
}
- $needed_angeltypes = array();
+ $needed_angeltypes = [];
foreach ($needed_angeltypes_source as $angeltype) {
$shift_entries = ShiftEntries_by_shift_and_angeltype($shiftId, $angeltype['angel_type_id']);
- if ($shift_entries === false)
+ if ($shift_entries === false) {
return false;
+ }
$angeltype['taken'] = count($shift_entries);
$needed_angeltypes[] = $angeltype;
diff --git a/includes/model/Room_model.php b/includes/model/Room_model.php
index 6d8a205e..1768b61b 100644
--- a/includes/model/Room_model.php
+++ b/includes/model/Room_model.php
@@ -25,8 +25,9 @@ function Room_create($name, $from_frab, $public) {
`FromPentabarf`='" . sql_escape($from_frab ? 'Y' : '') . "',
`show`='" . sql_escape($public ? 'Y' : '') . "',
`Number`=0");
- if ($result === false)
+ if ($result === false) {
return false;
+ }
return sql_id();
}
@@ -38,10 +39,12 @@ function Room_create($name, $from_frab, $public) {
function Room($id) {
$room_source = sql_select("SELECT * FROM `Room` WHERE `RID`='" . sql_escape($id) . "' AND `show` = 'Y'");
- if ($room_source === false)
+ if ($room_source === false) {
return false;
- if (count($room_source) > 0)
+ }
+ if (count($room_source) > 0) {
return $room_source[0];
+ }
return null;
}
diff --git a/includes/model/ShiftEntry_model.php b/includes/model/ShiftEntry_model.php
index 6324c3bf..425b92e8 100644
--- a/includes/model/ShiftEntry_model.php
+++ b/includes/model/ShiftEntry_model.php
@@ -51,10 +51,12 @@ function ShiftEntry_update($shift_entry) {
*/
function ShiftEntry($shift_entry_id) {
$shift_entry = sql_select("SELECT * FROM `ShiftEntry` WHERE `id`='" . sql_escape($shift_entry_id) . "'");
- if ($shift_entry === false)
+ if ($shift_entry === false) {
return false;
- if (count($shift_entry) == 0)
+ }
+ if (count($shift_entry) == 0) {
return null;
+ }
return $shift_entry[0];
}
@@ -89,8 +91,8 @@ function ShiftEntries_upcoming_for_user($user) {
*
* @param User $user
*/
-function ShiftEntries_finished_by_user($user){
- return sql_select("
+function ShiftEntries_finished_by_user($user) {
+ return sql_select("
SELECT *
FROM `ShiftEntry`
JOIN `Shifts` ON (`Shifts`.`SID` = `ShiftEntry`.`SID`)
diff --git a/includes/model/ShiftTypes_model.php b/includes/model/ShiftTypes_model.php
index 7f057da8..a9cf77bd 100644
--- a/includes/model/ShiftTypes_model.php
+++ b/includes/model/ShiftTypes_model.php
@@ -37,8 +37,9 @@ function ShiftType_create($name, $angeltype_id, $description) {
`name`='" . sql_escape($name) . "',
`angeltype_id`=" . sql_null($angeltype_id) . ",
`description`='" . sql_escape($description) . "'");
- if ($result === false)
+ if ($result === false) {
return false;
+ }
return sql_id();
}
@@ -49,10 +50,12 @@ function ShiftType_create($name, $angeltype_id, $description) {
*/
function ShiftType($shifttype_id) {
$shifttype = sql_select("SELECT * FROM `ShiftTypes` WHERE `id`='" . sql_escape($shifttype_id) . "'");
- if ($shifttype === false)
+ if ($shifttype === false) {
return false;
- if ($shifttype == null)
+ }
+ if ($shifttype == null) {
return null;
+ }
return $shifttype[0];
}
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php
index d32de0cb..cca5139d 100644
--- a/includes/model/Shifts_model.php
+++ b/includes/model/Shifts_model.php
@@ -6,10 +6,13 @@
* @param array<Shift> $shifts
*/
function Shift_collides($shift, $shifts) {
- foreach ($shifts as $other_shift)
- if ($shift['SID'] != $other_shift['SID'])
- if (! ($shift['start'] >= $other_shift['end'] || $shift['end'] <= $other_shift['start']))
+ foreach ($shifts as $other_shift) {
+ if ($shift['SID'] != $other_shift['SID']) {
+ if (! ($shift['start'] >= $other_shift['end'] || $shift['end'] <= $other_shift['start'])) {
return true;
+ }
+ }
+ }
return false;
}
@@ -25,41 +28,46 @@ function Shift_signup_allowed($shift, $angeltype, $user_angeltype = null, $user_
if ($user_shifts == null) {
$user_shifts = Shifts_by_user($user);
- if ($user_shifts === false)
+ if ($user_shifts === false) {
engelsystem_error('Unable to load users shifts.');
+ }
}
$collides = Shift_collides($shift, $user_shifts);
if ($user_angeltype == null) {
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
- if ($user_angeltype === false)
+ if ($user_angeltype === false) {
engelsystem_error('Unable to load user angeltype.');
+ }
}
$signed_up = false;
- foreach ($user_shifts as $user_shift)
+ foreach ($user_shifts as $user_shift) {
if ($user_shift['SID'] == $shift['SID']) {
$signed_up = true;
break;
}
+ }
$needed_angeltypes = NeededAngelTypes_by_shift($shift['SID']);
- if ($needed_angeltypes === false)
+ if ($needed_angeltypes === false) {
engelsystem_error('Unable to load needed angel types.');
-
- // is the shift still running or alternatively is the user shift admin?
+ }
+
+ // is the shift still running or alternatively is the user shift admin?
$user_may_join_shift = true;
// you canot join if shift is full
- foreach ($needed_angeltypes as $needed_angeltype)
+ foreach ($needed_angeltypes as $needed_angeltype) {
if ($needed_angeltype['angel_type_id'] == $angeltype['id']) {
if ($needed_angeltype['taken'] >= $needed_angeltype['count'])
$user_may_join_shift = false;
break;
}
-
- // you cannot join if user alread joined a parallel or this shift
+ }
+
+ // you cannot join if user alread joined a parallel or this shift
$user_may_join_shift &= ! $collides;
// you cannot join if you already singed up for this shift
@@ -69,10 +77,11 @@ function Shift_signup_allowed($shift, $angeltype, $user_angeltype = null, $user_
$user_may_join_shift &= $user_angeltype != null;
// you cannot join if you are not confirmed
- if ($angeltype['restricted'] == 1 && $user_angeltype != null)
+ if ($angeltype['restricted'] == 1 && $user_angeltype != null) {
$user_may_join_shift &= isset($user_angeltype['confirm_user_id']);
-
- // you can only join if the shift is in future
+ }
+
+ // you can only join if the shift is in future
$user_may_join_shift &= time() < $shift['start'];
// User shift admins may join anybody in every shift
@@ -123,10 +132,12 @@ function Shift_update($shift) {
*/
function Shift_update_by_psid($shift) {
$shift_source = sql_select("SELECT `SID` FROM `Shifts` WHERE `PSID`=" . $shift['PSID']);
- if ($shift_source === false)
+ if ($shift_source === false) {
return false;
- if (count($shift_source) == 0)
+ }
+ if (count($shift_source) == 0) {
return null;
+ }
$shift['SID'] = $shift_source[0]['SID'];
return Shift_update($shift);
}
@@ -148,8 +159,9 @@ function Shift_create($shift) {
`PSID`=" . sql_null($shift['PSID']) . ",
`created_by_user_id`='" . sql_escape($user['UID']) . "',
`created_at_timestamp`=" . time());
- if ($result === false)
+ if ($result === false) {
return false;
+ }
return sql_id();
}
@@ -205,8 +217,9 @@ function Shifts_filtered() {
// real request
$shifts_source = sql_select("SELECT `SID` FROM `Shifts`" . $filter);
- if ($shifts_source === false)
+ if ($shifts_source === false) {
return false;
+ }
if (count($shifts_source) > 0) {
return $shifts_source;
}
@@ -227,8 +240,9 @@ function Shift($id) {
WHERE `SID`='" . sql_escape($id) . "'");
$shiftsEntry_source = sql_select("SELECT `id`, `TID` , `UID` , `freeloaded` FROM `ShiftEntry` WHERE `SID`='" . sql_escape($id) . "'");
- if ($shifts_source === false)
+ if ($shifts_source === false) {
return false;
+ }
if (count($shifts_source) > 0) {
$result = $shifts_source[0];
@@ -260,13 +274,15 @@ function Shifts() {
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
JOIN `Room` ON `Room`.`RID` = `Shifts`.`RID`
");
- if ($shifts_source === false)
+ if ($shifts_source === false) {
return false;
+ }
foreach ($shifts_source as &$shift) {
$needed_angeltypes = NeededAngelTypes_by_shift($shift['SID']);
- if ($needed_angeltypes === false)
+ if ($needed_angeltypes === false) {
return false;
+ }
$shift['angeltypes'] = $needed_angeltypes;
}
diff --git a/includes/model/UserAngelTypes_model.php b/includes/model/UserAngelTypes_model.php
index f942483e..d3538f09 100644
--- a/includes/model/UserAngelTypes_model.php
+++ b/includes/model/UserAngelTypes_model.php
@@ -133,8 +133,9 @@ function UserAngelType_create($user, $angeltype) {
INSERT INTO `UserAngelTypes` SET
`user_id`='" . sql_escape($user['UID']) . "',
`angeltype_id`='" . sql_escape($angeltype['id']) . "'");
- if ($result === false)
+ if ($result === false) {
return false;
+ }
return sql_id();
}
@@ -149,10 +150,12 @@ function UserAngelType($user_angeltype_id) {
FROM `UserAngelTypes`
WHERE `id`='" . sql_escape($user_angeltype_id) . "'
LIMIT 1");
- if ($angeltype === false)
+ if ($angeltype === false) {
return false;
- if (count($angeltype) == 0)
+ }
+ if (count($angeltype) == 0) {
return null;
+ }
return $angeltype[0];
}
@@ -169,10 +172,12 @@ function UserAngelType_by_User_and_AngelType($user, $angeltype) {
WHERE `user_id`='" . sql_escape($user['UID']) . "'
AND `angeltype_id`='" . sql_escape($angeltype['id']) . "'
LIMIT 1");
- if ($angeltype === false)
+ if ($angeltype === false) {
return false;
- if (count($angeltype) == 0)
+ }
+ if (count($angeltype) == 0) {
return null;
+ }
return $angeltype[0];
}
?> \ No newline at end of file
diff --git a/includes/model/UserDriverLicenses_model.php b/includes/model/UserDriverLicenses_model.php
index b99c8b1b..19f87e63 100644
--- a/includes/model/UserDriverLicenses_model.php
+++ b/includes/model/UserDriverLicenses_model.php
@@ -6,10 +6,12 @@
*/
function UserDriverLicense($user_id) {
$user_driver_license = sql_select("SELECT * FROM `UserDriverLicenses` WHERE `user_id`='" . sql_escape($user_id) . "'");
- if ($user_driver_license === false)
+ if ($user_driver_license === false) {
return false;
- if (count($user_driver_license) > 0)
+ }
+ if (count($user_driver_license) > 0) {
return $user_driver_license[0];
+ }
return null;
}
diff --git a/includes/model/User_model.php b/includes/model/User_model.php
index 00c3bfdd..3d5416da 100644
--- a/includes/model/User_model.php
+++ b/includes/model/User_model.php
@@ -6,7 +6,7 @@
/**
* Delete a user
- *
+ *
* @param int $user_id
*/
function User_delete($user_id) {
@@ -164,10 +164,12 @@ function User_validate_Nick($nick) {
*/
function User($id) {
$user_source = sql_select("SELECT * FROM `User` WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
- if ($user_source === false)
+ if ($user_source === false) {
return false;
- if (count($user_source) > 0)
+ }
+ if (count($user_source) > 0) {
return $user_source[0];
+ }
return null;
}
@@ -179,10 +181,12 @@ function User($id) {
*/
function mUser_Limit($id) {
$user_source = sql_select("SELECT `UID`, `Nick`, `Name`, `Vorname`, `Telefon`, `DECT`, `Handy`, `email`, `jabber` FROM `User` WHERE `UID`='" . sql_escape($id) . "' LIMIT 1");
- if ($user_source === false)
+ if ($user_source === false) {
return false;
- if (count($user_source) > 0)
+ }
+ if (count($user_source) > 0) {
return $user_source[0];
+ }
return null;
}
@@ -195,10 +199,12 @@ function mUser_Limit($id) {
*/
function User_by_api_key($api_key) {
$user = sql_select("SELECT * FROM `User` WHERE `api_key`='" . sql_escape($api_key) . "' LIMIT 1");
- if ($user === false)
+ if ($user === false) {
return false;
- if (count($user) == 0)
+ }
+ if (count($user) == 0) {
return null;
+ }
return $user[0];
}
@@ -210,10 +216,12 @@ function User_by_api_key($api_key) {
*/
function User_by_email($email) {
$user = sql_select("SELECT * FROM `User` WHERE `email`='" . sql_escape($email) . "' LIMIT 1");
- if ($user === false)
+ if ($user === false) {
return false;
- if (count($user) == 0)
+ }
+ if (count($user) == 0) {
return null;
+ }
return $user[0];
}
@@ -225,10 +233,12 @@ function User_by_email($email) {
*/
function User_by_password_recovery_token($token) {
$user = sql_select("SELECT * FROM `User` WHERE `password_recovery_token`='" . sql_escape($token) . "' LIMIT 1");
- if ($user === false)
+ if ($user === false) {
return false;
- if (count($user) == 0)
+ }
+ if (count($user) == 0) {
return null;
+ }
return $user[0];
}
@@ -240,10 +250,12 @@ function User_by_password_recovery_token($token) {
function User_reset_api_key(&$user, $log = true) {
$user['api_key'] = md5($user['Nick'] . time() . rand());
$result = sql_query("UPDATE `User` SET `api_key`='" . sql_escape($user['api_key']) . "' WHERE `UID`='" . sql_escape($user['UID']) . "' LIMIT 1");
- if ($result === false)
+ if ($result === false) {
return false;
- if ($log)
+ }
+ if ($log) {
engelsystem_log(sprintf("API key resetted (%s).", User_Nick_render($user)));
+ }
}
/**
@@ -254,25 +266,25 @@ function User_reset_api_key(&$user, $log = true) {
function User_generate_password_recovery_token(&$user) {
$user['password_recovery_token'] = md5($user['Nick'] . time() . rand());
$result = sql_query("UPDATE `User` SET `password_recovery_token`='" . sql_escape($user['password_recovery_token']) . "' WHERE `UID`='" . sql_escape($user['UID']) . "' LIMIT 1");
- if ($result === false)
+ if ($result === false) {
return false;
+ }
engelsystem_log("Password recovery for " . User_Nick_render($user) . " started.");
return $user['password_recovery_token'];
}
-
function User_get_eligable_voucher_count(&$user) {
global $voucher_settings;
- $shifts_done = count(ShiftEntries_finished_by_user($user));
-
- $earned_vouchers = $user['got_voucher'] - $voucher_settings['initial_vouchers'];
- $elegible_vouchers = $shifts_done / $voucher_settings['shifts_per_voucher'] - $earned_vouchers;
- if ( $elegible_vouchers < 0) {
- return 0;
- }
-
- return $elegible_vouchers;
+ $shifts_done = count(ShiftEntries_finished_by_user($user));
+
+ $earned_vouchers = $user['got_voucher'] - $voucher_settings['initial_vouchers'];
+ $elegible_vouchers = $shifts_done / $voucher_settings['shifts_per_voucher'] - $earned_vouchers;
+ if ($elegible_vouchers < 0) {
+ return 0;
+ }
+
+ return $elegible_vouchers;
}
?>
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
index fae52713..65abe0f3 100644
--- a/includes/view/AngelTypes_view.php
+++ b/includes/view/AngelTypes_view.php
@@ -21,42 +21,39 @@ function AngelType_name_render($angeltype) {
* @return string
*/
function AngelType_render_membership($user_angeltype) {
- $membership = "";
if ($user_angeltype['user_angeltype_id'] != null) {
if ($user_angeltype['restricted']) {
- if ($user_angeltype['confirm_user_id'] == null)
- $membership = glyph('lock') . _("Unconfirmed");
- elseif ($user_angeltype['coordinator'])
- $membership = glyph_bool(true) . _("Coordinator");
- else
- $membership = glyph_bool(true) . _("Member");
- } elseif ($user_angeltype['coordinator'])
- $membership = glyph_bool(true) . _("Coordinator");
- else
- $membership = glyph_bool(true) . _("Member");
- } else {
- $membership = glyph_bool(false);
+ if ($user_angeltype['confirm_user_id'] == null) {
+ return glyph('lock') . _("Unconfirmed");
+ } elseif ($user_angeltype['coordinator']) {
+ return glyph_bool(true) . _("Coordinator");
+ }
+ return glyph_bool(true) . _("Member");
+ } elseif ($user_angeltype['coordinator']) {
+ return glyph_bool(true) . _("Coordinator");
+ }
+ return glyph_bool(true) . _("Member");
}
- return $membership;
+ return glyph_bool(false);
}
function AngelType_delete_view($angeltype) {
return page_with_title(sprintf(_("Delete angeltype %s"), $angeltype['name']), array(
info(sprintf(_("Do you want to delete angeltype %s?"), $angeltype['name']), true),
- buttons(array(
+ buttons([
button(page_link_to('angeltypes'), _("cancel"), 'cancel'),
button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'] . '&confirmed', _("delete"), 'ok')
- ))
+ ])
));
}
function AngelType_edit_view($name, $restricted, $description, $coordinator_mode, $requires_driver_license) {
return page_with_title(sprintf(_("Edit %s"), $name), array(
- buttons(array(
+ buttons([
button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
- )),
+ ]),
msg(),
- form(array(
+ form([
$coordinator_mode ? form_info(_("Name"), $name) : form_text('name', _("Name"), $name),
$coordinator_mode ? form_info(_("Restricted"), $restricted ? _("Yes") : _("No")) : form_checkbox('restricted', _("Restricted"), $restricted),
$coordinator_mode ? form_info(_("Requires driver license"), $requires_driver_license ? _("Yes") : _("No")) : form_checkbox('requires_driver_license', _("Requires driver license"), $requires_driver_license),
@@ -64,7 +61,7 @@ function AngelType_edit_view($name, $restricted, $description, $coordinator_mode
form_textarea('description', _("Description"), $description),
form_info("", _("Please use markdown for the description.")),
form_submit('submit', _("Save"))
- ))
+ ])
));
}
@@ -73,38 +70,44 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
];
- if ($angeltype['requires_driver_license'])
+ if ($angeltype['requires_driver_license']) {
$buttons[] = button(user_driver_license_edit_link($user), glyph("road") . _("my driving license"));
+ }
- if ($user_angeltype == null)
+ if ($user_angeltype == null) {
$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)
+ } else {
+ if ($angeltype['requires_driver_license'] && $user_driver_license == null) {
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'] && $user_angeltype['confirm_user_id'] == null) {
error(sprintf(_("You are unconfirmed for this angeltype. Please go to the introduction for %s to get confirmed."), $angeltype['name']));
+ }
$buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'], _("leave"), 'cancel');
}
- if ($admin_angeltypes || $coordinator)
+ if ($admin_angeltypes || $coordinator) {
$buttons[] = button(page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], _("edit"), 'edit');
- if ($admin_angeltypes)
+ }
+ if ($admin_angeltypes) {
$buttons[] = button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], _("delete"), 'delete');
+ }
- $page = array(
+ $page = [
msg(),
buttons($buttons)
- );
+ ];
$page[] = '<h3>' . _("Description") . '</h3>';
$parsedown = new Parsedown();
- if ($angeltype['description'] != "")
+ if ($angeltype['description'] != "") {
$page[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
+ }
- $coordinators = array();
- $members_confirmed = array();
- $members_unconfirmed = array();
+ $coordinators = [];
+ $members_confirmed = [];
+ $members_unconfirmed = [];
foreach ($members as $member) {
$member['Nick'] = User_Nick_render($member);
@@ -125,19 +128,21 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
]);
$members_unconfirmed[] = $member;
} elseif ($member['coordinator']) {
- if ($admin_angeltypes)
+ if ($admin_angeltypes) {
$member['actions'] = table_buttons([
button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&coordinator=0', _("Remove coordinator rights"), 'btn-xs')
]);
- else
+ } else {
$member['actions'] = '';
+ }
$coordinators[] = $member;
} else {
- if ($admin_user_angeltypes)
+ if ($admin_user_angeltypes) {
$member['actions'] = table_buttons([
$admin_angeltypes ? button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&coordinator=1', _("Add coordinator rights"), 'btn-xs') : '',
button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], _("remove"), 'btn-xs')
]);
+ }
$members_confirmed[] = $member;
}
}
@@ -167,25 +172,28 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
$page[] = table($table_headers, $coordinators);
}
- if (count($members_confirmed) > 0)
+ if (count($members_confirmed) > 0) {
$members_confirmed[] = [
'Nick' => _('Sum'),
'DECT' => count($members_confirmed),
'actions' => ''
];
+ }
- if (count($members_unconfirmed) > 0)
+ if (count($members_unconfirmed) > 0) {
$members_unconfirmed[] = [
'Nick' => _('Sum'),
'DECT' => count($members_unconfirmed),
'actions' => ''
];
+ }
$page[] = '<h3>' . _("Members") . '</h3>';
- if ($admin_user_angeltypes)
+ if ($admin_user_angeltypes) {
$page[] = buttons([
button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("Add"), 'add')
]);
+ }
$page[] = table($table_headers, $members_confirmed);
if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) {
@@ -206,51 +214,54 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
* @param array $angeltypes
*/
function AngelTypes_list_view($angeltypes, $admin_angeltypes) {
- return page_with_title(angeltypes_title(), array(
+ return page_with_title(angeltypes_title(), [
msg(),
- buttons(array(
+ buttons([
$admin_angeltypes ? button(page_link_to('angeltypes') . '&action=edit', _("New angeltype"), 'add') : '',
button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description"))
- )),
- table(array(
+ ]),
+ table([
'name' => _("Name"),
'restricted' => glyph('lock') . _("Restricted"),
'membership' => _("Membership"),
'actions' => ""
- ), $angeltypes)
- ));
+ ], $angeltypes)
+ ]);
}
function AngelTypes_about_view($angeltypes, $user_logged_in) {
global $faq_url;
- $content = array(
- buttons(array(
+ $content = [
+ buttons([
! $user_logged_in ? button(page_link_to('register'), register_title()) : '',
! $user_logged_in ? button(page_link_to('login'), login_title()) : '',
$user_logged_in ? button(page_link_to('angeltypes'), angeltypes_title(), 'back') : '',
button($faq_url, _("FAQ"), "btn-primary")
- )),
+ ]),
'<p>' . _("Here is the list of teams and their tasks. If you have questions, read the FAQ.") . '</p>',
'<hr />'
- );
+ ];
$parsedown = new Parsedown();
foreach ($angeltypes as $angeltype) {
$content[] = '<h2>' . $angeltype['name'] . '</h2>';
if (isset($angeltype['user_angeltype_id'])) {
- $buttons = array();
- if ($angeltype['user_angeltype_id'] != null)
+ $buttons = [];
+ if ($angeltype['user_angeltype_id'] != null) {
$buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'], _("leave"), 'cancel');
- else
+ } else {
$buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add');
+ }
$content[] = buttons($buttons);
}
- if ($angeltype['restricted'])
+ if ($angeltype['restricted']) {
$content[] = info(_("This angeltype is restricted by double-opt-in by a team coordinator. Please show up at the according introduction meetings."), true);
- if ($angeltype['description'] != "")
+ }
+ if ($angeltype['description'] != "") {
$content[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
+ }
$content[] = '<hr />';
}
diff --git a/includes/view/Questions_view.php b/includes/view/Questions_view.php
index c766125b..bdcb8a86 100644
--- a/includes/view/Questions_view.php
+++ b/includes/view/Questions_view.php
@@ -12,26 +12,26 @@ function Questions_view($open_questions, $answered_questions, $ask_action) {
$question['actions'] = '<a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">' . _("delete") . '</a>';
}
- return page_with_title(questions_title(), array(
+ return page_with_title(questions_title(), [
msg(),
- '<h2>' . _("Open questions") . '</h2>',
- table(array(
+ heading(_("Open questions"), 2),
+ table([
'Question' => _("Question"),
'actions' => ""
- ), $open_questions),
- '<h2>' . _("Answered questions") . '</h2>',
- table(array(
+ ], $open_questions),
+ heading(_("Answered questions"), 2),
+ table([
'Question' => _("Question"),
'answer_user' => _("Answered by"),
'Answer' => _("Answer"),
'actions' => ""
- ), $answered_questions),
- '<h2>' . _("Ask an archangel") . '</h2>',
- form(array(
+ ], $answered_questions),
+ heading(_("Ask an archangel"), 2),
+ form([
form_textarea('question', _("Your Question:"), ""),
form_submit('submit', _("Save"))
- ), $ask_action)
- ));
+ ], $ask_action)
+ ]);
}
?> \ No newline at end of file
diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php
index e1d411cb..c820e983 100644
--- a/includes/view/Rooms_view.php
+++ b/includes/view/Rooms_view.php
@@ -2,8 +2,9 @@
function Room_name_render($room) {
global $privileges;
- if (in_array('admin_rooms', $privileges))
+ if (in_array('admin_rooms', $privileges)) {
return '<a href="' . room_link($room) . '">' . glyph('map-marker') . $room['Name'] . '</a>';
+ }
return glyph('map-marker') . $room['Name'];
}
diff --git a/includes/view/ShiftEntry_view.php b/includes/view/ShiftEntry_view.php
index 9665e426..fab5be66 100644
--- a/includes/view/ShiftEntry_view.php
+++ b/includes/view/ShiftEntry_view.php
@@ -13,16 +13,16 @@
*/
function ShiftEntry_edit_view($angel, $date, $location, $title, $type, $comment, $freeloaded, $freeload_comment, $user_admin_shifts = false) {
if ($user_admin_shifts) {
- $freeload_form = array(
+ $freeload_form = [
form_checkbox('freeloaded', _("Freeloaded"), $freeloaded),
form_textarea('freeload_comment', _("Freeload comment (Only for shift coordination):"), $freeload_comment)
- );
+ ];
} else {
- $freeload_form = array();
+ $freeload_form = [];
}
- return page_with_title(_("Edit shift entry"), array(
+ return page_with_title(_("Edit shift entry"), [
msg(),
- form(array(
+ form([
form_info(_("Angel:"), $angel),
form_info(_("Date, Duration:"), $date),
form_info(_("Location:"), $location),
@@ -31,8 +31,8 @@ function ShiftEntry_edit_view($angel, $date, $location, $title, $type, $comment,
form_textarea('comment', _("Comment (for your eyes only):"), $comment),
join("", $freeload_form),
form_submit('submit', _("Save"))
- ))
- ));
+ ])
+ ]);
}
?> \ No newline at end of file
diff --git a/includes/view/ShiftTypes_view.php b/includes/view/ShiftTypes_view.php
index 10431440..163d6646 100644
--- a/includes/view/ShiftTypes_view.php
+++ b/includes/view/ShiftTypes_view.php
@@ -2,27 +2,29 @@
function ShiftType_name_render($shifttype) {
global $privileges;
- if (in_array('shifttypes', $privileges))
+ if (in_array('shifttypes', $privileges)) {
return '<a href="' . shifttype_link($shifttype) . '">' . $shifttype['name'] . '</a>';
+ }
return $shifttype['name'];
}
function ShiftType_delete_view($shifttype) {
- return page_with_title(sprintf(_("Delete shifttype %s"), $shifttype['name']), array(
+ return page_with_title(sprintf(_("Delete shifttype %s"), $shifttype['name']), [
info(sprintf(_("Do you want to delete shifttype %s?"), $shifttype['name']), true),
- buttons(array(
+ buttons([
button(page_link_to('shifttypes'), _("cancel"), 'cancel'),
button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'] . '&confirmed', _("delete"), 'ok')
- ))
- ));
+ ])
+ ]);
}
function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id) {
$angeltypes_select = [
'' => _('All')
];
- foreach ($angeltypes as $angeltype)
+ foreach ($angeltypes as $angeltype) {
$angeltypes_select[$angeltype['id']] = $angeltype['name'];
+ }
return page_with_title($shifttype_id ? _('Edit shifttype') : _('Create shifttype'), [
msg(),
@@ -42,8 +44,9 @@ function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $s
function ShiftType_view($shifttype, $angeltype) {
$parsedown = new Parsedown();
$title = $shifttype['name'];
- if ($angeltype)
+ if ($angeltype) {
$title .= ' <small>' . sprintf(_('for team %s'), $angeltype['name']) . '</small>';
+ }
return page_with_title($title, [
msg(),
buttons([
diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php
index c67ca740..95282eb5 100644
--- a/includes/view/Shifts_view.php
+++ b/includes/view/Shifts_view.php
@@ -2,10 +2,12 @@
function Shift_editor_info_render($shift) {
$info = [];
- if ($shift['created_by_user_id'] != null)
+ if ($shift['created_by_user_id'] != null) {
$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 ($shift['edited_by_user_id'] != null) {
$info[] = sprintf(glyph('pencil') . _("edited at %s by %s"), date('Y-m-d H:i', $shift['edited_at_timestamp']), User_Nick_render(User($shift['edited_by_user_id'])));
+ }
return join('<br />', $info);
}
@@ -14,32 +16,36 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null,
if ($user_angeltype == null) {
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
- if ($user_angeltype === false)
+ if ($user_angeltype === false) {
engelsystem_error('Unable to load user angeltype.');
+ }
}
- if (Shift_signup_allowed($shift, $angeltype, $user_angeltype, $user_shifts))
+ if (Shift_signup_allowed($shift, $angeltype, $user_angeltype, $user_shifts)) {
return button(page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'], _('Sign up'));
- elseif ($user_angeltype == null)
+ } elseif ($user_angeltype == null) {
return button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], sprintf(_('Become %s'), $angeltype['name']));
- else
- return '';
+ }
+ return '';
}
function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source, $user_shift_admin, $admin_rooms, $admin_shifttypes, $user_shifts, $signed_up) {
$parsedown = new Parsedown();
$angeltypes = [];
- foreach ($angeltypes_source as $angeltype)
+ foreach ($angeltypes_source as $angeltype) {
$angeltypes[$angeltype['id']] = $angeltype;
+ }
$needed_angels = '';
foreach ($shift['NeedAngels'] as $needed_angeltype) {
$class = 'progress-bar-warning';
- if ($needed_angeltype['taken'] == 0)
+ if ($needed_angeltype['taken'] == 0) {
$class = 'progress-bar-danger';
- if ($needed_angeltype['taken'] >= $needed_angeltype['count'])
+ }
+ if ($needed_angeltype['taken'] >= $needed_angeltype['count']) {
$class = 'progress-bar-success';
+ }
$needed_angels .= '<div class="list-group-item">';
$needed_angels .= '<div class="pull-right">' . Shift_signup_button_render($shift, $angeltypes[$needed_angeltype['TID']]) . '</div>';
@@ -51,8 +57,9 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
foreach ($shift['ShiftEntry'] as $shift_entry) {
if ($shift_entry['TID'] == $needed_angeltype['TID']) {
$entry = User_Nick_render(User($shift_entry['UID']));
- if ($shift_entry['freeloaded'])
+ if ($shift_entry['freeloaded']) {
$entry = '<strike>' . $entry . '</strike>';
+ }
if ($user_shift_admin) {
$entry .= ' <div class="btn-group">';
$entry .= button_glyph(page_link_to('user_myshifts') . '&edit=' . $shift_entry['id'] . '&id=' . $shift_entry['UID'], 'pencil', 'btn-xs');
@@ -69,7 +76,6 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
}
return page_with_title($shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', [
-
msg(),
Shift_collides($shift, $user_shifts) ? info(_('This shift collides with one of your shifts.'), true) : '',
$signed_up ? info(_('You are signed up for this shift.'), true) : '',
diff --git a/includes/view/UserAngelTypes_view.php b/includes/view/UserAngelTypes_view.php
index 29bde3c4..802ec5aa 100644
--- a/includes/view/UserAngelTypes_view.php
+++ b/includes/view/UserAngelTypes_view.php
@@ -1,86 +1,88 @@
<?php
+
function UserAngelType_update_view($user_angeltype, $user, $angeltype, $coordinator) {
- return page_with_title($coordinator ? _("Add coordinator rights") : _("Remove coordinator rights"), array(
+ return page_with_title($coordinator ? _("Add coordinator rights") : _("Remove coordinator rights"), [
msg(),
info(sprintf($coordinator ? _("Do you really want to add coordinator rights for %s to %s?") : _("Do you really want to remove coordinator rights for %s from %s?"), $angeltype['name'], User_Nick_render($user)), true),
- buttons(array(
+ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $user_angeltype['id'] . '&coordinator=' . ($coordinator ? '1' : '0') . '&confirmed', _("yes"), 'ok')
- ))
- ));
+ ])
+ ]);
}
function UserAngelTypes_delete_all_view($angeltype) {
- return page_with_title(_("Deny all users"), array(
+ return page_with_title(_("Deny all users"), [
msg(),
info(sprintf(_("Do you really want to deny all users for %s?"), $angeltype['name']), true),
- buttons(array(
+ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
button(page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'] . '&confirmed', _("yes"), 'ok')
- ))
- ));
+ ])
+ ]);
}
function UserAngelTypes_confirm_all_view($angeltype) {
- return page_with_title(_("Confirm all users"), array(
+ return page_with_title(_("Confirm all users"), [
msg(),
info(sprintf(_("Do you really want to confirm all users for %s?"), $angeltype['name']), true),
- buttons(array(
+ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
button(page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'] . '&confirmed', _("yes"), 'ok')
- ))
- ));
+ ])
+ ]);
}
function UserAngelType_confirm_view($user_angeltype, $user, $angeltype) {
- return page_with_title(_("Confirm angeltype for user"), array(
+ return page_with_title(_("Confirm angeltype for user"), [
msg(),
info(sprintf(_("Do you really want to confirm %s for %s?"), User_Nick_render($user), $angeltype['name']), true),
- buttons(array(
+ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
button(page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed', _("yes"), 'ok')
- ))
- ));
+ ])
+ ]);
}
function UserAngelType_delete_view($user_angeltype, $user, $angeltype) {
- return page_with_title(_("Remove angeltype"), array(
+ return page_with_title(_("Remove angeltype"), [
msg(),
info(sprintf(_("Do you really want to delete %s from %s?"), User_Nick_render($user), $angeltype['name']), true),
- buttons(array(
+ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed', _("yes"), 'ok')
- ))
- ));
+ ])
+ ]);
}
function UserAngelType_add_view($angeltype, $users_source, $user_id) {
- $users = array();
- foreach ($users_source as $user_source)
+ $users = [];
+ foreach ($users_source as $user_source) {
$users[$user_source['UID']] = User_Nick_render($user_source);
+ }
- return page_with_title(_("Add user to angeltype"), array(
+ return page_with_title(_("Add user to angeltype"), [
msg(),
- buttons(array(
+ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("back"), 'back')
- )),
- form(array(
+ ]),
+ form([
form_info(_("Angeltype"), $angeltype['name']),
form_select('user_id', _("User"), $users, $user_id),
form_submit('submit', _("Add"))
- ))
- ));
+ ])
+ ]);
}
function UserAngelType_join_view($user, $angeltype) {
- return page_with_title(sprintf(_("Become a %s"), $angeltype['name']), array(
+ return page_with_title(sprintf(_("Become a %s"), $angeltype['name']), [
msg(),
info(sprintf(_("Do you really want to add %s to %s?"), User_Nick_render($user), $angeltype['name']), true),
- buttons(array(
+ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'] . '&user_id=' . $user['UID'] . '&confirmed', _("save"), 'ok')
- ))
- ));
+ ])
+ ]);
}
?> \ No newline at end of file
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index 4f61006e..5c258fc7 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -3,7 +3,7 @@
/**
* Available T-Shirt sizes
*/
-$tshirt_sizes = array(
+$tshirt_sizes = [
'' => _("Please select..."),
'S' => "S",
'M' => "M",
@@ -17,7 +17,7 @@ $tshirt_sizes = array(
'M-G' => "M Girl",
'L-G' => "L Girl",
'XL-G' => "XL Girl"
-);
+];
/**
* Displays the welcome message to the user and shows a login form.
@@ -112,12 +112,12 @@ function Users_view($users, $order_by, $arrived_count, $active_count, $force_act
'actions' => '<strong>' . count($users) . '</strong>'
);
- return page_with_title(_('All users'), array(
+ return page_with_title(_('All users'), [
msg(),
- buttons(array(
+ buttons([
button(page_link_to('register'), glyph('plus') . _('New user'))
- )),
- table(array(
+ ]),
+ table([
'Nick' => Users_table_header_link('Nick', _('Nick'), $order_by),
'Vorname' => Users_table_header_link('Vorname', _('Prename'), $order_by),
'Name' => Users_table_header_link('Name', _('Name'), $order_by),
@@ -131,8 +131,8 @@ function Users_view($users, $order_by, $arrived_count, $active_count, $force_act
'Size' => Users_table_header_link('Size', _('Size'), $order_by),
'lastLogIn' => Users_table_header_link('lastLogIn', _('Last login'), $order_by),
'actions' => ''
- ), $users)
- ));
+ ], $users)
+ ]);
}
function Users_table_header_link($column, $label, $order_by) {
@@ -141,24 +141,28 @@ function Users_table_header_link($column, $label, $order_by) {
function User_shift_state_render($user) {
$upcoming_shifts = ShiftEntries_upcoming_for_user($user);
- if ($upcoming_shifts === false)
+ if ($upcoming_shifts === false) {
return false;
+ }
- if (count($upcoming_shifts) == 0)
+ if (count($upcoming_shifts) == 0) {
return '<span class="text-success">' . _("Free") . '</span>';
+ }
- if ($upcoming_shifts[0]['start'] > time())
- if ($upcoming_shifts[0]['start'] - time() > 3600)
+ 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
+ } else {
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)
+ if (time() < $halfway) {
return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Shift starts %c") . '</span>';
- else
+ } else {
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) {
@@ -166,76 +170,83 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
$user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']);
- $myshifts_table = array();
+ $myshifts_table = [];
$timesum = 0;
foreach ($shifts as $shift) {
$shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>';
- if ($shift['title'])
+ if ($shift['title']) {
$shift_info .= '<br /><a href="' . shift_link($shift) . '">' . $shift['title'] . '</a>';
+ }
foreach ($shift['needed_angeltypes'] as $needed_angel_type) {
$shift_info .= '<br><b>' . $needed_angel_type['name'] . ':</b> ';
- $shift_entries = array();
+ $shift_entries = [];
foreach ($needed_angel_type['users'] as $user_shift) {
$member = User_Nick_render($user_shift);
- if ($user_shift['freeloaded'])
+ if ($user_shift['freeloaded']) {
$member = '<strike>' . $member . '</strike>';
+ }
$shift_entries[] = $member;
}
$shift_info .= join(", ", $shift_entries);
}
- $myshift = array(
+ $myshift = [
'date' => date("Y-m-d", $shift['start']),
'time' => date("H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']),
'room' => $shift['Name'],
'shift_info' => $shift_info,
'comment' => $shift['Comment']
- );
+ ];
if ($shift['freeloaded']) {
- if (in_array("user_shifts_admin", $privileges))
+ if (in_array("user_shifts_admin", $privileges)) {
$myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . ': ' . $shift['freeload_comment'] . '</p>';
- else
+ } else {
$myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . '</p>';
+ }
}
$myshift['actions'] = [
button(shift_link($shift), glyph('eye-open') . _('view'), 'btn-xs')
];
- if ($its_me || in_array('user_shifts_admin', $privileges))
+ if ($its_me || in_array('user_shifts_admin', $privileges)) {
$myshift['actions'][] = button(page_link_to('user_myshifts') . '&edit=' . $shift['id'] . '&id=' . $user_source['UID'], glyph('edit') . _('edit'), 'btn-xs');
- if (($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600) || in_array('user_shifts_admin', $privileges))
+ }
+ if (($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600) || in_array('user_shifts_admin', $privileges)) {
$myshift['actions'][] = button(page_link_to('user_myshifts') . ((! $its_me) ? '&id=' . $user_source['UID'] : '') . '&cancel=' . $shift['id'], glyph('trash') . _('sign off'), 'btn-xs');
+ }
$myshift['actions'] = table_buttons($myshift['actions']);
- if ($shift['freeloaded'])
+ if ($shift['freeloaded']) {
$timesum += (- 2 * ($shift['end'] - $shift['start']));
- else
+ } else {
$timesum += ($shift['end'] - $shift['start']);
+ }
$myshifts_table[] = $myshift;
}
- if (count($myshifts_table) > 0)
- $myshifts_table[] = array(
+ if (count($myshifts_table) > 0) {
+ $myshifts_table[] = [
'date' => '<b>' . _("Sum:") . '</b>',
'time' => "<b>" . round($timesum / 3600, 1) . " h</b>",
'room' => "",
'shift_info' => "",
'comment' => "",
'actions' => ""
- );
+ ];
+ }
- return page_with_title('<span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . ' <small>' . $user_name . '</small>', array(
+ return page_with_title('<span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . ' <small>' . $user_name . '</small>', [
msg(),
- div('row', array(
- div('col-md-3', array(
+ div('row', [
+ div('col-md-3', [
'<h1>',
'<span class="glyphicon glyphicon-phone"></span>',
$user_source['DECT'],
'</h1>'
- )),
- div('col-md-3', array(
+ ]),
+ div('col-md-3', [
'<h4>' . _("User state") . '</h4>',
($admin_user_privilege && $freeloader) ? '<span class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"></span> ' . _("Freeloader") . '</span><br />' : '',
$user_source['Gekommen'] ? User_shift_state_render($user_source) . '<br />' : '',
@@ -243,19 +254,19 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
$admin_user_privilege ? ($user_source['got_voucher'] > 0 ? '<br /><span class="text-success">' . glyph('cutlery') . sprintf(ngettext("Got %s voucher", "Got %s vouchers", $user_source['got_voucher']), $user_source['got_voucher']) . '</span><br />' : '<br /><span class="text-danger">' . _("Got no vouchers") . '</span><br />') : '',
($user_source['Gekommen'] && $admin_user_privilege && $user_source['Aktiv']) ? ' <span class="text-success">' . _("Active") . '</span>' : '',
($user_source['Gekommen'] && $admin_user_privilege && $user_source['Tshirt']) ? ' <span class="text-success">' . _("T-Shirt") . '</span>' : ''
- )),
- div('col-md-3', array(
+ ]),
+ div('col-md-3', [
'<h4>' . _("Angeltypes") . '</h4>',
User_angeltypes_render($user_angeltypes)
- )),
- div('col-md-3', array(
+ ]),
+ div('col-md-3', [
'<h4>' . _("Rights") . '</h4>',
User_groups_render($user_groups)
- ))
- )),
- div('row space-top', array(
- div('col-md-12', array(
- buttons(array(
+ ])
+ ]),
+ div('row space-top', [
+ div('col-md-12', [
+ buttons([
$admin_user_privilege ? button(page_link_to('admin_user') . '&id=' . $user_source['UID'], glyph("edit") . _("edit")) : '',
$admin_user_privilege ? button(user_driver_license_edit_link($user_source), glyph("road") . _("driving license")) : '',
($admin_user_privilege && ! $user_source['Gekommen']) ? button(page_link_to('admin_arrive') . '&arrived=' . $user_source['UID'], _("arrived")) : '',
@@ -264,63 +275,65 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
$its_me ? button(page_link_to('ical') . '&key=' . $user_source['api_key'], glyph('calendar') . _("iCal Export")) : '',
$its_me ? button(page_link_to('shifts_json_export') . '&key=' . $user_source['api_key'], glyph('export') . _("JSON Export")) : '',
$its_me ? button(page_link_to('user_myshifts') . '&reset', glyph('repeat') . _('Reset API key')) : ''
- ))
- ))
- )),
+ ])
+ ])
+ ]),
($its_me || $admin_user_privilege) ? '<h2>' . _("Shifts") . '</h2>' : '',
- ($its_me || $admin_user_privilege) ? table(array(
+ ($its_me || $admin_user_privilege) ? table([
'date' => _("Day"),
'time' => _("Time"),
'room' => _("Location"),
'shift_info' => _("Name &amp; workmates"),
'comment' => _("Comment"),
'actions' => _("Action")
- ), $myshifts_table) : '',
+ ], $myshifts_table) : '',
$its_me ? info(glyph('info-sign') . _("Your night shifts between 2 and 8 am count twice."), true) : '',
$its_me && count($shifts) == 0 ? error(sprintf(_("Go to the <a href=\"%s\">shifts table</a> to sign yourself up for some shifts."), page_link_to('user_shifts')), true) : ''
- ));
+ ]);
}
/**
* View for password recovery step 1: E-Mail
*/
function User_password_recovery_view() {
- return page_with_title(user_password_recovery_title(), array(
+ return page_with_title(user_password_recovery_title(), [
msg(),
_("We will send you an e-mail with a password recovery link. Please use the email address you used for registration."),
- form(array(
+ form([
form_text('email', _("E-Mail"), ""),
form_submit('submit', _("Recover"))
- ))
- ));
+ ])
+ ]);
}
/**
* View for password recovery step 2: New password
*/
function User_password_set_view() {
- return page_with_title(user_password_recovery_title(), array(
+ return page_with_title(user_password_recovery_title(), [
msg(),
_("Please enter a new password."),
- form(array(
+ form([
form_password('password', _("Password")),
form_password('password2', _("Confirm password")),
form_submit('submit', _("Save"))
- ))
- ));
+ ])
+ ]);
}
function User_angeltypes_render($user_angeltypes) {
- $output = array();
+ $output = [];
foreach ($user_angeltypes as $angeltype) {
$class = "";
- if ($angeltype['restricted'] == 1)
- if ($angeltype['confirm_user_id'] != null)
+ if ($angeltype['restricted'] == 1) {
+ if ($angeltype['confirm_user_id'] != null) {
$class = 'text-success';
- else
+ } else {
$class = 'text-warning';
- else
+ }
+ } else {
$class = 'text-success';
+ }
$output[] = '<a href="' . angeltype_link($angeltype['id']) . '" class="' . $class . '">' . ($angeltype['coordinator'] ? glyph('education') : '') . $angeltype['name'] . '</a>';
}
return join('<br />', $output);