summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBot <bot@myigel.name>2017-12-25 23:12:52 +0100
committerIgor Scheller <igor.scheller@igorshp.de>2017-12-25 23:51:15 +0100
commit952c7892f3ac7bfadf8419062e44ff1af66ecc57 (patch)
tree69a85e8e4719801a064b8fa2d521fe000f959cd5
parent879918864a9c6da0fe9be1aca6c443ec8df0afc3 (diff)
Formatting & Docstrings
-rw-r--r--.gitlab-ci.yml2
-rw-r--r--README.md2
-rw-r--r--db/update.sql4
-rw-r--r--includes/controller/angeltypes_controller.php34
-rw-r--r--includes/controller/event_config_controller.php7
-rw-r--r--includes/controller/public_dashboard_controller.php47
-rw-r--r--includes/controller/shift_entries_controller.php181
-rw-r--r--includes/controller/shifts_controller.php16
-rw-r--r--includes/controller/user_angeltypes_controller.php13
-rw-r--r--includes/controller/users_controller.php7
-rw-r--r--includes/helper/email_helper.php5
-rw-r--r--includes/includes.php1
-rw-r--r--includes/mailer/shifts_mailer.php11
-rw-r--r--includes/model/AngelType_model.php13
-rw-r--r--includes/model/NeededAngelTypes_model.php12
-rw-r--r--includes/model/Room_model.php66
-rw-r--r--includes/model/ShiftEntry_model.php15
-rw-r--r--includes/model/ShiftSignupState.php8
-rw-r--r--includes/model/ShiftTypes_model.php2
-rw-r--r--includes/model/ShiftsFilter.php1
-rw-r--r--includes/model/Shifts_model.php75
-rw-r--r--includes/model/Stats.php44
-rw-r--r--includes/model/UserAngelTypes_model.php8
-rw-r--r--includes/model/UserGroups_model.php2
-rw-r--r--includes/model/User_model.php32
-rw-r--r--includes/pages/admin_active.php3
-rw-r--r--includes/pages/admin_groups.php6
-rw-r--r--includes/pages/admin_import.php20
-rw-r--r--includes/pages/admin_questions.php4
-rw-r--r--includes/pages/admin_rooms.php37
-rw-r--r--includes/pages/admin_shifts.php36
-rw-r--r--includes/pages/admin_user.php17
-rw-r--r--includes/pages/guest_login.php3
-rw-r--r--includes/pages/guest_stats.php6
-rw-r--r--includes/pages/user_atom.php10
-rw-r--r--includes/pages/user_ical.php2
-rw-r--r--includes/pages/user_news.php17
-rw-r--r--includes/pages/user_settings.php4
-rw-r--r--includes/pages/user_shifts.php35
-rw-r--r--includes/sys_auth.php12
-rw-r--r--includes/sys_form.php24
-rw-r--r--includes/sys_menu.php34
-rw-r--r--includes/sys_template.php36
-rw-r--r--includes/view/AngelTypes_view.php85
-rw-r--r--includes/view/EventConfig_view.php11
-rw-r--r--includes/view/PublicDashboard_view.php28
-rw-r--r--includes/view/Rooms_view.php38
-rw-r--r--includes/view/ShiftCalendarLane.php2
-rw-r--r--includes/view/ShiftCalendarRenderer.php16
-rw-r--r--includes/view/ShiftCalendarShiftRenderer.php44
-rw-r--r--includes/view/ShiftEntry_view.php153
-rw-r--r--includes/view/Shifts_view.php19
-rw-r--r--includes/view/UserAngelTypes_view.php18
-rw-r--r--includes/view/UserDriverLicenses_view.php6
-rw-r--r--includes/view/UserHintsRenderer.php4
-rw-r--r--includes/view/User_view.php110
-rw-r--r--src/Database/DatabaseServiceProvider.php4
-rw-r--r--src/Database/Db.php2
-rw-r--r--src/Exceptions/Handlers/HandlerInterface.php1
-rw-r--r--src/Exceptions/Handlers/Whoops.php5
60 files changed, 947 insertions, 513 deletions
diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml
index 7b645edc..8018543b 100644
--- a/.gitlab-ci.yml
+++ b/.gitlab-ci.yml
@@ -42,7 +42,7 @@ before_script:
.test_template: &test_definition
stage: test
artifacts:
- name: "${CI_JOB_NAME}_${CI_PROJECT_ID}_${PHP_VERSION}"
+ name: "${CI_JOB_NAME}_${CI_PROJECT_ID}"
expire_in: 1 week
paths:
- ./coverage/
diff --git a/README.md b/README.md
index b5716436..662d994c 100644
--- a/README.md
+++ b/README.md
@@ -24,7 +24,7 @@ To report bugs use [engelsystem/issues](https://github.com/engelsystem/engelsyst
On production systems it is recommended to use
```bash
composer install --no-dev
- composerdump-autoload --optimize
+ composer dump-autoload --optimize
```
to install the engelsystem
* The webserver must have write access to the 'import' directory and read access for all other directories
diff --git a/db/update.sql b/db/update.sql
index 6e1c6dc5..212cd97e 100644
--- a/db/update.sql
+++ b/db/update.sql
@@ -41,11 +41,11 @@ ALTER TABLE `Room` DROP `Number`;
ALTER TABLE `Room` DROP `show`;
ALTER TABLE `Room` DROP `Man`;
ALTER TABLE `Room` ADD `from_frab` BOOLEAN NOT NULL AFTER `FromPentabarf`;
-update Room set `from_frab`=(`FromPentabarf`='Y');
+UPDATE Room SET `from_frab` = (`FromPentabarf` = 'Y');
ALTER TABLE `Room` DROP `FromPentabarf`;
ALTER TABLE `Room` ADD `map_url` VARCHAR(300) NULL AFTER `from_frab`;
ALTER TABLE `Room` ADD `description` TEXT NULL AFTER `map_url`;
-- Dashboard
ALTER TABLE `AngelTypes` ADD `show_on_dashboard` BOOLEAN NOT NULL AFTER `contact_email`;
-UPDATE `AngelTypes` SET `show_on_dashboard`=TRUE;
+UPDATE `AngelTypes` SET `show_on_dashboard` = TRUE;
diff --git a/includes/controller/angeltypes_controller.php b/includes/controller/angeltypes_controller.php
index 48b81b9f..399930c2 100644
--- a/includes/controller/angeltypes_controller.php
+++ b/includes/controller/angeltypes_controller.php
@@ -2,6 +2,7 @@
use Engelsystem\ShiftsFilter;
use Engelsystem\ShiftsFilterRenderer;
+
/**
* Text for Angeltype related links.
*
@@ -39,8 +40,8 @@ function angeltypes_controller()
/**
* Path to angeltype view.
*
- * @param int $angeltype_id AngelType id
- * @param array $params additional params
+ * @param int $angeltype_id AngelType id
+ * @param array $params additional params
* @return string
*/
function angeltype_link($angeltype_id, $params = [])
@@ -187,17 +188,18 @@ function angeltype_controller()
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
$user_driver_license = UserDriverLicense($user['UID']);
$members = Users_by_angeltype($angeltype);
-
+
$days = angeltype_controller_shiftsFilterDays($angeltype);
$shiftsFilter = angeltype_controller_shiftsFilter($angeltype, $days);
-
+
$shiftsFilterRenderer = new ShiftsFilterRenderer($shiftsFilter);
$shiftsFilterRenderer->enableDaySelection($days);
-
+
$shiftCalendarRenderer = shiftCalendarRendererByShiftFilter($shiftsFilter);
$request = request();
$tab = 0;
- if($request->has('shifts_filter_day')) {
+
+ if ($request->has('shifts_filter_day')) {
$tab = 1;
}
@@ -221,11 +223,12 @@ function angeltype_controller()
/**
* On which days do shifts for this angeltype occur? Needed for shiftCalendar.
- *
- * @param Angeltype $angeltype
+ *
+ * @param array $angeltype
* @return array
*/
-function angeltype_controller_shiftsFilterDays($angeltype) {
+function angeltype_controller_shiftsFilterDays($angeltype)
+{
$all_shifts = Shifts_by_angeltype($angeltype);
$days = [];
foreach ($all_shifts as $shift) {
@@ -239,20 +242,21 @@ function angeltype_controller_shiftsFilterDays($angeltype) {
/**
* Sets up the shift filter for the angeltype.
- *
- * @param Angeltype $angeltype
+ *
+ * @param array $angeltype
* @param array $days
* @return ShiftsFilter
*/
-function angeltype_controller_shiftsFilter($angeltype, $days) {
+function angeltype_controller_shiftsFilter($angeltype, $days)
+{
global $privileges;
-
+
$request = request();
$shiftsFilter = new ShiftsFilter(
in_array('user_shifts_admin', $privileges),
Room_ids(),
[$angeltype['id']]
- );
+ );
$selected_day = date('Y-m-d');
if (!empty($days)) {
$selected_day = $days[0];
@@ -262,7 +266,7 @@ function angeltype_controller_shiftsFilter($angeltype, $days) {
}
$shiftsFilter->setStartTime(parse_date('Y-m-d H:i', $selected_day . ' 00:00'));
$shiftsFilter->setEndTime(parse_date('Y-m-d H:i', $selected_day . ' 23:59'));
-
+
return $shiftsFilter;
}
diff --git a/includes/controller/event_config_controller.php b/includes/controller/event_config_controller.php
index aa328802..4422f046 100644
--- a/includes/controller/event_config_controller.php
+++ b/includes/controller/event_config_controller.php
@@ -101,9 +101,10 @@ function event_config_edit_controller()
);
engelsystem_log(
- sprintf('Changed event config: %s, %s, %s, %s, %s, %s',
- $event_name,
- $event_welcome_msg,
+ sprintf(
+ 'Changed event config: %s, %s, %s, %s, %s, %s',
+ $event_name,
+ $event_welcome_msg,
date('Y-m-d', $buildup_start_date),
date('Y-m-d', $event_start_date),
date('Y-m-d', $event_end_date),
diff --git a/includes/controller/public_dashboard_controller.php b/includes/controller/public_dashboard_controller.php
index 7d652a64..23d5a4d6 100644
--- a/includes/controller/public_dashboard_controller.php
+++ b/includes/controller/public_dashboard_controller.php
@@ -2,25 +2,27 @@
/**
* Loads all data for the public dashboard
+ *
+ * @return array
*/
function public_dashboard_controller()
{
$stats = [
'needed-3-hours' => stats_angels_needed_three_hours(),
- 'needed-night' => stats_angels_needed_for_nightshifts(),
+ 'needed-night' => stats_angels_needed_for_nightshifts(),
'angels-working' => stats_currently_working(),
- 'hours-to-work' => stats_hours_to_work()
+ 'hours-to-work' => stats_hours_to_work()
];
-
+
$free_shifts_source = Shifts_free(time(), time() + 12 * 60 * 60);
$free_shifts = [];
foreach ($free_shifts_source as $shift) {
$free_shift = public_dashboard_controller_free_shift($shift);
- if(count($free_shift['needed_angels']) > 0) {
+ if (count($free_shift['needed_angels']) > 0) {
$free_shifts[] = $free_shift;
}
}
-
+
return [
_('Public Dashboard'),
public_dashboard_view($stats, $free_shifts)
@@ -30,41 +32,43 @@ function public_dashboard_controller()
/**
* Gathers information for free shifts to display.
*
- * @param array $shift
+ * @param array $shift
+ * @return array
*/
function public_dashboard_controller_free_shift($shift)
{
$shifttype = ShiftType($shift['shifttype_id']);
$room = Room($shift['RID']);
-
+
$free_shift = [
- 'SID' => $shift['SID'],
- 'style' => 'default',
- 'start' => date('H:i', $shift['start']),
- 'end' => date('H:i', $shift['end']),
- 'duration' => round(($shift['end'] - $shift['start']) / 3600),
+ 'SID' => $shift['SID'],
+ 'style' => 'default',
+ 'start' => date('H:i', $shift['start']),
+ 'end' => date('H:i', $shift['end']),
+ 'duration' => round(($shift['end'] - $shift['start']) / 3600),
'shifttype_name' => $shifttype['name'],
- 'title' => $shift['title'],
- 'room_name' => $room['Name'],
- 'needed_angels' => []
+ 'title' => $shift['title'],
+ 'room_name' => $room['Name'],
+ 'needed_angels' => []
];
-
+
if (time() + 3 * 60 * 60 > $shift['start']) {
$free_shift['style'] = 'warning';
}
if (time() > $shift['start']) {
$free_shift['style'] = 'danger';
}
-
+
$free_shift['needed_angels'] = public_dashboard_needed_angels($shift['NeedAngels']);
-
+
return $free_shift;
}
/**
* Gathers information for needed angels on dashboard
*
- * @param array $needed_angels
+ * @param array $needed_angels
+ * @return array
*/
function public_dashboard_needed_angels($needed_angels)
{
@@ -75,7 +79,7 @@ function public_dashboard_needed_angels($needed_angels)
$angeltype = AngelType($needed_angel['TID']);
if ($angeltype['show_on_dashboard']) {
$result[] = [
- 'need' => $need,
+ 'need' => $need,
'angeltype_name' => $angeltype['name']
];
}
@@ -86,9 +90,10 @@ function public_dashboard_needed_angels($needed_angels)
/**
* Returns url to public dashboard
+ *
+ * @return string
*/
function public_dashboard_link()
{
return page_link_to('public-dashboard');
}
-?> \ No newline at end of file
diff --git a/includes/controller/shift_entries_controller.php b/includes/controller/shift_entries_controller.php
index 8dbf03ef..c20e48b4 100644
--- a/includes/controller/shift_entries_controller.php
+++ b/includes/controller/shift_entries_controller.php
@@ -1,18 +1,21 @@
<?php
+
use Engelsystem\ShiftSignupState;
/**
* Route shift entry actions.
+ *
+ * @return array
*/
function shift_entries_controller()
{
global $user;
-
+
$action = strip_request_item('action');
if ($action == null) {
redirect(user_link($user));
}
-
+
switch ($action) {
case 'create':
return shift_entry_create_controller();
@@ -25,35 +28,37 @@ function shift_entries_controller()
/**
* Sign up for a shift.
+ *
+ * @return array
*/
function shift_entry_create_controller()
{
global $privileges, $user;
$request = request();
-
+
if (User_is_freeloader($user)) {
redirect(page_link_to('user_myshifts'));
}
-
+
$shift = Shift($request->input('shift_id'));
if ($shift == null) {
redirect(user_link($user));
}
-
+
$angeltype = AngelType($request->input('angeltype_id'));
-
+
if (in_array('user_shifts_admin', $privileges)) {
return shift_entry_create_controller_admin($shift, $angeltype);
}
-
+
if ($angeltype == null) {
redirect(user_link($user));
}
-
+
if (User_is_AngelType_supporter($user, $angeltype)) {
return shift_entry_create_controller_supporter($shift, $angeltype);
}
-
+
return shift_entry_create_controller_user($shift, $angeltype);
}
@@ -61,58 +66,59 @@ function shift_entry_create_controller()
* Sign up for a shift.
* Case: Admin
*
- * @param array $shift
- * @param array $angeltype
+ * @param array $shift
+ * @param array $angeltype
+ * @return array
*/
function shift_entry_create_controller_admin($shift, $angeltype)
{
global $user;
$request = request();
-
+
$signup_user = $user;
if ($request->has('user_id')) {
$signup_user = User($request->input('user_id'));
}
- if($signup_user == null) {
+ if ($signup_user == null) {
redirect(shift_link($shift));
}
-
+
$angeltypes = AngelTypes();
- if($request->has('angeltype_id')) {
+ if ($request->has('angeltype_id')) {
$angeltype = AngelType($request->input('angeltype_id'));
}
- if($angeltype == null) {
- if(count($angeltypes) == 0) {
+ if ($angeltype == null) {
+ if (count($angeltypes) == 0) {
redirect(shift_link($shift));
}
$angeltype = $angeltypes[0];
}
-
+
if ($request->has('submit')) {
ShiftEntry_create([
- 'SID' => $shift['SID'],
- 'TID' => $angeltype['id'],
- 'UID' => $signup_user['UID'],
- 'Comment' => '',
- 'freeloaded' => false,
+ 'SID' => $shift['SID'],
+ 'TID' => $angeltype['id'],
+ 'UID' => $signup_user['UID'],
+ 'Comment' => '',
+ 'freeloaded' => false,
'freeload_comment' => ''
]);
-
+
success(sprintf(_('%s has been subscribed to the shift.'), User_Nick_render($signup_user)));
redirect(shift_link($shift));
}
-
+
$users = Users();
$users_select = [];
foreach ($users as $u) {
$users_select[$u['UID']] = $u['Nick'];
}
-
+
$angeltypes_select = [];
- foreach($angeltypes as $a) {
+ foreach ($angeltypes as $a) {
$angeltypes_select[$a['id']] = $a['name'];
}
-
+
$room = Room($shift['RID']);
return [
ShiftEntry_create_title(),
@@ -124,53 +130,62 @@ function shift_entry_create_controller_admin($shift, $angeltype)
* Sign up for a shift.
* Case: Supporter
*
- * @param array $shift
- * @param array $angeltype
+ * @param array $shift
+ * @param array $angeltype
+ * @return array
*/
function shift_entry_create_controller_supporter($shift, $angeltype)
{
global $user;
$request = request();
-
+
$signup_user = $user;
if ($request->has('user_id')) {
$signup_user = User($request->input('user_id'));
}
- if (! UserAngelType_exists($signup_user, $angeltype)) {
+ if (!UserAngelType_exists($signup_user, $angeltype)) {
error(_('User is not in angeltype.'));
redirect(shift_link($shift));
}
-
+
$needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype);
$shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $angeltype['id']);
- $shift_signup_state = Shift_signup_allowed($signup_user, $shift, $angeltype, null, null, $needed_angeltype, $shift_entries);
- if (! $shift_signup_state->isSignupAllowed()) {
+ $shift_signup_state = Shift_signup_allowed(
+ $signup_user,
+ $shift,
+ $angeltype,
+ null,
+ null,
+ $needed_angeltype,
+ $shift_entries
+ );
+ if (!$shift_signup_state->isSignupAllowed()) {
if ($shift_signup_state->getState() == ShiftSignupState::OCCUPIED) {
error(_('This shift is already occupied.'));
}
redirect(shift_link($shift));
}
-
+
if ($request->has('submit')) {
ShiftEntry_create([
- 'SID' => $shift['SID'],
- 'TID' => $angeltype['id'],
- 'UID' => $signup_user['UID'],
- 'Comment' => '',
- 'freeloaded' => false,
+ 'SID' => $shift['SID'],
+ 'TID' => $angeltype['id'],
+ 'UID' => $signup_user['UID'],
+ 'Comment' => '',
+ 'freeloaded' => false,
'freeload_comment' => ''
]);
-
+
success(sprintf(_('%s has been subscribed to the shift.'), User_Nick_render($signup_user)));
redirect(shift_link($shift));
}
-
+
$users = Users_by_angeltype($angeltype);
$users_select = [];
foreach ($users as $u) {
$users_select[$u['UID']] = $u['Nick'];
}
-
+
$room = Room($shift['RID']);
return [
ShiftEntry_create_title(),
@@ -180,9 +195,11 @@ function shift_entry_create_controller_supporter($shift, $angeltype)
/**
* Generates an error message for the given shift signup state.
+ *
* @param ShiftSignupState $shift_signup_state
*/
-function shift_entry_error_message(ShiftSignupState $shift_signup_state) {
+function shift_entry_error_message(ShiftSignupState $shift_signup_state)
+{
if ($shift_signup_state->getState() == ShiftSignupState::ANGELTYPE) {
error(_('You need be accepted member of the angeltype.'));
} elseif ($shift_signup_state->getState() == ShiftSignupState::COLLIDES) {
@@ -202,43 +219,52 @@ function shift_entry_error_message(ShiftSignupState $shift_signup_state) {
* Sign up for a shift.
* Case: User
*
- * @param array $shift
- * @param array $angeltype
+ * @param array $shift
+ * @param array $angeltype
+ * @return array
*/
function shift_entry_create_controller_user($shift, $angeltype)
{
global $user;
$request = request();
-
+
$signup_user = $user;
$needed_angeltype = NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype);
$shift_entries = ShiftEntries_by_shift_and_angeltype($shift['SID'], $angeltype['id']);
- $shift_signup_state = Shift_signup_allowed($signup_user, $shift, $angeltype, null, null, $needed_angeltype, $shift_entries);
- if (! $shift_signup_state->isSignupAllowed()) {
+ $shift_signup_state = Shift_signup_allowed(
+ $signup_user,
+ $shift,
+ $angeltype,
+ null,
+ null,
+ $needed_angeltype,
+ $shift_entries
+ );
+ if (!$shift_signup_state->isSignupAllowed()) {
shift_entry_error_message($shift_signup_state);
redirect(shift_link($shift));
}
-
+
$comment = '';
if ($request->has('submit')) {
$comment = strip_request_item_nl('comment');
ShiftEntry_create([
- 'SID' => $shift['SID'],
- 'TID' => $angeltype['id'],
- 'UID' => $signup_user['UID'],
- 'Comment' => $comment,
- 'freeloaded' => false,
+ 'SID' => $shift['SID'],
+ 'TID' => $angeltype['id'],
+ 'UID' => $signup_user['UID'],
+ 'Comment' => $comment,
+ 'freeloaded' => false,
'freeload_comment' => ''
]);
-
- if ($angeltype['restricted'] == false && ! UserAngelType_exists($signup_user, $angeltype)) {
+
+ if ($angeltype['restricted'] == false && !UserAngelType_exists($signup_user, $angeltype)) {
UserAngelType_create($signup_user, $angeltype);
}
-
+
success(_('You are subscribed. Thank you!'));
redirect(shift_link($shift));
}
-
+
$room = Room($shift['RID']);
return [
ShiftEntry_create_title(),
@@ -249,13 +275,16 @@ function shift_entry_create_controller_user($shift, $angeltype)
/**
* Link to create a shift entry.
*
+ * @param array $shift
+ * @param array $angeltype
+ * @param array $params
* @return string URL
*/
function shift_entry_create_link($shift, $angeltype, $params = [])
{
$params = array_merge([
- 'action' => 'create',
- 'shift_id' => $shift['SID'],
+ 'action' => 'create',
+ 'shift_id' => $shift['SID'],
'angeltype_id' => $angeltype['id']
], $params);
return page_link_to('shift_entries', $params);
@@ -264,12 +293,14 @@ function shift_entry_create_link($shift, $angeltype, $params = [])
/**
* Link to create a shift entry as admin.
*
+ * @param array $shift
+ * @param array $params
* @return string URL
*/
function shift_entry_create_link_admin($shift, $params = [])
{
$params = array_merge([
- 'action' => 'create',
+ 'action' => 'create',
'shift_id' => $shift['SID']
], $params);
return page_link_to('shift_entries', $params);
@@ -277,12 +308,14 @@ function shift_entry_create_link_admin($shift, $params = [])
/**
* Load a shift entry from get parameter shift_entry_id.
+ *
+ * @return array
*/
function shift_entry_load()
{
$request = request();
-
- if (! $request->has('shift_entry_id') || ! test_request_int('shift_entry_id')) {
+
+ if (!$request->has('shift_entry_id') || !test_request_int('shift_entry_id')) {
redirect(page_link_to('user_shifts'));
}
$shiftEntry = ShiftEntry($request->input('shift_entry_id'));
@@ -290,19 +323,21 @@ function shift_entry_load()
error(_('Shift entry not found.'));
redirect(page_link_to('user_shifts'));
}
-
+
return $shiftEntry;
}
/**
* Remove somebody from a shift.
+ *
+ * @return array
*/
function shift_entry_delete_controller()
{
global $user;
$request = request();
$shiftEntry = shift_entry_load();
-
+
$shift = Shift($shiftEntry['SID']);
$angeltype = AngelType($shiftEntry['TID']);
$signout_user = User($shiftEntry['UID']);
@@ -310,20 +345,20 @@ function shift_entry_delete_controller()
error(_('You are not allowed to remove this shift entry. If necessary, ask your supporter or heaven to do so.'));
redirect(user_link($signout_user));
}
-
+
if ($request->has('continue')) {
ShiftEntry_delete($shiftEntry);
success(_('Shift entry removed.'));
redirect(shift_link($shift));
}
-
+
if ($user['UID'] == $signout_user['UID']) {
return [
ShiftEntry_delete_title(),
ShiftEntry_delete_view($shiftEntry, $shift, $angeltype, $signout_user)
];
}
-
+
return [
ShiftEntry_delete_title(),
ShiftEntry_delete_view_admin($shiftEntry, $shift, $angeltype, $signout_user)
@@ -333,14 +368,14 @@ function shift_entry_delete_controller()
/**
* Link to delete a shift entry.
*
- * @param array $shiftEntry
- *
+ * @param array $shiftEntry
+ * @param array $params
* @return string URL
*/
function shift_entry_delete_link($shiftEntry, $params = [])
{
$params = array_merge([
- 'action' => 'delete',
+ 'action' => 'delete',
'shift_entry_id' => $shiftEntry['id']
], $params);
return page_link_to('shift_entries', $params);
diff --git a/includes/controller/shifts_controller.php b/includes/controller/shifts_controller.php
index 28e35a1a..5930595e 100644
--- a/includes/controller/shifts_controller.php
+++ b/includes/controller/shifts_controller.php
@@ -45,7 +45,6 @@ function shift_edit_controller()
{
global $privileges;
- // Schicht bearbeiten
$msg = '';
$valid = true;
$request = request();
@@ -65,7 +64,11 @@ function shift_edit_controller()
$angeltypes = select_array(AngelTypes(), 'id', 'name');
$shifttypes = select_array(ShiftTypes(), 'id', 'name');
- $needed_angel_types = select_array(NeededAngelTypes_by_shift($shift_id), 'angel_type_id', 'count');
+ $needed_angel_types = select_array(
+ NeededAngelTypes_by_shift($shift_id),
+ 'angel_type_id',
+ 'count'
+ );
foreach (array_keys($angeltypes) as $angeltype_id) {
if (!isset($needed_angel_types[$angeltype_id])) {
$needed_angel_types[$angeltype_id] = 0;
@@ -149,7 +152,7 @@ function shift_edit_controller()
$needed_angel_types_info = [];
foreach ($needed_angel_types as $type_id => $count) {
NeededAngelType_add($shift_id, $type_id, null, $count);
- if($count > 0) {
+ if ($count > 0) {
$needed_angel_types_info[] = $angeltypes[$type_id] . ': ' . $count;
}
}
@@ -178,7 +181,9 @@ function shift_edit_controller()
shifts_title(),
[
msg(),
- '<noscript>' . info(_('This page is much more comfortable with javascript.'), true) . '</noscript>',
+ '<noscript>'
+ . info(_('This page is much more comfortable with javascript.'), true)
+ . '</noscript>',
form([
form_select('shifttype_id', _('Shifttype'), $shifttypes, $shifttype_id),
form_text('title', _('Title'), $title),
@@ -310,8 +315,9 @@ function shifts_controller()
switch ($request->input('action')) {
case 'view':
return shift_controller();
+ /** @noinspection PhpMissingBreakStatementInspection */
case 'next':
- return shift_next_controller();
+ shift_next_controller();
default:
redirect(page_link_to('/'));
}
diff --git a/includes/controller/user_angeltypes_controller.php b/includes/controller/user_angeltypes_controller.php
index 543ba150..fb63cda8 100644
--- a/includes/controller/user_angeltypes_controller.php
+++ b/includes/controller/user_angeltypes_controller.php
@@ -273,7 +273,10 @@ function user_angeltype_update_controller()
UserAngelType_update($user_angeltype['id'], $supporter);
$success_message = sprintf(
- $supporter ? _('Added supporter rights for %s to %s.') : _('Removed supporter rights for %s from %s.'),
+ $supporter
+ ? _('Added supporter rights for %s to %s.')
+ : _('Removed supporter rights for %s from %s.')
+ ,
AngelType_name_render($angeltype),
User_Nick_render($user_source)
);
@@ -291,6 +294,8 @@ function user_angeltype_update_controller()
/**
* User joining an Angeltype (Or supporter doing this for him).
+ *
+ * @return array
*/
function user_angeltype_add_controller()
{
@@ -364,7 +369,11 @@ function user_angeltype_join_controller($angeltype)
$user_angeltype_id = UserAngelType_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)));
+ 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)) {
diff --git a/includes/controller/users_controller.php b/includes/controller/users_controller.php
index b1ef517e..e206176f 100644
--- a/includes/controller/users_controller.php
+++ b/includes/controller/users_controller.php
@@ -271,7 +271,7 @@ function users_list_controller()
User_arrived_count(),
User_active_count(),
User_force_active_count(),
- ShiftEntries_freeleaded_count(),
+ ShiftEntries_freeloaded_count(),
User_tshirts_count(),
User_got_voucher_count()
)
@@ -464,7 +464,10 @@ function shiftCalendarRendererByShiftFilter(ShiftsFilter $shiftsFilter)
if (in_array(ShiftsFilter::FILLED_FREE, $shiftsFilter->getFilled()) && $taken < $needed_angels_count) {
$filtered_shifts[] = $shift;
}
- if (in_array(ShiftsFilter::FILLED_FILLED, $shiftsFilter->getFilled()) && $taken >= $needed_angels_count) {
+ if (
+ in_array(ShiftsFilter::FILLED_FILLED, $shiftsFilter->getFilled())
+ && $taken >= $needed_angels_count
+ ) {
$filtered_shifts[] = $shift;
}
}
diff --git a/includes/helper/email_helper.php b/includes/helper/email_helper.php
index dad27b39..a8b933f3 100644
--- a/includes/helper/email_helper.php
+++ b/includes/helper/email_helper.php
@@ -39,7 +39,10 @@ function engelsystem_email($address, $title, $message)
$address,
$title,
$message,
- sprintf("Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem <%s>", config('no_reply_email'))
+ sprintf(
+ "Content-Type: text/plain; charset=UTF-8\r\nFrom: Engelsystem <%s>",
+ config('no_reply_email')
+ )
);
if ($result === false) {
diff --git a/includes/includes.php b/includes/includes.php
index b6bd41cf..e8e5ce29 100644
--- a/includes/includes.php
+++ b/includes/includes.php
@@ -84,6 +84,7 @@ $includeFiles = [
__DIR__ . '/../includes/pages/user_settings.php',
__DIR__ . '/../includes/pages/user_shifts.php',
];
+
foreach ($includeFiles as $file) {
require_once realpath($file);
}
diff --git a/includes/mailer/shifts_mailer.php b/includes/mailer/shifts_mailer.php
index 5c0e4310..a69aab3a 100644
--- a/includes/mailer/shifts_mailer.php
+++ b/includes/mailer/shifts_mailer.php
@@ -63,7 +63,12 @@ function mail_shift_change($old_shift, $new_shift)
foreach ($users as $user) {
if ($user['email_shiftinfo']) {
- engelsystem_email_to_user($user, '[engelsystem] ' . _('Your Shift has changed'), $message, true);
+ engelsystem_email_to_user(
+ $user,
+ '[engelsystem] ' . _('Your Shift has changed'),
+ $message,
+ true
+ );
}
}
}
@@ -111,6 +116,10 @@ function mail_shift_assign($user, $shift)
engelsystem_email_to_user($user, '[engelsystem] ' . _('Assigned to Shift'), $message, true);
}
+/**
+ * @param array $user
+ * @param array $shift
+ */
function mail_shift_removed($user, $shift)
{
if (!$user['email_shiftinfo']) {
diff --git a/includes/model/AngelType_model.php b/includes/model/AngelType_model.php
index f6e2a9cf..3641f125 100644
--- a/includes/model/AngelType_model.php
+++ b/includes/model/AngelType_model.php
@@ -25,13 +25,14 @@ function AngelType_new()
/**
* Checks if the angeltype has any contact information.
- *
- * @param Angeltype $angeltype
+ *
+ * @param array $angeltype Angeltype
* @return bool
*/
-function AngelType_has_contact_info($angeltype) {
- return !empty($angeltype['contact_name'])
- || !empty($angeltype['contact_dect'])
+function AngelType_has_contact_info($angeltype)
+{
+ return !empty($angeltype['contact_name'])
+ || !empty($angeltype['contact_dect'])
|| !empty($angeltype['contact_email']);
}
@@ -139,6 +140,7 @@ function AngelType_create($angeltype)
. $angeltype['contact_email'] . ', '
. $angeltype['show_on_dashboard']
);
+
return $angeltype;
}
@@ -172,6 +174,7 @@ function AngelType_validate_name($name, $angeltype)
FROM `AngelTypes`
WHERE `name`=?
LIMIT 1', [$name])) == 0);
+
return new ValidationResult($valid, $name);
}
diff --git a/includes/model/NeededAngelTypes_model.php b/includes/model/NeededAngelTypes_model.php
index 53313fe8..53f783c1 100644
--- a/includes/model/NeededAngelTypes_model.php
+++ b/includes/model/NeededAngelTypes_model.php
@@ -56,11 +56,12 @@ function NeededAngelTypes_delete_by_room($room_id)
/**
* Returns all needed angeltypes by room.
- *
+ *
* @param int $room_id
* @return array
*/
-function NeededAngelTypes_by_room($room_id) {
+function NeededAngelTypes_by_room($room_id)
+{
return DB::select(
'SELECT `angel_type_id`, `count` FROM `NeededAngelTypes` WHERE `room_id`=?',
[$room_id]
@@ -76,7 +77,12 @@ function NeededAngelTypes_by_room($room_id) {
function NeededAngelTypes_by_shift($shiftId)
{
$needed_angeltypes_source = DB::select('
- SELECT `NeededAngelTypes`.*, `AngelTypes`.`id`, `AngelTypes`.`name`, `AngelTypes`.`restricted`, `AngelTypes`.`no_self_signup`
+ SELECT
+ `NeededAngelTypes`.*,
+ `AngelTypes`.`id`,
+ `AngelTypes`.`name`,
+ `AngelTypes`.`restricted`,
+ `AngelTypes`.`no_self_signup`
FROM `NeededAngelTypes`
JOIN `AngelTypes` ON `AngelTypes`.`id` = `NeededAngelTypes`.`angel_type_id`
WHERE `shift_id` = ?
diff --git a/includes/model/Room_model.php b/includes/model/Room_model.php
index b23e35d1..f153cd52 100644
--- a/includes/model/Room_model.php
+++ b/includes/model/Room_model.php
@@ -1,14 +1,13 @@
<?php
+
use Engelsystem\Database\DB;
use Engelsystem\ValidationResult;
/**
* Validate a name for a room.
*
- * @param string $name
- * The new name
- * @param int $room_id
- * The room id
+ * @param string $name The new name
+ * @param int $room_id The room id
* @return ValidationResult
*/
function Room_validate_name($name, $room_id)
@@ -17,10 +16,11 @@ function Room_validate_name($name, $room_id)
if (empty($name)) {
$valid = false;
}
+
if (count(DB::select('SELECT RID FROM `Room` WHERE `Name`=? AND NOT `RID`=?', [
- $name,
- $room_id
- ])) > 0) {
+ $name,
+ $room_id
+ ])) > 0) {
$valid = false;
}
return new ValidationResult($valid, $name);
@@ -50,7 +50,7 @@ function Room_ids()
/**
* Delete a room
*
- * @param int $room_id
+ * @param int $room_id
*/
function Room_delete($room_id)
{
@@ -64,7 +64,7 @@ function Room_delete($room_id)
/**
* Delete a room by its name
*
- * @param string $name
+ * @param string $name
*/
function Room_delete_by_name($name)
{
@@ -77,14 +77,10 @@ function Room_delete_by_name($name)
/**
* Create a new room
*
- * @param string $name
- * Name of the room
- * @param boolean $from_frab
- * Is this a frab imported room?
- * @param string $map_url
- * URL to a map tha can be displayed in an iframe
- * @param
- * description markdown description
+ * @param string $name Name of the room
+ * @param boolean $from_frab Is this a frab imported room?
+ * @param string $map_url URL to a map tha can be displayed in an iframe
+ * @param string description Markdown description
* @return false|int
*/
function Room_create($name, $from_frab, $map_url, $description)
@@ -94,33 +90,31 @@ function Room_create($name, $from_frab, $map_url, $description)
VALUES (?, ?, ?, ?)
', [
$name,
- (int) $from_frab,
+ (int)$from_frab,
$map_url,
$description
]);
$result = DB::getPdo()->lastInsertId();
-
+
engelsystem_log(
'Room created: ' . $name
. ', frab import: ' . ($from_frab ? 'Yes' : '')
. ', map_url: ' . $map_url
. ', description: ' . $description
);
-
+
return $result;
}
/**
* update a room
*
- * @param string $name
- * Name of the room
- * @param boolean $from_frab
- * Is this a frab imported room?
- * @param string $map_url
- * URL to a map tha can be displayed in an iframe
- * @param
- * description markdown description
+ * @param int $room_id The rooms id
+ * @param string $name Name of the room
+ * @param boolean $from_frab Is this a frab imported room?
+ * @param string $map_url URL to a map tha can be displayed in an iframe
+ * @param string $description Markdown description
+ * @return int
*/
function Room_update($room_id, $name, $from_frab, $map_url, $description)
{
@@ -134,28 +128,26 @@ function Room_update($room_id, $name, $from_frab, $map_url, $description)
WHERE `RID`=?
LIMIT 1', [
$name,
- (int) $from_frab,
+ (int)$from_frab,
$map_url,
$description,
$room_id
]);
-
+
engelsystem_log(
- 'Room updated: ' . $name .
- ', frab import: ' . ($from_frab ? 'Yes' : '') .
- ', map_url: ' . $map_url .
+ 'Room updated: ' . $name .
+ ', frab import: ' . ($from_frab ? 'Yes' : '') .
+ ', map_url: ' . $map_url .
', description: ' . $description
);
-
+
return $result;
}
/**
* Returns room by id.
*
- * @param int $room_id
- * RID
- * @param bool $onlyVisible
+ * @param int $room_id RID
* @return array|false
*/
function Room($room_id)
diff --git a/includes/model/ShiftEntry_model.php b/includes/model/ShiftEntry_model.php
index 38db5959..bb9db49d 100644
--- a/includes/model/ShiftEntry_model.php
+++ b/includes/model/ShiftEntry_model.php
@@ -26,7 +26,7 @@ function ShiftEntry_new()
*
* @return int
*/
-function ShiftEntries_freeleaded_count()
+function ShiftEntries_freeloaded_count()
{
$result = DB::selectOne('SELECT COUNT(*) FROM `ShiftEntry` WHERE `freeloaded` = 1');
@@ -38,7 +38,7 @@ function ShiftEntries_freeleaded_count()
}
/**
- * List users subsribed to a given shift.
+ * List users subscribed to a given shift.
*
* @param int $shift_id
* @return array
@@ -102,7 +102,8 @@ function ShiftEntry_create($shift_entry)
. ' signed up for shift ' . $shift['name']
. ' from ' . date('Y-m-d H:i', $shift['start'])
. ' to ' . date('Y-m-d H:i', $shift['end'])
- );
+ );
+
return $result;
}
@@ -149,20 +150,20 @@ function ShiftEntry_delete($shiftEntry)
{
mail_shift_removed(User($shiftEntry['UID']), Shift($shiftEntry['SID']));
DB::delete('DELETE FROM `ShiftEntry` WHERE `id` = ?', [$shiftEntry['id']]);
-
+
$signout_user = User($shiftEntry['UID']);
$shift = Shift($shiftEntry['SID']);
$shifttype = ShiftType($shift['shifttype_id']);
$room = Room($shift['RID']);
$angeltype = AngelType($shiftEntry['TID']);
-
+
engelsystem_log(
- 'Shift signout: '. User_Nick_render($signout_user) . ' from shift ' . $shifttype['name']
+ 'Shift signout: ' . User_Nick_render($signout_user) . ' from shift ' . $shifttype['name']
. ' at ' . $room['Name']
. ' from ' . date('Y-m-d H:i', $shift['start'])
. ' to ' . date('Y-m-d H:i', $shift['end'])
. ' as ' . $angeltype['name']
- );
+ );
}
/**
diff --git a/includes/model/ShiftSignupState.php b/includes/model/ShiftSignupState.php
index 1ab7c362..8d588de3 100644
--- a/includes/model/ShiftSignupState.php
+++ b/includes/model/ShiftSignupState.php
@@ -42,12 +42,12 @@ class ShiftSignupState
* User is already signed up
*/
const SIGNED_UP = 'SIGNED_UP';
-
+
/**
* User has to be arrived
*/
const NOT_ARRIVED = 'NOT_ARRIVED';
-
+
/** @var string */
private $state;
@@ -69,8 +69,7 @@ class ShiftSignupState
/**
* Combine this state with another state from the same shift.
*
- * @param ShiftSignupState $shiftSignupState
- * The other state to combine
+ * @param ShiftSignupState $shiftSignupState The other state to combine
*/
public function combineWith(ShiftSignupState $shiftSignupState)
{
@@ -122,6 +121,7 @@ class ShiftSignupState
case ShiftSignupState::ADMIN:
return true;
}
+
return false;
}
diff --git a/includes/model/ShiftTypes_model.php b/includes/model/ShiftTypes_model.php
index 227df367..3d2dc9fe 100644
--- a/includes/model/ShiftTypes_model.php
+++ b/includes/model/ShiftTypes_model.php
@@ -76,7 +76,7 @@ function ShiftType($shifttype_id)
/**
* Get all shift types.
*
- * @return array
+ * @return array[]
*/
function ShiftTypes()
{
diff --git a/includes/model/ShiftsFilter.php b/includes/model/ShiftsFilter.php
index 3b691b55..5ad7a9b3 100644
--- a/includes/model/ShiftsFilter.php
+++ b/includes/model/ShiftsFilter.php
@@ -50,7 +50,6 @@ class ShiftsFilter
*/
public function __construct($user_shifts_admin, $rooms, $types)
{
- $this->user_shifts_admin = $user_shifts_admin;
$this->rooms = $rooms;
$this->types = $types;
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php
index fd229be6..62335882 100644
--- a/includes/model/Shifts_model.php
+++ b/includes/model/Shifts_model.php
@@ -8,7 +8,8 @@ use Engelsystem\ShiftSignupState;
* @param array $angeltype
* @return array
*/
-function Shifts_by_angeltype($angeltype) {
+function Shifts_by_angeltype($angeltype)
+{
return DB::select('
SELECT DISTINCT `Shifts`.* FROM `Shifts`
JOIN `NeededAngelTypes` ON `NeededAngelTypes`.`shift_id` = `Shifts`.`SID`
@@ -27,7 +28,11 @@ function Shifts_by_angeltype($angeltype) {
}
/**
- * Returns every shift with needed angels in the given time range.
+ * Returns every shift with needed angels in the given time range.
+ *
+ * @param int $start timestamp
+ * @param int $end timestamp
+ * @return array
*/
function Shifts_free($start, $end)
{
@@ -48,14 +53,14 @@ function Shifts_free($start, $end)
AND (SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`)
> (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
AND NOT `Shifts`.`PSID` IS NULL
- ) as `tmp`
+ ) AS `tmp`
ORDER BY `tmp`.`start`
", [
- $start,
- $end,
- $start,
- $end
- ]);
+ $start,
+ $end,
+ $start,
+ $end
+ ]);
$free_shifts = [];
foreach ($shifts as $shift) {
$free_shifts[] = Shift($shift['SID']);
@@ -65,14 +70,17 @@ function Shifts_free($start, $end)
/**
* Returns all shifts with a PSID (from frab import)
+ *
+ * @return array[]
*/
-function Shifts_from_frab() {
+function Shifts_from_frab()
+{
return DB::select('SELECT * FROM `Shifts` WHERE `PSID` IS NOT NULL ORDER BY `start`');
}
/**
* @param array $room
- * @return array
+ * @return array[]
*/
function Shifts_by_room($room)
{
@@ -220,7 +228,7 @@ function NeededAngeltype_by_Shift_and_Angeltype($shift, $angeltype)
/**
* @param ShiftsFilter $shiftsFilter
- * @return array
+ * @return array[]
*/
function ShiftEntries_by_ShiftsFilter(ShiftsFilter $shiftsFilter)
{
@@ -404,33 +412,33 @@ function Shift_signup_allowed_admin($needed_angeltype, $shift_entries)
/**
* Check if an angel can signout from a shift.
- *
- * @param $shift The shift
- * @param $angeltype The angeltype
- * @param $signout_user The user that was signed up for the shift
- *
+ *
+ * @param array $shift The shift
+ * @param array $angeltype The angeltype
+ * @param array $signout_user The user that was signed up for the shift
* @return bool
*/
-function Shift_signout_allowed($shift, $angeltype, $signout_user) {
+function Shift_signout_allowed($shift, $angeltype, $signout_user)
+{
global $user, $privileges;
-
+
// user shifts admin can sign out any user at any time
if (in_array('user_shifts_admin', $privileges)) {
return true;
}
-
+
// angeltype supporter can sign out any user at any time from their supported angeltype
if (
in_array('shiftentry_edit_angeltype_supporter', $privileges)
&& User_is_AngelType_supporter($user, $angeltype)
- ) {
+ ) {
return true;
}
-
- if($signout_user['UID'] == $user['UID'] && $shift['start'] > time() + config('last_unsubscribe') * 3600) {
+
+ if ($signout_user['UID'] == $user['UID'] && $shift['start'] > time() + config('last_unsubscribe') * 3600) {
return true;
}
-
+
return false;
}
@@ -496,9 +504,8 @@ function Shift_delete_by_psid($shift_psid)
*/
function Shift_delete($shift_id)
{
- mail_shift_delete(Shift($shift_id));
-
DB::delete('DELETE FROM `Shifts` WHERE `SID`=?', [$shift_id]);
+ mail_shift_delete(Shift($shift_id));
}
/**
@@ -606,15 +613,23 @@ function Shift_create($shift)
*
* @param array $user
* @param bool $include_freeload_comments
- * @return array
+ * @return array[]
*/
function Shifts_by_user($user, $include_freeload_comments = false)
{
return DB::select('
- SELECT `ShiftTypes`.`id` AS `shifttype_id`, `ShiftTypes`.`name`,
- `ShiftEntry`.`id`, `ShiftEntry`.`SID`, `ShiftEntry`.`TID`, `ShiftEntry`.`UID`, `ShiftEntry`.`freeloaded`, `ShiftEntry`.`Comment`,
- ' . ($include_freeload_comments ? '`ShiftEntry`.`freeload_comment`, ' : '') . '
- `Shifts`.*, `Room`.*
+ SELECT
+ `ShiftTypes`.`id` AS `shifttype_id`,
+ `ShiftTypes`.`name`,
+ `ShiftEntry`.`id`,
+ `ShiftEntry`.`SID`,
+ `ShiftEntry`.`TID`,
+ `ShiftEntry`.`UID`,
+ `ShiftEntry`.`freeloaded`,
+ `ShiftEntry`.`Comment`,
+ ' . ($include_freeload_comments ? '`ShiftEntry`.`freeload_comment`, ' : '') . '
+ `Shifts`.*,
+ `Room`.*
FROM `ShiftEntry`
JOIN `Shifts` ON (`ShiftEntry`.`SID` = `Shifts`.`SID`)
JOIN `ShiftTypes` ON (`ShiftTypes`.`id` = `Shifts`.`shifttype_id`)
diff --git a/includes/model/Stats.php b/includes/model/Stats.php
index 0c581fa9..4ff376c6 100644
--- a/includes/model/Stats.php
+++ b/includes/model/Stats.php
@@ -1,36 +1,43 @@
<?php
+
use Engelsystem\Database\Db;
/**
* Returns the number of angels currently working.
+ *
+ * @return int|string
*/
function stats_currently_working()
{
$result = Db::selectOne("
SELECT SUM(
(SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
- ) as `count`
+ ) AS `count`
FROM `Shifts`
WHERE (`end` >= ? AND `start` <= ?)", [
time(),
time()
]);
+
if (empty($result['count'])) {
return '-';
}
+
return $result['count'];
}
/**
* Return the number of hours still to work.
+ *
+ * @return int|string
*/
function stats_hours_to_work()
{
$result = Db::selectOne("
- SELECT ROUND(SUM(`count`)) as `count` FROM (
+ SELECT ROUND(SUM(`count`)) AS `count` FROM (
SELECT
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`)
- * (`Shifts`.`end` - `Shifts`.`start`)/3600 as `count`
+ * (`Shifts`.`end` - `Shifts`.`start`)/3600 AS `count`
FROM `Shifts`
WHERE `end` >= ?
AND `Shifts`.`PSID` IS NULL
@@ -39,11 +46,11 @@ function stats_hours_to_work()
SELECT
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`)
- * (`Shifts`.`end` - `Shifts`.`start`)/3600 as `count`
+ * (`Shifts`.`end` - `Shifts`.`start`)/3600 AS `count`
FROM `Shifts`
WHERE `end` >= ?
AND NOT `Shifts`.`PSID` IS NULL
- ) as `tmp`
+ ) AS `tmp`
", [
time(),
time()
@@ -56,17 +63,19 @@ function stats_hours_to_work()
/**
* Returns the number of needed angels in the next 3 hours
+ *
+ * @return int|string
*/
function stats_angels_needed_three_hours()
{
$now = time();
$in3hours = $now + 3 * 60 * 60;
$result = Db::selectOne("
- SELECT SUM(`count`) as `count` FROM (
+ SELECT SUM(`count`) AS `count` FROM (
SELECT
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`)
- (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
- as `count`
+ AS `count`
FROM `Shifts`
WHERE `end` > ? AND `start` < ?
AND `Shifts`.`PSID` IS NULL
@@ -76,11 +85,11 @@ function stats_angels_needed_three_hours()
SELECT
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`)
- (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
- as `count`
+ AS `count`
FROM `Shifts`
WHERE `end` > ? AND `start` < ?
AND NOT `Shifts`.`PSID` IS NULL
- ) as `tmp`", [
+ ) AS `tmp`", [
$now,
$in3hours,
$now,
@@ -94,17 +103,22 @@ function stats_angels_needed_three_hours()
/**
* Returns the number of needed angels for nightshifts (between 2 and 8)
+ *
+ * @return int|string
*/
function stats_angels_needed_for_nightshifts()
{
- $night_start = parse_date('Y-m-d H:i', date('Y-m-d', time() + 12 * 60 * 60) . ' 02:00');
+ $night_start = parse_date(
+ 'Y-m-d H:i',
+ date('Y-m-d', time() + 12 * 60 * 60) . ' 02:00'
+ );
$night_end = $night_start + 6 * 60 * 60;
$result = Db::selectOne("
- SELECT SUM(`count`) as `count` FROM (
+ SELECT SUM(`count`) AS `count` FROM (
SELECT
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`shift_id`=`Shifts`.`SID`)
- (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
- as `count`
+ AS `count`
FROM `Shifts`
WHERE `end` > ? AND `start` < ?
AND `Shifts`.`PSID` IS NULL
@@ -114,11 +128,11 @@ function stats_angels_needed_for_nightshifts()
SELECT
(SELECT SUM(`count`) FROM `NeededAngelTypes` WHERE `NeededAngelTypes`.`room_id`=`Shifts`.`RID`)
- (SELECT COUNT(*) FROM `ShiftEntry` WHERE `ShiftEntry`.`SID`=`Shifts`.`SID` AND `freeloaded`=0)
- as `count`
+ AS `count`
FROM `Shifts`
WHERE `end` > ? AND `start` < ?
AND NOT `Shifts`.`PSID` IS NULL
- ) as `tmp`", [
+ ) AS `tmp`", [
$night_start,
$night_end,
$night_start,
@@ -129,5 +143,3 @@ function stats_angels_needed_for_nightshifts()
}
return $result['count'];
}
-
-?> \ No newline at end of file
diff --git a/includes/model/UserAngelTypes_model.php b/includes/model/UserAngelTypes_model.php
index 42742f54..7b22e347 100644
--- a/includes/model/UserAngelTypes_model.php
+++ b/includes/model/UserAngelTypes_model.php
@@ -27,7 +27,7 @@ function UserAngelType_exists($user, $angeltype)
* List users angeltypes.
*
* @param array $user
- * @return array
+ * @return array[]
*/
function User_angeltypes($user)
{
@@ -43,7 +43,7 @@ function User_angeltypes($user)
* Gets unconfirmed user angeltypes for angeltypes of which the given user is a supporter.
*
* @param array $user
- * @return array
+ * @return array[]
*/
function User_unconfirmed_AngelTypes($user)
{
@@ -76,6 +76,7 @@ function User_is_AngelType_supporter(&$user, $angeltype)
if (!isset($user['privileges'])) {
$user['privileges'] = privileges_for_user($user['UID']);
}
+
return (count(DB::select('
SELECT `id`
FROM `UserAngelTypes`
@@ -105,7 +106,7 @@ function UserAngelType_update($user_angeltype_id, $supporter)
SET `supporter`=?
WHERE `id`=?
LIMIT 1
- ', [(int) $supporter, $user_angeltype_id]);
+ ', [(int)$supporter, $user_angeltype_id]);
}
/**
@@ -143,7 +144,6 @@ function UserAngelTypes_confirm_all($angeltype_id, $confirm_user)
*
* @param int $user_angeltype_id
* @param array $confirm_user
- * @return bool
*/
function UserAngelType_confirm($user_angeltype_id, $confirm_user)
{
diff --git a/includes/model/UserGroups_model.php b/includes/model/UserGroups_model.php
index d4baf638..9d67770c 100644
--- a/includes/model/UserGroups_model.php
+++ b/includes/model/UserGroups_model.php
@@ -6,7 +6,7 @@ use Engelsystem\Database\DB;
* Returns users groups
*
* @param array $user
- * @return array
+ * @return array[]
*/
function User_groups($user)
{
diff --git a/includes/model/User_model.php b/includes/model/User_model.php
index 2d1767e6..33fca639 100644
--- a/includes/model/User_model.php
+++ b/includes/model/User_model.php
@@ -209,7 +209,7 @@ function User_is_freeloader($user)
* Returns all users that are not member of given angeltype.
*
* @param array $angeltype Angeltype
- * @return array
+ * @return array[]
*/
function Users_by_angeltype_inverted($angeltype)
{
@@ -231,7 +231,7 @@ function Users_by_angeltype_inverted($angeltype)
* Returns all members of given angeltype.
*
* @param array $angeltype
- * @return array
+ * @return array[]
*/
function Users_by_angeltype($angeltype)
{
@@ -258,7 +258,7 @@ function Users_by_angeltype($angeltype)
/**
* Returns User id array
*
- * @return array
+ * @return array[]
*/
function User_ids()
{
@@ -268,6 +268,7 @@ function User_ids()
/**
* Strip unwanted characters from a users nick. Allowed are letters, numbers, connecting punctuation and simple space.
* Nick is trimmed.
+ *
* @param string $nick
* @return string
*/
@@ -279,8 +280,7 @@ function User_validate_Nick($nick)
/**
* Validate user email address.
*
- * @param string $mail
- * The email address to validate
+ * @param string $mail The email address to validate
* @return ValidationResult
*/
function User_validate_mail($mail)
@@ -292,8 +292,7 @@ function User_validate_mail($mail)
/**
* Validate user jabber address
*
- * @param string $jabber
- * Jabber-ID to validate
+ * @param string $jabber Jabber-ID to validate
* @return ValidationResult
*/
function User_validate_jabber($jabber)
@@ -337,10 +336,8 @@ function User_validate_planned_arrival_date($planned_arrival_date)
/**
* Validate the planned departure date
*
- * @param int $planned_arrival_date
- * Unix timestamp
- * @param int $planned_departure_date
- * Unix timestamp
+ * @param int $planned_arrival_date Unix timestamp
+ * @param int $planned_departure_date Unix timestamp
* @return ValidationResult
*/
function User_validate_planned_departure_date($planned_arrival_date, $planned_departure_date)
@@ -383,8 +380,7 @@ function User($user_id)
/**
* Returns User by api_key.
*
- * @param string $api_key
- * User api key
+ * @param string $api_key User api key
* @return array|null Matching user, null if not found
*/
function User_by_api_key($api_key)
@@ -396,7 +392,7 @@ function User_by_api_key($api_key)
* Returns User by email.
*
* @param string $email
- * @return array|null Matching user, null or false on error
+ * @return array|null Matching user, null on error
*/
function User_by_email($email)
{
@@ -460,7 +456,9 @@ function User_generate_password_recovery_token(&$user)
$user['UID'],
]
);
+
engelsystem_log('Password recovery for ' . User_Nick_render($user) . ' started.');
+
return $user['password_recovery_token'];
}
@@ -474,10 +472,10 @@ function User_get_eligable_voucher_count(&$user)
$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) {
+ $eligable_vouchers = $shifts_done / $voucher_settings['shifts_per_voucher'] - $earned_vouchers;
+ if ($eligable_vouchers < 0) {
return 0;
}
- return $elegible_vouchers;
+ return $eligable_vouchers;
}
diff --git a/includes/pages/admin_active.php b/includes/pages/admin_active.php
index 0612202f..576cdc49 100644
--- a/includes/pages/admin_active.php
+++ b/includes/pages/admin_active.php
@@ -173,7 +173,8 @@ function admin_active()
}
$usr['nick'] = User_Nick_render($usr);
$usr['shirt_size'] = $tshirt_sizes[$usr['Size']];
- $usr['work_time'] = round($usr['shift_length'] / 60) . ' min (' . round($usr['shift_length'] / 3600) . ' h)';
+ $usr['work_time'] = round($usr['shift_length'] / 60)
+ . ' min (' . round($usr['shift_length'] / 3600) . ' h)';
$usr['active'] = glyph_bool($usr['Aktiv'] == 1);
$usr['force_active'] = glyph_bool($usr['force_active'] == 1);
$usr['tshirt'] = glyph_bool($usr['Tshirt'] == 1);
diff --git a/includes/pages/admin_groups.php b/includes/pages/admin_groups.php
index e0260320..92b6a3ea 100644
--- a/includes/pages/admin_groups.php
+++ b/includes/pages/admin_groups.php
@@ -85,7 +85,11 @@ function admin_groups()
'privilege-' . $privilege['name']
);
$privileges_html .= sprintf(
- '<tr><td><input type="checkbox" name="privileges[]" value="%s" %s /></td> <td>%s</td> <td>%s</td></tr>',
+ '<tr>'
+ . '<td><input type="checkbox" name="privileges[]" value="%s" %s /></td>'
+ . '<td>%s</td>'
+ . '<td>%s</td>'
+ . '</tr>',
$privilege['id'],
($privilege['group_id'] != '' ? 'checked="checked"' : ''),
$privilege['name'],
diff --git a/includes/pages/admin_import.php b/includes/pages/admin_import.php
index 4b0f35de..3688259b 100644
--- a/includes/pages/admin_import.php
+++ b/includes/pages/admin_import.php
@@ -34,7 +34,7 @@ function admin_import()
$test_handle = @fopen($import_dir . '/tmp', 'w');
fclose($test_handle);
@unlink($import_dir . '/tmp');
- } catch(Exception $e) {
+ } catch (Exception $e) {
error(_('Webserver has no write-permission on import directory.'));
}
@@ -63,8 +63,9 @@ function admin_import()
error(_('Please select a shift type.'));
}
- if ($request->has('add_minutes_start') && is_numeric(trim($request->input('add_minutes_start')))) {
- $add_minutes_start = trim($request->input('add_minutes_start'));
+ $minutes_start = trim($request->input('add_minutes_start'));
+ if ($request->has('add_minutes_start') && is_numeric($minutes_start)) {
+ $add_minutes_start = $minutes_start;
} else {
$valid = false;
error(_('Please enter an amount of minutes to add to a talk\'s begin.'));
@@ -106,7 +107,11 @@ function admin_import()
);
} else {
$html .= div('well well-sm text-center', [
- _('File Upload') . mute(glyph('arrow-right')) . mute(_('Validation')) . mute(glyph('arrow-right')) . mute(_('Import'))
+ _('File Upload')
+ . mute(glyph('arrow-right'))
+ . mute(_('Validation'))
+ . mute(glyph('arrow-right'))
+ . mute(_('Import'))
]) . div('row', [
div('col-md-offset-3 col-md-6', [
form([
@@ -164,7 +169,10 @@ function admin_import()
'well well-sm text-center',
[
'<span class="text-success">' . _('File Upload') . glyph('ok-circle') . '</span>'
- . mute(glyph('arrow-right')) . _('Validation') . mute(glyph('arrow-right')) . mute(_('Import'))
+ . mute(glyph('arrow-right'))
+ . _('Validation')
+ . mute(glyph('arrow-right'))
+ . mute(_('Import'))
]
)
. form(
@@ -315,7 +323,7 @@ function prepare_rooms($file)
// Contains all rooms from db and frab
$rooms_import = [];
foreach ($rooms as $room) {
- if($room['from_frab']) {
+ if ($room['from_frab']) {
$rooms_db[] = $room['Name'];
}
$rooms_db_all[] = $room['Name'];
diff --git a/includes/pages/admin_questions.php b/includes/pages/admin_questions.php
index 5f2e3a2b..0636a1d9 100644
--- a/includes/pages/admin_questions.php
+++ b/includes/pages/admin_questions.php
@@ -24,7 +24,9 @@ function admin_new_questions()
$new_messages = count(DB::select('SELECT `QID` FROM `Questions` WHERE `AID` IS NULL'));
if ($new_messages > 0) {
- return '<a href="' . page_link_to('admin_questions') . '">' . _('There are unanswered questions!') . '</a>';
+ return '<a href="' . page_link_to('admin_questions') . '">'
+ . _('There are unanswered questions!')
+ . '</a>';
}
}
}
diff --git a/includes/pages/admin_rooms.php b/includes/pages/admin_rooms.php
index b1db9509..8144b328 100644
--- a/includes/pages/admin_rooms.php
+++ b/includes/pages/admin_rooms.php
@@ -18,17 +18,25 @@ function admin_rooms()
foreach ($rooms_source as $room) {
$rooms[] = [
- 'name' => Room_name_render($room),
+ 'name' => Room_name_render($room),
'from_frab' => glyph_bool($room['from_frab']),
- 'map_url' => glyph_bool(!empty($room['map_url'])),
- 'actions' => table_buttons([
- button(page_link_to('admin_rooms', ['show' => 'edit', 'id' => $room['RID']]), _('edit'), 'btn-xs'),
- button(page_link_to('admin_rooms', ['show' => 'delete', 'id' => $room['RID']]), _('delete'), 'btn-xs')
+ 'map_url' => glyph_bool(!empty($room['map_url'])),
+ 'actions' => table_buttons([
+ button(
+ page_link_to('admin_rooms', ['show' => 'edit', 'id' => $room['RID']]),
+ _('edit'),
+ 'btn-xs'
+ ),
+ button(
+ page_link_to('admin_rooms', ['show' => 'delete', 'id' => $room['RID']]),
+ _('delete'),
+ 'btn-xs'
+ )
])
];
}
- $room = null;
+ $room = null;
if ($request->has('show')) {
$msg = '';
$name = '';
@@ -69,7 +77,7 @@ function admin_rooms()
if ($request->has('name') && strlen(strip_request_item('name')) > 0) {
$result = Room_validate_name(strip_request_item('name'), $room_id);
- if(!$result->isValid()) {
+ if (!$result->isValid()) {
$valid = false;
$msg .= error(_('This name is already in use.'), true);
} else {
@@ -87,7 +95,7 @@ function admin_rooms()
}
if ($request->has('description')) {
- $description= strip_request_item_nl('description');
+ $description = strip_request_item_nl('description');
}
foreach ($angeltypes as $angeltype_id => $angeltype) {
@@ -101,7 +109,10 @@ function admin_rooms()
$angeltypes_count[$angeltype_id] = $request->input($queryKey);
} else {
$valid = false;
- $msg .= error(sprintf(_('Please enter needed angels for type %s.'), $angeltype), true);
+ $msg .= error(sprintf(
+ _('Please enter needed angels for type %s.'),
+ $angeltype
+ ), true);
}
}
@@ -118,7 +129,7 @@ function admin_rooms()
$angeltype = AngelType($angeltype_id);
if ($angeltype != null) {
NeededAngelType_add(null, $angeltype_id, $room_id, $angeltype_count);
- if($angeltype_count > 0) {
+ if ($angeltype_count > 0) {
$needed_angeltype_info[] = $angeltype['name'] . ': ' . $angeltype_count;
}
}
@@ -197,10 +208,10 @@ function admin_rooms()
]),
msg(),
table([
- 'name' => _('Name'),
+ 'name' => _('Name'),
'from_frab' => _('Frab import'),
- 'map_url' => _('Map'),
- 'actions' => ''
+ 'map_url' => _('Map'),
+ 'actions' => ''
], $rooms)
]);
}
diff --git a/includes/pages/admin_shifts.php b/includes/pages/admin_shifts.php
index 22ce7635..c80603a1 100644
--- a/includes/pages/admin_shifts.php
+++ b/includes/pages/admin_shifts.php
@@ -113,10 +113,16 @@ function admin_shifts()
} elseif ($request->input('mode') == 'variable') {
if (
$request->has('change_hours')
- && preg_match('/^(\d{2}(,|$))/', trim(str_replace(' ', '', $request->input('change_hours'))))
+ && preg_match(
+ '/^(\d{2}(,|$))/',
+ trim(str_replace(' ', '', $request->input('change_hours')))
+ )
) {
$mode = 'variable';
- $change_hours = array_map('trim', explode(',', $request->input('change_hours')));
+ $change_hours = array_map(
+ 'trim',
+ explode(',', $request->input('change_hours'))
+ );
} else {
$valid = false;
error(_('Please split the shift-change hours by colons.'));
@@ -264,7 +270,8 @@ function admin_shifts()
];
foreach ($types as $type) {
if (isset($needed_angel_types[$type['id']]) && $needed_angel_types[$type['id']] > 0) {
- $shifts_table_entry['needed_angels'] .= '<b>' . AngelType_name_render($type) . ':</b> ' . $needed_angel_types[$type['id']] . '<br />';
+ $shifts_table_entry['needed_angels'] .= '<b>' . AngelType_name_render($type) . ':</b> '
+ . $needed_angel_types[$type['id']] . '<br />';
}
}
$shifts_table[] = $shifts_table_entry;
@@ -327,6 +334,7 @@ function admin_shifts()
FROM `AngelTypes`
WHERE `id` = ?
LIMIT 1', [$type_id]);
+
if (!empty($angel_type_source)) {
DB::insert('
INSERT INTO `NeededAngelTypes` (`shift_id`, `angel_type_id`, `count`)
@@ -338,7 +346,8 @@ function admin_shifts()
$count
]
);
- if($count > 0) {
+
+ if ($count > 0) {
$needed_angel_types_info[] = $angel_type_source['name'] . ': ' . $count;
}
}
@@ -380,7 +389,13 @@ function admin_shifts()
form_info(_('Mode'), ''),
form_radio('mode', _('Create one shift'), $mode == 'single', 'single'),
form_radio('mode', _('Create multiple shifts'), $mode == 'multi', 'multi'),
- form_text('length', _('Length'), $request->has('length') ? $request->input('length') : '120'),
+ form_text(
+ 'length',
+ _('Length'),
+ $request->has('length')
+ ? $request->input('length')
+ : '120'
+ ),
form_radio(
'mode',
_('Create multiple shifts with variable length'),
@@ -390,7 +405,9 @@ function admin_shifts()
form_text(
'change_hours',
_('Shift change hours'),
- $request->has('change_hours') ? $request->input('input') : '00, 04, 08, 10, 12, 14, 16, 18, 20, 22'
+ $request->has('change_hours')
+ ? $request->input('input')
+ : '00, 04, 08, 10, 12, 14, 16, 18, 20, 22'
)
]),
div('col-md-6', [
@@ -401,7 +418,12 @@ function admin_shifts()
$angelmode == 'location',
'location'
),
- form_radio('angelmode', _('The following angels are needed'), $angelmode == 'manually', 'manually'),
+ form_radio(
+ 'angelmode',
+ _('The following angels are needed'),
+ $angelmode == 'manually',
+ 'manually'
+ ),
div('row', [
$angel_types
])
diff --git a/includes/pages/admin_user.php b/includes/pages/admin_user.php
index 0620155b..8da09e81 100644
--- a/includes/pages/admin_user.php
+++ b/includes/pages/admin_user.php
@@ -235,7 +235,8 @@ function admin_user()
}
$user_source = User($user_id);
engelsystem_log(
- 'Set groups of ' . User_Nick_render($user_source) . ' to: ' . join(', ', $user_groups_info)
+ 'Set groups of ' . User_Nick_render($user_source) . ' to: '
+ . join(', ', $user_groups_info)
);
$html .= success('Benutzergruppen gespeichert.', true);
} else {
@@ -261,7 +262,9 @@ function admin_user()
`Handy` = ?,
`Alter` =?,
`DECT` = ?,
- ' . ($user_source['email_by_human_allowed'] ? '`email` = ' . DB::getPdo()->quote($request->postData('eemail')) . ',' : '') . '
+ ' . ($user_source['email_by_human_allowed']
+ ? '`email` = ' . DB::getPdo()->quote($request->postData('eemail')) . ','
+ : '') . '
`jabber` = ?,
`Size` = ?,
`Gekommen`= ?,
@@ -298,13 +301,19 @@ function admin_user()
break;
case 'change_pw':
- if ($request->postData('new_pw') != '' && $request->postData('new_pw') == $request->postData('new_pw2')) {
+ if (
+ $request->postData('new_pw') != ''
+ && $request->postData('new_pw') == $request->postData('new_pw2')
+ ) {
set_password($user_id, $request->postData('new_pw'));
$user_source = User($user_id);
engelsystem_log('Set new password for ' . User_Nick_render($user_source));
$html .= success('Passwort neu gesetzt.', true);
} else {
- $html .= error('Die Eingaben müssen übereinstimmen und dürfen nicht leer sein!', true);
+ $html .= error(
+ 'Die Eingaben müssen übereinstimmen und dürfen nicht leer sein!',
+ true
+ );
}
break;
}
diff --git a/includes/pages/guest_login.php b/includes/pages/guest_login.php
index 0f8137d0..bed42ee5 100644
--- a/includes/pages/guest_login.php
+++ b/includes/pages/guest_login.php
@@ -183,7 +183,7 @@ function guest_register()
$tel = strip_request_item('tel');
}
if ($request->has('dect')) {
- if(strlen(strip_request_item('dect')) <= 5) {
+ if (strlen(strip_request_item('dect')) <= 5) {
$dect = strip_request_item('dect');
} else {
$valid = false;
@@ -392,7 +392,6 @@ function guest_register()
form_info(entry_required() . ' = ' . _('Entry required!'))
])
]),
- // form_textarea('comment', _('Did you help at former CCC events and which tasks have you performed then?'), $comment),
form_submit('submit', _('Register'))
])
]);
diff --git a/includes/pages/guest_stats.php b/includes/pages/guest_stats.php
index bf1814a3..bb07f4dc 100644
--- a/includes/pages/guest_stats.php
+++ b/includes/pages/guest_stats.php
@@ -14,7 +14,11 @@ function guest_stats()
list($user_count) = DB::select('SELECT count(*) AS `user_count` FROM `User`');
$stats['user_count'] = $user_count['user_count'];
- list($arrived_user_count) = DB::select('SELECT count(*) AS `user_count` FROM `User` WHERE `Gekommen`=1');
+ list($arrived_user_count) = DB::select('
+ SELECT count(*) AS `user_count`
+ FROM `User`
+ WHERE `Gekommen`=1
+ ');
$stats['arrived_user_count'] = $arrived_user_count['user_count'];
$done_shifts_seconds = DB::selectOne('
diff --git a/includes/pages/user_atom.php b/includes/pages/user_atom.php
index c9d9398e..c36e1dfd 100644
--- a/includes/pages/user_atom.php
+++ b/includes/pages/user_atom.php
@@ -63,13 +63,21 @@ function make_atom_entries_from_news($news_entries)
return $html;
}
+/**
+ * @param array $news_entry
+ * @return string
+ */
function make_atom_entry_from_news($news_entry)
{
return '
<entry>
<title>' . htmlspecialchars($news_entry['Betreff']) . '</title>
<link href="' . page_link_to('news_comments', ['nid' => $news_entry['ID']]) . '"/>
- <id>' . preg_replace('#^https?://#', '', page_link_to('news_comments', ['nid' => $news_entry['ID']])) . '</id>
+ <id>' . preg_replace(
+ '#^https?://#',
+ '',
+ page_link_to('news_comments', ['nid' => $news_entry['ID']])
+ ) . '</id>
<updated>' . date('Y-m-d\TH:i:sP', $news_entry['Datum']) . '</updated>
<summary>' . htmlspecialchars($news_entry['Text']) . '</summary>
</entry>' . "\n";
diff --git a/includes/pages/user_ical.php b/includes/pages/user_ical.php
index 4ebbb9a2..69a260a2 100644
--- a/includes/pages/user_ical.php
+++ b/includes/pages/user_ical.php
@@ -30,7 +30,7 @@ function user_ical()
/**
* Renders an ical calendar from given shifts array.
*
- * @param array <Shift> $shifts
+ * @param array $shifts Shift
*/
function send_ical_from_shifts($shifts)
{
diff --git a/includes/pages/user_news.php b/includes/pages/user_news.php
index ba5ed53e..0ec93627 100644
--- a/includes/pages/user_news.php
+++ b/includes/pages/user_news.php
@@ -73,11 +73,12 @@ function user_meetings()
/**
* Renders the text content of a news entry
- *
+ *
* @param array $news
* @return string HTML
*/
-function news_text($news) {
+function news_text($news)
+{
$text = ReplaceSmilies($news['Text']);
$text = preg_replace("/\r\n\r\n/m", '<br><br>', $text);
return $text;
@@ -101,7 +102,11 @@ function display_news($news)
$html .= '<div class="panel-footer text-muted">';
if (in_array('admin_news', $privileges)) {
$html .= '<div class="pull-right">'
- . button_glyph(page_link_to('admin_news', ['action' => 'edit', 'id' => $news['ID']]), 'edit', 'btn-xs')
+ . button_glyph(
+ page_link_to('admin_news', ['action' => 'edit', 'id' => $news['ID']]),
+ 'edit',
+ 'btn-xs'
+ )
. '</div>';
}
$html .= '<span class="glyphicon glyphicon-time"></span> ' . date('Y-m-d H:i', $news['Datum']) . '&emsp;';
@@ -140,7 +145,11 @@ function user_news_comments()
$nid = $request->input('nid');
$news = DB::selectOne('SELECT * FROM `News` WHERE `ID`=? LIMIT 1', [$nid]);
if ($request->has('text')) {
- $text = preg_replace("/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui", '', strip_tags($request->input('text')));
+ $text = preg_replace(
+ "/([^\p{L}\p{P}\p{Z}\p{N}\n]{1,})/ui",
+ '',
+ strip_tags($request->input('text'))
+ );
DB::insert('
INSERT INTO `NewsComments` (`Refid`, `Datum`, `Text`, `UID`)
VALUES (?, ?, ?, ?)
diff --git a/includes/pages/user_settings.php b/includes/pages/user_settings.php
index 83d593ad..bdc8b70d 100644
--- a/includes/pages/user_settings.php
+++ b/includes/pages/user_settings.php
@@ -78,7 +78,7 @@ function user_settings_main($user_source, $enable_tshirt_size, $tshirt_sizes)
$user_source['Vorname'] = strip_request_item('prename', $user_source['Vorname']);
$user_source['Alter'] = strip_request_item('age', $user_source['Alter']);
$user_source['Telefon'] = strip_request_item('tel', $user_source['Telefon']);
- if(strlen(strip_request_item('dect')) <= 5) {
+ if (strlen(strip_request_item('dect')) <= 5) {
$user_source['DECT'] = strip_request_item('dect', $user_source['DECT']);
} else {
$valid = false;
@@ -126,7 +126,7 @@ function user_settings_password($user_source)
*
* @param array $user_source The user
* @param array $themes List of available themes
- * @return mixed
+ * @return array
*/
function user_settings_theme($user_source, $themes)
{
diff --git a/includes/pages/user_shifts.php b/includes/pages/user_shifts.php
index b3db0391..2d294ff4 100644
--- a/includes/pages/user_shifts.php
+++ b/includes/pages/user_shifts.php
@@ -56,8 +56,18 @@ function update_ShiftsFilter_timerange(ShiftsFilter $shiftsFilter, $days)
$end_time = $start_time + 24 * 60 * 60;
}
- $shiftsFilter->setStartTime(check_request_datetime('start_day', 'start_time', $days, $start_time));
- $shiftsFilter->setEndTime(check_request_datetime('end_day', 'end_time', $days, $end_time));
+ $shiftsFilter->setStartTime(check_request_datetime(
+ 'start_day',
+ 'start_time',
+ $days,
+ $start_time
+ ));
+ $shiftsFilter->setEndTime(check_request_datetime(
+ 'end_day',
+ 'end_time',
+ $days,
+ $end_time
+ ));
if ($shiftsFilter->getStartTime() > $shiftsFilter->getEndTime()) {
$shiftsFilter->setEndTime($shiftsFilter->getStartTime() + 24 * 60 * 60);
@@ -115,7 +125,7 @@ function load_days()
}
/**
- * @return array|false
+ * @return array[]|false
*/
function load_types()
{
@@ -210,9 +220,19 @@ function view_user_shifts()
view(__DIR__ . '/../../templates/user_shifts.html', [
'title' => shifts_title(),
'room_select' => make_select($rooms, $shiftsFilter->getRooms(), 'rooms', _('Rooms')),
- 'start_select' => html_select_key('start_day', 'start_day', array_combine($days, $days), $start_day),
+ 'start_select' => html_select_key(
+ 'start_day',
+ 'start_day',
+ array_combine($days, $days),
+ $start_day
+ ),
'start_time' => $start_time,
- 'end_select' => html_select_key('end_day', 'end_day', array_combine($days, $days), $end_day),
+ 'end_select' => html_select_key(
+ 'end_day',
+ 'end_day',
+ array_combine($days, $days),
+ $end_day
+ ),
'end_time' => $end_time,
'type_select' => make_select(
$types,
@@ -242,7 +262,10 @@ function view_user_shifts()
'set_last_4h' => _('last 4h'),
'set_next_4h' => _('next 4h'),
'set_next_8h' => _('next 8h'),
- 'buttons' => button(public_dashboard_link(), glyph('dashboard') . _('Public Dashboard'))
+ 'buttons' => button(
+ public_dashboard_link(),
+ glyph('dashboard') . _('Public Dashboard')
+ )
])
])
]);
diff --git a/includes/sys_auth.php b/includes/sys_auth.php
index 4242261b..91edca77 100644
--- a/includes/sys_auth.php
+++ b/includes/sys_auth.php
@@ -87,18 +87,22 @@ function verify_password($password, $salt, $uid = null)
{
$crypt_alg = config('crypt_alg');
$correct = false;
- if (substr($salt, 0, 1) == '$') { // new-style crypt()
+ if (substr($salt, 0, 1) == '$') {
+ // new-style crypt()
$correct = crypt($password, $salt) == $salt;
- } elseif (substr($salt, 0, 7) == '{crypt}') { // old-style crypt() with DES and static salt - not used anymore
+ } elseif (substr($salt, 0, 7) == '{crypt}') {
+ // old-style crypt() with DES and static salt - not used anymore
$correct = crypt($password, '77') == $salt;
- } elseif (strlen($salt) == 32) { // old-style md5 without salt - not used anymore
+ } elseif (strlen($salt) == 32) {
+ // old-style md5 without salt - not used anymore
$correct = md5($password) == $salt;
}
if ($correct && substr($salt, 0, strlen($crypt_alg)) != $crypt_alg && intval($uid)) {
// this password is stored in another format than we want it to be.
// let's update it!
- // we duplicate the query from the above set_password() function to have the extra safety of checking the old hash
+ // we duplicate the query from the above set_password() function to have the extra safety of checking
+ // the old hash
DB::update('
UPDATE `User`
SET `Passwort` = ?
diff --git a/includes/sys_form.php b/includes/sys_form.php
index e6aadddc..05df4c15 100644
--- a/includes/sys_form.php
+++ b/includes/sys_form.php
@@ -23,9 +23,11 @@ function form_hidden($name, $value)
*/
function form_spinner($name, $label, $value)
{
+ $value = htmlspecialchars($value);
+
return form_element($label, '
<div class="input-group">
- <input id="spinner-' . $name . '" class="form-control" name="' . $name . '" value="' . htmlspecialchars($value) . '" />
+ <input id="spinner-' . $name . '" class="form-control" name="' . $name . '" value="' . $value . '" />
<div class="input-group-btn">
<button id="spinner-' . $name . '-down" class="btn btn-default" type="button">
<span class="glyphicon glyphicon-minus"></span>
@@ -130,7 +132,13 @@ function form_multi_checkboxes($names, $label, $items, $selected, $disabled = []
$sel .= ' disabled="disabled"';
}
$html .= '<td style="text-align: center;">'
- . '<input type="checkbox" id="' . $dom_id . '" name="' . $name . '[]" value="' . $key . '" ' . $sel . ' />'
+ . sprintf(
+ '<input type="checkbox" id="%s" name="%s[]" value="%s" %s />',
+ $dom_id,
+ $name,
+ $key,
+ $sel
+ )
. '</td>';
}
$html .= '<td><label for="' . $dom_id . '">' . $item . '</label></td></tr>';
@@ -281,7 +289,11 @@ function form_email($name, $label, $value, $disabled = false)
*/
function form_file($name, $label)
{
- return form_element($label, '<input id="form_' . $name . '" type="file" name="' . $name . '" />', 'form_' . $name);
+ return form_element(
+ $label,
+ sprintf('<input id="form_%1$s" type="file" name="%1$s" />', $name),
+ 'form_' . $name
+ );
}
/**
@@ -297,7 +309,11 @@ function form_password($name, $label, $disabled = false)
$disabled = $disabled ? ' disabled="disabled"' : '';
return form_element(
$label,
- '<input class="form-control" id="form_' . $name . '" type="password" name="' . $name . '" value="" ' . $disabled . '/>',
+ sprintf(
+ '<input class="form-control" id="form_%1$s" type="password" name="%1$s" value=""%s/>',
+ $name,
+ $disabled
+ ),
'form_' . $name
);
}
diff --git a/includes/sys_menu.php b/includes/sys_menu.php
index 863808d2..85ef1287 100644
--- a/includes/sys_menu.php
+++ b/includes/sys_menu.php
@@ -60,15 +60,29 @@ function header_toolbar()
}
if (!isset($user) && in_array('register', $privileges) && config('registration_enabled')) {
- $toolbar_items[] = toolbar_item_link(page_link_to('register'), 'plus', register_title(), $page == 'register');
+ $toolbar_items[] = toolbar_item_link(
+ page_link_to('register'),
+ 'plus',
+ register_title(),
+ $page == 'register'
+ );
}
if (in_array('login', $privileges)) {
- $toolbar_items[] = toolbar_item_link(page_link_to('login'), 'log-in', login_title(), $page == 'login');
+ $toolbar_items[] = toolbar_item_link(
+ page_link_to('login'),
+ 'log-in',
+ login_title(),
+ $page == 'login'
+ );
}
if (isset($user) && in_array('user_messages', $privileges)) {
- $toolbar_items[] = toolbar_item_link(page_link_to('user_messages'), 'envelope', user_unread_messages());
+ $toolbar_items[] = toolbar_item_link(
+ page_link_to('user_messages'),
+ 'envelope',
+ user_unread_messages()
+ );
}
$toolbar_items[] = header_render_hints();
@@ -112,7 +126,12 @@ function make_user_submenu()
}
if (in_array('logout', $privileges)) {
- $user_submenu[] = toolbar_item_link(page_link_to('logout'), 'log-out', logout_title(), $page == 'logout');
+ $user_submenu[] = toolbar_item_link(
+ page_link_to('logout'),
+ 'log-out',
+ logout_title(),
+ $page == 'logout'
+ );
}
return $user_submenu;
@@ -160,7 +179,12 @@ function make_navigation()
foreach ($admin_pages as $menu_page => $title) {
if (in_array($menu_page, $privileges)) {
- $admin_menu[] = toolbar_item_link(page_link_to($menu_page), '', $title, $menu_page == $page);
+ $admin_menu[] = toolbar_item_link(
+ page_link_to($menu_page),
+ '',
+ $title,
+ $menu_page == $page
+ );
}
}
diff --git a/includes/sys_template.php b/includes/sys_template.php
index 48ec7e8c..a988ca7c 100644
--- a/includes/sys_template.php
+++ b/includes/sys_template.php
@@ -3,15 +3,16 @@
/**
* Render a stat for dashborad (big number with label).
* If no style given, style is danger if number > 0, and success if number == 0.
- *
+ *
* @param string $label
* @param string $number
* @param string $style default, warning, danger or success. Optional.
+ * @return string
*/
function stats($label, $number, $style = null)
{
- if(empty($style)) {
- if($number > 0) {
+ if (empty($style)) {
+ if ($number > 0) {
$style = 'danger';
} else {
$style = 'success';
@@ -27,24 +28,26 @@ function stats($label, $number, $style = null)
/**
* Renders tabs from the array. Array key is tab name, array value is tab content.
- *
+ *
* @param array $tabs
- * @param int $selected The selected tab, default 0
+ * @param int $selected The selected tab, default 0
* @return string HTML
*/
function tabs($tabs, $selected = 0)
{
$tab_header = [];
$tab_content = [];
- foreach($tabs as $header => $content) {
+ foreach ($tabs as $header => $content) {
$class = '';
- if(count($tab_header) == $selected) {
+ if (count($tab_header) == $selected) {
$class = 'active';
}
$tab_header[] = '<li role="presentation" class="' . $class . '">
- <a href="#' . $header . '" aria-controls="' . $header . '" role="tab" data-toggle="tab">'
- . $header . '</a></li>';
- $tab_content[] = '<div role="tabpanel" class="tab-pane ' . $class . '" id="' . $header . '">' . $content . '</div>';
+ <a href="#' . $header . '" aria-controls="' . $header . '" role="tab" data-toggle="tab">'
+ . $header . '</a></li>';
+ $tab_content[] = '<div role="tabpanel" class="tab-pane ' . $class . '" id="' . $header . '">'
+ . $content
+ . '</div>';
}
return div('', [
'<ul class="nav nav-tabs" role="tablist">' . join($tab_header) . '</ul>',
@@ -114,7 +117,9 @@ function glyph($glyph_name)
*/
function glyph_bool($boolean)
{
- return '<span class="text-' . ($boolean ? 'success' : 'danger') . '">' . glyph($boolean ? 'ok' : 'remove') . '</span>';
+ return '<span class="text-' . ($boolean ? 'success' : 'danger') . '">'
+ . glyph($boolean ? 'ok' : 'remove')
+ . '</span>';
}
/**
@@ -265,12 +270,15 @@ function page_with_title($title, $elements)
/**
* Renders a description based on the data arrays key and values as label an description.
+ *
* @param array $data
+ * @return string
*/
-function description($data) {
+function description($data)
+{
$elements = [];
- foreach($data as $label => $description) {
- if(!empty($label) && !empty($description)) {
+ foreach ($data as $label => $description) {
+ if (!empty($label) && !empty($description)) {
$elements[] = '<dt>' . $label . '</dt><dd>' . $description . '</dd>';
}
}
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
index a5c10a38..6cefbb24 100644
--- a/includes/view/AngelTypes_view.php
+++ b/includes/view/AngelTypes_view.php
@@ -1,7 +1,8 @@
<?php
-use Engelsystem\ShiftsFilterRenderer;
use Engelsystem\ShiftCalendarRenderer;
+use Engelsystem\ShiftsFilterRenderer;
+
/**
* AngelTypes
*/
@@ -14,7 +15,9 @@ use Engelsystem\ShiftCalendarRenderer;
*/
function AngelType_name_render($angeltype)
{
- return '<a href="' . angeltype_link($angeltype['id']) . '">' . ($angeltype['restricted'] ? glyph('lock') : '') . $angeltype['name'] . '</a>';
+ return '<a href="' . angeltype_link($angeltype['id']) . '">'
+ . ($angeltype['restricted'] ? glyph('lock') : '') . $angeltype['name']
+ . '</a>';
}
/**
@@ -92,7 +95,10 @@ function AngelType_edit_view($angeltype, $supporter_mode)
? form_info(_('No Self Sign Up'), $angeltype['no_self_signup'] ? _('Yes') : _('No'))
: form_checkbox('no_self_signup', _('No Self Sign Up'), $angeltype['no_self_signup']),
$supporter_mode
- ? form_info(_('Requires driver license'), $angeltype['requires_driver_license'] ? _('Yes') : _('No'))
+ ? form_info(_('Requires driver license'),
+ $angeltype['requires_driver_license']
+ ? _('Yes')
+ : _('No'))
: form_checkbox(
'requires_driver_license',
_('Requires driver license'),
@@ -133,7 +139,10 @@ function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes,
];
if ($angeltype['requires_driver_license']) {
- $buttons[] = button(user_driver_license_edit_link($user), glyph('road') . _('my driving license'));
+ $buttons[] = button(
+ user_driver_license_edit_link($user),
+ glyph('road') . _('my driving license')
+ );
}
if ($user_angeltype == null) {
@@ -336,45 +345,45 @@ function AngelType_view(
AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes, $supporter, $user_driver_license, $user),
msg(),
tabs([
- _('Info') => AngelType_view_info(
+ _('Info') => AngelType_view_info(
$angeltype,
$members,
$admin_user_angeltypes,
$admin_angeltypes,
$supporter
- ),
+ ),
_('Shifts') => AngelType_view_shifts(
$angeltype,
$shiftsFilterRenderer,
$shiftCalendarRenderer
- )
- ], $tab)
+ )
+ ], $tab)
]);
}
/**
- * @param Angeltype $angeltype
- * @param ShiftsFilterRenderer $shiftsFilterRenderer
+ * @param array $angeltype
+ * @param ShiftsFilterRenderer $shiftsFilterRenderer
* @param ShiftCalendarRenderer $shiftCalendarRenderer
* @return string HTML
*/
function AngelType_view_shifts($angeltype, $shiftsFilterRenderer, $shiftCalendarRenderer)
{
- $shifts = $shiftsFilterRenderer->render(page_link_to('angeltypes', [
- 'action' => 'view',
+ $shifts = $shiftsFilterRenderer->render(page_link_to('angeltypes', [
+ 'action' => 'view',
'angeltype_id' => $angeltype['id']
]));
$shifts .= $shiftCalendarRenderer->render();
-
+
return div('first', $shifts);
}
/**
- * @param Angeltype $angeltype
+ * @param array $angeltype
* @param array $members
- * @param bool $admin_user_angeltypes
- * @param bool $admin_angeltypes
- * @param bool $supporter
+ * @param bool $admin_user_angeltypes
+ * @param bool $admin_angeltypes
+ * @param bool $supporter
* @return string HTML
*/
function AngelType_view_info(
@@ -385,29 +394,29 @@ function AngelType_view_info(
$supporter
) {
$info = [];
- if(AngelType_has_contact_info($angeltype)) {
+ if (AngelType_has_contact_info($angeltype)) {
$info[] = AngelTypes_render_contact_info($angeltype);
}
-
+
$info[] = '<h3>' . _('Description') . '</h3>';
$parsedown = new Parsedown();
if ($angeltype['description'] != '') {
$info[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
}
-
+
list($supporters, $members_confirmed, $members_unconfirmed) = AngelType_view_members(
$angeltype,
$members,
$admin_user_angeltypes,
$admin_angeltypes
- );
+ );
$table_headers = AngelType_view_table_headers($angeltype, $supporter, $admin_angeltypes);
-
+
if (count($supporters) > 0) {
$info[] = '<h3>' . _('Supporters') . '</h3>';
$info[] = table($table_headers, $supporters);
}
-
+
if (count($members_confirmed) > 0) {
$members_confirmed[] = [
'Nick' => _('Sum'),
@@ -415,7 +424,7 @@ function AngelType_view_info(
'actions' => ''
];
}
-
+
if (count($members_unconfirmed) > 0) {
$members_unconfirmed[] = [
'Nick' => _('Sum'),
@@ -423,7 +432,7 @@ function AngelType_view_info(
'actions' => ''
];
}
-
+
$info[] = '<h3>' . _('Members') . '</h3>';
if ($admin_user_angeltypes) {
$info[] = buttons([
@@ -431,45 +440,45 @@ function AngelType_view_info(
page_link_to(
'user_angeltypes',
['action' => 'add', 'angeltype_id' => $angeltype['id']]
- ),
+ ),
_('Add'),
'add'
- )
+ )
]);
}
$info[] = table($table_headers, $members_confirmed);
-
+
if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) {
$info[] = '<h3>' . _('Unconfirmed') . '</h3>';
$info[] = buttons([
button(
page_link_to('user_angeltypes', ['action' => 'confirm_all', 'angeltype_id' => $angeltype['id']]),
glyph('ok') . _('confirm all')
- ),
+ ),
button(
page_link_to('user_angeltypes', ['action' => 'delete_all', 'angeltype_id' => $angeltype['id']]),
glyph('remove') . _('deny all')
- )
+ )
]);
$info[] = table($table_headers, $members_unconfirmed);
}
-
+
return join($info);
}
/**
* Renders the contact info
- *
- * @param Anteltype $angeltype
+ *
+ * @param array $angeltype
* @return string HTML
*/
function AngelTypes_render_contact_info($angeltype)
{
return heading(_('Contact'), 3) . description([
- _('Name') => $angeltype['contact_name'],
- _('DECT') => $angeltype['contact_dect'],
- _('E-Mail') => $angeltype['contact_email']
- ]);
+ _('Name') => $angeltype['contact_name'],
+ _('DECT') => $angeltype['contact_dect'],
+ _('E-Mail') => $angeltype['contact_email']
+ ]);
}
/**
@@ -511,7 +520,7 @@ function AngelTypes_about_view_angeltype($angeltype)
$html = '<h2>' . $angeltype['name'] . '</h2>';
- if(AngelType_has_contact_info($angeltype)) {
+ if (AngelType_has_contact_info($angeltype)) {
$html .= AngelTypes_render_contact_info($angeltype);
}
diff --git a/includes/view/EventConfig_view.php b/includes/view/EventConfig_view.php
index 2b092962..25c4b225 100644
--- a/includes/view/EventConfig_view.php
+++ b/includes/view/EventConfig_view.php
@@ -73,7 +73,11 @@ function EventConfig_info($event_config)
}
// Event name, start+end date are set
- if ($event_config['event_name'] != null && $event_config['event_start_date'] != null && $event_config['event_end_date'] != null) {
+ if (
+ $event_config['event_name'] != null
+ && $event_config['event_start_date'] != null
+ && $event_config['event_end_date'] != null
+ ) {
return sprintf(
_('%s, from %s to %s'),
$event_config['event_name'],
@@ -134,7 +138,10 @@ function EventConfig_edit_view(
form_text('event_name', _('Event Name'), $event_name),
form_info('', _('Event Name is shown on the start page.')),
form_textarea('event_welcome_msg', _('Event Welcome Message'), $event_welcome_msg),
- form_info('', _('Welcome message is shown after successful registration. You can use markdown.'))
+ form_info(
+ '',
+ _('Welcome message is shown after successful registration. You can use markdown.')
+ )
]),
div('col-md-3 col-xs-6', [
form_date('buildup_start_date', _('Buildup date'), $buildup_start_date),
diff --git a/includes/view/PublicDashboard_view.php b/includes/view/PublicDashboard_view.php
index 30f63d63..b4064294 100644
--- a/includes/view/PublicDashboard_view.php
+++ b/includes/view/PublicDashboard_view.php
@@ -2,6 +2,10 @@
/**
* Public dashboard (formerly known as angel news hub)
+ *
+ * @param array $stats
+ * @param array[] $free_shifts
+ * @return string
*/
function public_dashboard_view($stats, $free_shifts)
{
@@ -9,7 +13,7 @@ function public_dashboard_view($stats, $free_shifts)
if (count($free_shifts) > 0) {
$shift_panels = [];
foreach ($free_shifts as $shift) {
- $shift_panels[] = public_dashborad_shift_render($shift);
+ $shift_panels[] = public_dashboard_shift_render($shift);
}
$needed_angels = div('first', [
div('col-md-12', [
@@ -18,6 +22,7 @@ function public_dashboard_view($stats, $free_shifts)
join($shift_panels)
]);
}
+
return page([
div('public-dashboard', [
div('first', [
@@ -48,23 +53,29 @@ function public_dashboard_view($stats, $free_shifts)
/**
* Renders a single shift panel for a dashboard shift with needed angels
+ *
+ * @param array $shift
+ * @return string
*/
-function public_dashborad_shift_render($shift)
+function public_dashboard_shift_render($shift)
{
$panel_body = glyph('time') . $shift['start'] . ' - ' . $shift['end'];
$panel_body .= ' (' . $shift['duration'] . ' h)';
-
+
$panel_body .= '<br>' . glyph('tasks') . $shift['shifttype_name'];
- if (! empty($shift['title'])) {
+ if (!empty($shift['title'])) {
$panel_body .= ' (' . $shift['title'] . ')';
}
-
+
$panel_body .= '<br>' . glyph('map-marker') . $shift['room_name'];
-
+
foreach ($shift['needed_angels'] as $needed_angels) {
- $panel_body .= '<br>' . glyph('user') . '<span class="text-' . $shift['style'] . '">' . $needed_angels['need'] . ' &times; ' . $needed_angels['angeltype_name'] . '</span>';
+ $panel_body .= '<br>' . glyph('user')
+ . '<span class="text-' . $shift['style'] . '">'
+ . $needed_angels['need'] . ' &times; ' . $needed_angels['angeltype_name']
+ . '</span>';
}
-
+
return div('col-md-3', [
div('dashboard-panel panel panel-' . $shift['style'], [
div('panel-body', [
@@ -74,4 +85,3 @@ function public_dashborad_shift_render($shift)
])
]);
}
-?>
diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php
index 1e8ae4d2..4cd4d8fe 100644
--- a/includes/view/Rooms_view.php
+++ b/includes/view/Rooms_view.php
@@ -1,49 +1,55 @@
<?php
+
use Engelsystem\ShiftCalendarRenderer;
use Engelsystem\ShiftsFilterRenderer;
/**
*
- * @param array $room
- * @param ShiftsFilterRenderer $shiftsFilterRenderer
- * @param ShiftCalendarRenderer $shiftCalendarRenderer
+ * @param array $room
+ * @param ShiftsFilterRenderer $shiftsFilterRenderer
+ * @param ShiftCalendarRenderer $shiftCalendarRenderer
* @return string
*/
function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalendarRenderer $shiftCalendarRenderer)
{
global $user;
-
+
$assignNotice = '';
- if (config('signup_requires_arrival') && ! $user['Gekommen']) {
+ if (config('signup_requires_arrival') && !$user['Gekommen']) {
$assignNotice = info(render_user_arrived_hint(), true);
}
-
+
$description = '';
- if (! empty($room['description'])) {
+ if (!empty($room['description'])) {
$description = '<h3>' . _('Description') . '</h3>';
$parsedown = new Parsedown();
$description .= '<div class="well">' . $parsedown->parse($room['description']) . '</div>';
}
-
+
$tabs = [];
- if (! empty($room['map_url'])) {
- $tabs[_('Map')] = '<div class="map"><iframe style="width: 100%; min-height: 400px; border: 0px none;" src="' . $room['map_url'] . '"></iframe></div>';
+ if (!empty($room['map_url'])) {
+ $tabs[_('Map')] = sprintf(
+ '<div class="map">'
+ . '<iframe style="width: 100%; min-height: 400px; border: 0 none;" src="%s"></iframe>'
+ . '</div>',
+ $room['map_url']
+ );
}
-
+
$tabs[_('Shifts')] = div('first', [
$shiftsFilterRenderer->render(page_link_to('rooms', [
- 'action' => 'view',
+ 'action' => 'view',
'room_id' => $room['RID']
])),
$shiftCalendarRenderer->render()
]);
-
+
$selected_tab = 0;
$request = request();
if ($request->has('shifts_filter_day')) {
$selected_tab = count($tabs) - 1;
}
-
+
return page_with_title(glyph('map-marker') . $room['Name'], [
$assignNotice,
$description,
@@ -53,14 +59,16 @@ function Room_view($room, ShiftsFilterRenderer $shiftsFilterRenderer, ShiftCalen
/**
*
- * @param array $room
+ * @param array $room
* @return string
*/
function Room_name_render($room)
{
global $privileges;
+
if (in_array('view_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/ShiftCalendarLane.php b/includes/view/ShiftCalendarLane.php
index fd4c6f06..d28b85e7 100644
--- a/includes/view/ShiftCalendarLane.php
+++ b/includes/view/ShiftCalendarLane.php
@@ -48,6 +48,7 @@ class ShiftCalendarLane
$this->shifts[] = $shift;
return;
}
+
throw new Exception('Unable to add shift to shift calendar lane.');
}
@@ -65,6 +66,7 @@ class ShiftCalendarLane
return false;
}
}
+
return true;
}
diff --git a/includes/view/ShiftCalendarRenderer.php b/includes/view/ShiftCalendarRenderer.php
index 40642947..98f40d49 100644
--- a/includes/view/ShiftCalendarRenderer.php
+++ b/includes/view/ShiftCalendarRenderer.php
@@ -267,7 +267,10 @@ class ShiftCalendarRenderer
$start_time = $shift['start'];
}
}
- return ShiftCalendarRenderer::SECONDS_PER_ROW * floor(($start_time - ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW);
+ return ShiftCalendarRenderer::SECONDS_PER_ROW * floor(
+ ($start_time - ShiftCalendarRenderer::TIME_MARGIN)
+ / ShiftCalendarRenderer::SECONDS_PER_ROW
+ );
}
/**
@@ -282,7 +285,11 @@ class ShiftCalendarRenderer
$end_time = $shift['end'];
}
}
- return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil(($end_time + ShiftCalendarRenderer::TIME_MARGIN) / ShiftCalendarRenderer::SECONDS_PER_ROW);
+
+ return ShiftCalendarRenderer::SECONDS_PER_ROW * ceil(
+ ($end_time + ShiftCalendarRenderer::TIME_MARGIN)
+ / ShiftCalendarRenderer::SECONDS_PER_ROW
+ );
}
/**
@@ -290,7 +297,10 @@ class ShiftCalendarRenderer
*/
private function calcBlocksPerSlot()
{
- return ceil(($this->getLastBlockEndTime() - $this->getFirstBlockStartTime()) / ShiftCalendarRenderer::SECONDS_PER_ROW);
+ return ceil(
+ ($this->getLastBlockEndTime() - $this->getFirstBlockStartTime())
+ / ShiftCalendarRenderer::SECONDS_PER_ROW
+ );
}
/**
diff --git a/includes/view/ShiftCalendarShiftRenderer.php b/includes/view/ShiftCalendarShiftRenderer.php
index 2940306d..8bfb18ea 100644
--- a/includes/view/ShiftCalendarShiftRenderer.php
+++ b/includes/view/ShiftCalendarShiftRenderer.php
@@ -33,10 +33,14 @@ class ShiftCalendarShiftRenderer
$blocks = ceil(($shift['end'] - $shift['start']) / ShiftCalendarRenderer::SECONDS_PER_ROW);
$blocks = max(1, $blocks);
+
return [
$blocks,
div(
- 'shift panel panel-' . $class . '" style="height: ' . ($blocks * ShiftCalendarRenderer::BLOCK_HEIGHT - ShiftCalendarRenderer::MARGIN) . 'px"',
+ 'shift panel panel-' . $class . '" '
+ . 'style="height: '
+ . ($blocks * ShiftCalendarRenderer::BLOCK_HEIGHT - ShiftCalendarRenderer::MARGIN)
+ . 'px"',
[
$this->renderShiftHead($shift),
div('panel-body', [
@@ -127,9 +131,9 @@ class ShiftCalendarShiftRenderer
if (in_array('user_shifts_admin', $privileges)) {
$html .= '<li class="list-group-item">';
$html .= button(shift_entry_create_link_admin($shift),
- glyph('plus') . _('Add more angels'),
- 'btn-xs'
- );
+ glyph('plus') . _('Add more angels'),
+ 'btn-xs'
+ );
$html .= '</li>';
}
if ($html != '') {
@@ -138,6 +142,7 @@ class ShiftCalendarShiftRenderer
'<ul class="list-group">' . $html . '</ul>'
];
}
+
return [
$shift_signup_state,
''
@@ -161,7 +166,15 @@ class ShiftCalendarShiftRenderer
$style = $entry['freeloaded'] ? ' text-decoration: line-through;' : '';
$entry_list[] = '<span style="' . $style . '">' . User_Nick_render($entry) . '</span>';
}
- $shift_signup_state = Shift_signup_allowed($user, $shift, $angeltype, null, null, $angeltype, $shift_entries);
+ $shift_signup_state = Shift_signup_allowed(
+ $user,
+ $shift,
+ $angeltype,
+ null,
+ null,
+ $angeltype,
+ $shift_entries
+ );
$inner_text = sprintf(
ngettext('%d helper needed', '%d helpers needed', $shift_signup_state->getFreeEntries()),
$shift_signup_state->getFreeEntries()
@@ -181,12 +194,12 @@ class ShiftCalendarShiftRenderer
_('Sign up'), 'btn-xs btn-primary'
);
break;
-
+
case ShiftSignupState::SHIFT_ENDED:
// No link and add a text hint, when the shift ended
$entry_list[] = $inner_text . ' (' . _('ended') . ')';
break;
-
+
case ShiftSignupState::NOT_ARRIVED:
// No link and add a text hint, when the shift ended
$entry_list[] = $inner_text . ' (' . _('please arrive for signup') . ')';
@@ -200,7 +213,10 @@ class ShiftCalendarShiftRenderer
// Add link to join the angeltype first
$entry_list[] = $inner_text . '<br />'
. button(
- page_link_to('user_angeltypes', ['action' => 'add', 'angeltype_id' => $angeltype['id']]),
+ page_link_to(
+ 'user_angeltypes',
+ ['action' => 'add', 'angeltype_id' => $angeltype['id']]
+ ),
sprintf(_('Become %s'), $angeltype['name']),
'btn-xs'
);
@@ -241,8 +257,16 @@ class ShiftCalendarShiftRenderer
$header_buttons = '';
if (in_array('admin_shifts', $privileges)) {
$header_buttons = '<div class="pull-right">' . table_buttons([
- button(page_link_to('user_shifts', ['edit_shift' => $shift['SID']]), glyph('edit'), 'btn-xs'),
- button(page_link_to('user_shifts', ['delete_shift' => $shift['SID']]), glyph('trash'), 'btn-xs')
+ button(
+ page_link_to('user_shifts', ['edit_shift' => $shift['SID']]),
+ glyph('edit'),
+ 'btn-xs'
+ ),
+ button(
+ page_link_to('user_shifts', ['delete_shift' => $shift['SID']]),
+ glyph('trash'),
+ 'btn-xs'
+ )
]) . '</div>';
}
$shift_heading = date('H:i', $shift['start']) . ' &dash; '
diff --git a/includes/view/ShiftEntry_view.php b/includes/view/ShiftEntry_view.php
index da99e9d8..1b646557 100644
--- a/includes/view/ShiftEntry_view.php
+++ b/includes/view/ShiftEntry_view.php
@@ -13,7 +13,14 @@
function ShiftEntry_delete_view_admin($shiftEntry, $shift, $angeltype, $signoff_user)
{
return page_with_title(ShiftEntry_delete_title(), [
- info(sprintf(_('Do you want to sign off %s from shift %s from %s to %s as %s?'), User_Nick_render($signoff_user), $shift['name'], date('Y-m-d H:i', $shift['start']), date('Y-m-d H:i', $shift['end']), $angeltype['name']), true),
+ info(sprintf(
+ _('Do you want to sign off %s from shift %s from %s to %s as %s?'),
+ User_Nick_render($signoff_user),
+ $shift['name'],
+ date('Y-m-d H:i', $shift['start']),
+ date('Y-m-d H:i', $shift['end']),
+ $angeltype['name']
+ ), true),
buttons([
button(user_link($signoff_user), glyph('remove') . _('cancel')),
button(shift_entry_delete_link($shiftEntry, [
@@ -26,17 +33,23 @@ function ShiftEntry_delete_view_admin($shiftEntry, $shift, $angeltype, $signoff_
/**
* Sign off from a shift, asking for ack.
*
- * @param array $shiftEntry
- * @param array $shift
- * @param array $angeltype
- * @param array $signoff_user
+ * @param array $shiftEntry
+ * @param array $shift
+ * @param array $angeltype
+ * @param array $signoff_user
*
* @return string HTML
*/
function ShiftEntry_delete_view($shiftEntry, $shift, $angeltype, $signoff_user)
{
return page_with_title(ShiftEntry_delete_title(), [
- info(sprintf(_('Do you want to sign off from your shift %s from %s to %s as %s?'), $shift['name'], date('Y-m-d H:i', $shift['start']), date('Y-m-d H:i', $shift['end']), $angeltype['name']), true),
+ info(sprintf(
+ _('Do you want to sign off from your shift %s from %s to %s as %s?'),
+ $shift['name'],
+ date('Y-m-d H:i', $shift['start']),
+ date('Y-m-d H:i', $shift['end']),
+ $angeltype['name']
+ ), true),
buttons([
button(user_link($signoff_user), glyph('remove') . _('cancel')),
button(shift_entry_delete_link($shiftEntry, [
@@ -57,65 +70,76 @@ function ShiftEntry_delete_title()
/**
* Admin puts user into shift.
*
- * @param array $shift
- * @param array $room
- * @param array $angeltype
- * @param array $angeltypes_select
- * @param array $signup_user
- * @param array $users_select
+ * @param array $shift
+ * @param array $room
+ * @param array $angeltype
+ * @param array $angeltypes_select
+ * @param array $signup_user
+ * @param array $users_select
+ * @return string
*/
function ShiftEntry_create_view_admin($shift, $room, $angeltype, $angeltypes_select, $signup_user, $users_select)
{
- return page_with_title(ShiftEntry_create_title() . ': ' . $shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', [
- Shift_view_header($shift, $room),
- info(_('Do you want to sign up the following user for this shift?'), true),
- form([
- form_select('angeltype_id', _('Angeltype'), $angeltypes_select, $angeltype['id']),
- form_select('user_id', _('User'), $users_select, $signup_user['UID']),
- form_submit('submit', glyph('ok') . _('Save'))
- ])
- ]);
+ return page_with_title(
+ ShiftEntry_create_title() . ': ' . $shift['name']
+ . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>',
+ [
+ Shift_view_header($shift, $room),
+ info(_('Do you want to sign up the following user for this shift?'), true),
+ form([
+ form_select('angeltype_id', _('Angeltype'), $angeltypes_select, $angeltype['id']),
+ form_select('user_id', _('User'), $users_select, $signup_user['UID']),
+ form_submit('submit', glyph('ok') . _('Save'))
+ ])
+ ]);
}
/**
* Supporter puts user into shift.
*
- * @param array $shift
- * @param array $room
- * @param array $angeltype
- * @param array $signup_user
- * @param array $users_select
+ * @param array $shift
+ * @param array $room
+ * @param array $angeltype
+ * @param array $signup_user
+ * @param array $users_select
+ * @return string
*/
function ShiftEntry_create_view_supporter($shift, $room, $angeltype, $signup_user, $users_select)
{
- return page_with_title(ShiftEntry_create_title() . ': ' . $shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', [
- Shift_view_header($shift, $room),
- info(sprintf(_('Do you want to sign up the following user for this shift as %s?'), AngelType_name_render($angeltype)), true),
- form([
- form_select('user_id', _('User'), $users_select, $signup_user['UID']),
- form_submit('submit', glyph('ok') . _('Save'))
- ])
- ]);
+ return page_with_title(ShiftEntry_create_title() . ': ' . $shift['name']
+ . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>',
+ [
+ Shift_view_header($shift, $room),
+ info(sprintf(_('Do you want to sign up the following user for this shift as %s?'),
+ AngelType_name_render($angeltype)), true),
+ form([
+ form_select('user_id', _('User'), $users_select, $signup_user['UID']),
+ form_submit('submit', glyph('ok') . _('Save'))
+ ])
+ ]);
}
/**
* User joining a shift.
- *
- * @param array $shift
- * @param array $room
- * @param array $angeltype
+ *
+ * @param array $shift
+ * @param array $room
+ * @param array $angeltype
* @param string $comment
+ * @return string
*/
function ShiftEntry_create_view_user($shift, $room, $angeltype, $comment)
{
- return page_with_title(ShiftEntry_create_title() . ': ' . $shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', [
- Shift_view_header($shift, $room),
- info(sprintf(_('Do you want to sign up for this shift as %s?'), AngelType_name_render($angeltype)), true),
- form([
- form_textarea('comment', _('Comment (for your eyes only):'), $comment),
- form_submit('submit', glyph('ok') . _('Save'))
- ])
- ]);
+ return page_with_title(ShiftEntry_create_title() . ': ' . $shift['name']
+ . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>',
+ [
+ Shift_view_header($shift, $room),
+ info(sprintf(_('Do you want to sign up for this shift as %s?'), AngelType_name_render($angeltype)), true),
+ form([
+ form_textarea('comment', _('Comment (for your eyes only):'), $comment),
+ form_submit('submit', glyph('ok') . _('Save'))
+ ])
+ ]);
}
/**
@@ -129,24 +153,37 @@ function ShiftEntry_create_title()
/**
* Display form for adding/editing a shift entry.
*
- * @param string $angel
- * @param string $date
- * @param string $location
- * @param string $title
- * @param string $type
- * @param string $comment
- * @param bool $freeloaded
- * @param string $freeload_comment
- * @param bool $user_admin_shifts
+ * @param string $angel
+ * @param string $date
+ * @param string $location
+ * @param string $title
+ * @param string $type
+ * @param string $comment
+ * @param bool $freeloaded
+ * @param string $freeload_comment
+ * @param bool $user_admin_shifts
* @return string
*/
-function ShiftEntry_edit_view($angel, $date, $location, $title, $type, $comment, $freeloaded, $freeload_comment, $user_admin_shifts = false)
-{
+function ShiftEntry_edit_view(
+ $angel,
+ $date,
+ $location,
+ $title,
+ $type,
+ $comment,
+ $freeloaded,
+ $freeload_comment,
+ $user_admin_shifts = false
+) {
$freeload_form = [];
if ($user_admin_shifts) {
$freeload_form = [
form_checkbox('freeloaded', _('Freeloaded'), $freeloaded),
- form_textarea('freeload_comment', _('Freeload comment (Only for shift coordination):'), $freeload_comment)
+ form_textarea(
+ 'freeload_comment',
+ _('Freeload comment (Only for shift coordination):'),
+ $freeload_comment
+ )
];
}
return page_with_title(_('Edit shift entry'), [
diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php
index 0b71b77b..7fc56d1d 100644
--- a/includes/view/Shifts_view.php
+++ b/includes/view/Shifts_view.php
@@ -4,17 +4,21 @@ use Engelsystem\ShiftSignupState;
/**
* Renders the basic shift view header.
- *
+ *
* @param array $shift
* @param array $room
- *
* @return string HTML
*/
-function Shift_view_header($shift, $room) {
+function Shift_view_header($shift, $room)
+{
return div('row', [
div('col-sm-3 col-xs-6', [
'<h4>' . _('Title') . '</h4>',
- '<p class="lead">' . ($shift['URL'] != '' ? '<a href="' . $shift['URL'] . '">' . $shift['title'] . '</a>' : $shift['title']) . '</p>'
+ '<p class="lead">'
+ . ($shift['URL'] != ''
+ ? '<a href="' . $shift['URL'] . '">' . $shift['title'] . '</a>'
+ : $shift['title'])
+ . '</p>'
]),
div('col-sm-3 col-xs-6', [
'<h4>' . _('Start') . '</h4>',
@@ -237,6 +241,11 @@ function Shift_view_render_shift_entry($shift_entry, $user_shift_admin, $angelty
function shift_length($shift)
{
$length = floor(($shift['end'] - $shift['start']) / (60 * 60)) . ':';
- $length .= str_pad((($shift['end'] - $shift['start']) % (60 * 60)) / 60, 2, '0', STR_PAD_LEFT) . 'h';
+ $length .= str_pad(
+ (($shift['end'] - $shift['start']) % (60 * 60)) / 60,
+ 2,
+ '0',
+ STR_PAD_LEFT
+ ) . 'h';
return $length;
}
diff --git a/includes/view/UserAngelTypes_view.php b/includes/view/UserAngelTypes_view.php
index c46c1ee1..1f802de4 100644
--- a/includes/view/UserAngelTypes_view.php
+++ b/includes/view/UserAngelTypes_view.php
@@ -97,7 +97,11 @@ function UserAngelType_confirm_view($user_angeltype, $user, $angeltype)
{
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),
+ info(sprintf(
+ _('Do you really want to confirm %s for %s?'),
+ User_Nick_render($user),
+ $angeltype['name']
+ ), true),
buttons([
button(angeltype_link($angeltype['id']), glyph('remove') . _('cancel')),
button(
@@ -122,7 +126,11 @@ function UserAngelType_delete_view($user_angeltype, $user, $angeltype)
{
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),
+ info(sprintf(
+ _('Do you really want to delete %s from %s?'),
+ User_Nick_render($user),
+ $angeltype['name']
+ ), true),
buttons([
button(angeltype_link($angeltype['id']), glyph('remove') . _('cancel')),
button(
@@ -174,7 +182,11 @@ function UserAngelType_join_view($user, $angeltype)
{
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),
+ info(sprintf(
+ _('Do you really want to add %s to %s?'),
+ User_Nick_render($user),
+ $angeltype['name']
+ ), true),
buttons([
button(angeltype_link($angeltype['id']), glyph('remove') . _('cancel')),
button(
diff --git a/includes/view/UserDriverLicenses_view.php b/includes/view/UserDriverLicenses_view.php
index 5eacf456..b92f5f07 100644
--- a/includes/view/UserDriverLicenses_view.php
+++ b/includes/view/UserDriverLicenses_view.php
@@ -42,7 +42,11 @@ function UserDriverLicense_edit_view($user_source, $wants_to_drive, $user_driver
_('Truck 12,5t'),
$user_driver_license['has_license_12_5t_truck']
),
- form_checkbox('has_license_forklift', _('Forklift'), $user_driver_license['has_license_forklift'])
+ form_checkbox(
+ 'has_license_forklift',
+ _('Forklift'),
+ $user_driver_license['has_license_forklift']
+ )
])
], 'driving_license'),
form_submit('submit', _('Save'))
diff --git a/includes/view/UserHintsRenderer.php b/includes/view/UserHintsRenderer.php
index aac8ecfd..a2bc62f9 100644
--- a/includes/view/UserHintsRenderer.php
+++ b/includes/view/UserHintsRenderer.php
@@ -20,7 +20,9 @@ class UserHintsRenderer
$hint_class = $this->important ? 'danger' : 'info';
$glyphicon = $this->important ? 'warning-sign' : 'info-sign';
- return toolbar_popover($glyphicon . ' text-' . $hint_class, '', $this->hints, 'bg-' . $hint_class);
+ return toolbar_popover(
+ $glyphicon . ' text-' . $hint_class, '', $this->hints, 'bg-' . $hint_class
+ );
}
return '';
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index 5aec1962..c9530307 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -105,6 +105,7 @@ function User_registration_success_view($event_welcome_message)
{
$parsedown = new Parsedown();
$event_welcome_message = $parsedown->text($event_welcome_message);
+
return page_with_title(_('Registration successful'), [
msg(),
div('row', [
@@ -171,7 +172,10 @@ function User_edit_vouchers_view($user)
buttons([
button(user_link($user), glyph('chevron-left') . _('back'))
]),
- info(sprintf(_('Angel should receive at least %d vouchers.'), User_get_eligable_voucher_count($user)), true),
+ info(sprintf(
+ _('Angel should receive at least %d vouchers.'),
+ User_get_eligable_voucher_count($user)
+ ), true),
form(
[
form_spinner('vouchers', _('Number of vouchers given out'), $user['got_voucher']),
@@ -269,10 +273,10 @@ function Users_table_header_link($column, $label, $order_by)
*/
function User_shift_state_render($user)
{
- if(!$user['Gekommen']) {
+ if (!$user['Gekommen']) {
return '';
}
-
+
$upcoming_shifts = ShiftEntries_upcoming_for_user($user);
if (empty($upcoming_shifts)) {
@@ -283,16 +287,25 @@ function User_shift_state_render($user)
if ($nextShift['start'] > time()) {
if ($nextShift['start'] - time() > 3600) {
- return '<span class="text-success moment-countdown" data-timestamp="' . $nextShift['start'] . '">' . _('Next shift %c') . '</span>';
+ return '<span class="text-success moment-countdown" data-timestamp="' . $nextShift['start'] . '">'
+ . _('Next shift %c')
+ . '</span>';
}
- return '<span class="text-warning moment-countdown" data-timestamp="' . $nextShift['start'] . '">' . _('Next shift %c') . '</span>';
+ return '<span class="text-warning moment-countdown" data-timestamp="' . $nextShift['start'] . '">'
+ . _('Next shift %c')
+ . '</span>';
}
$halfway = ($nextShift['start'] + $nextShift['end']) / 2;
if (time() < $halfway) {
- return '<span class="text-danger moment-countdown" data-timestamp="' . $nextShift['start'] . '">' . _('Shift starts %c') . '</span>';
+ return '<span class="text-danger moment-countdown" data-timestamp="' . $nextShift['start'] . '">'
+ . _('Shift starts %c')
+ . '</span>';
}
- return '<span class="text-danger moment-countdown" data-timestamp="' . $nextShift['end'] . '">' . _('Shift ends %c') . '</span>';
+
+ return '<span class="text-danger moment-countdown" data-timestamp="' . $nextShift['end'] . '">'
+ . _('Shift ends %c')
+ . '</span>';
}
/**
@@ -344,14 +357,15 @@ function User_view_myshift($shift, $user_source, $its_me)
'shift_info' => $shift_info,
'comment' => ''
];
-
- if($its_me) {
+
+ if ($its_me) {
$myshift['comment'] = $shift['Comment'];
}
if ($shift['freeloaded']) {
if (in_array('user_shifts_admin', $privileges)) {
- $myshift['comment'] .= '<br /><p class="error">' . _('Freeloaded') . ': ' . $shift['freeload_comment'] . '</p>';
+ $myshift['comment'] .= '<br />'
+ . '<p class="error">' . _('Freeloaded') . ': ' . $shift['freeload_comment'] . '</p>';
} else {
$myshift['comment'] .= '<br /><p class="error">' . _('Freeloaded') . '</p>';
}
@@ -432,7 +446,9 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
$myshifts_table = User_view_myshifts($shifts, $user_source, $its_me);
return page_with_title(
- '<span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . ' <small>' . $user_name . '</small>',
+ '<span class="icon-icon_angel"></span> '
+ . htmlspecialchars($user_source['Nick'])
+ . ' <small>' . $user_name . '</small>',
[
msg(),
div('row space-top', [
@@ -451,10 +467,16 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
_('arrived')
) : '',
$admin_user_privilege ? button(
- page_link_to('users', ['action' => 'edit_vouchers', 'user_id' => $user_source['UID']]),
+ page_link_to(
+ 'users',
+ ['action' => 'edit_vouchers', 'user_id' => $user_source['UID']]
+ ),
glyph('cutlery') . _('Edit vouchers')
) : '',
- $its_me ? button(page_link_to('user_settings'), glyph('list-alt') . _('Settings')) : '',
+ $its_me ? button(
+ page_link_to('user_settings'),
+ glyph('list-alt') . _('Settings')
+ ) : '',
$its_me ? button(
page_link_to('ical', ['key' => $user_source['api_key']]),
glyph('calendar') . _('iCal Export')
@@ -487,7 +509,10 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
'comment' => _('Comment'),
'actions' => _('Action')
], $myshifts_table) : '',
- $its_me ? info(glyph('info-sign') . _('Your night shifts between 2 and 8 am count twice.'), true) : '',
+ $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.'),
@@ -499,10 +524,16 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
}
/**
- * Render the state section of user view.
+ * Render the state section of user view
+ *
+ * @param bool $admin_user_privilege
+ * @param bool $freeloader
+ * @param array $user_source
+ * @return string
*/
-function User_view_state($admin_user_privilege, $freeloader, $user_source) {
- if($admin_user_privilege) {
+function User_view_state($admin_user_privilege, $freeloader, $user_source)
+{
+ if ($admin_user_privilege) {
$state = User_view_state_admin($freeloader, $user_source);
} else {
$state = User_view_state_user($user_source);
@@ -516,45 +547,54 @@ function User_view_state($admin_user_privilege, $freeloader, $user_source) {
/**
* Render the state section of user view for users.
+ *
+ * @param array $user_source
+ * @return array
*/
-function User_view_state_user($user_source) {
+function User_view_state_user($user_source)
+{
$state = [
User_shift_state_render($user_source)
];
-
- if($user_source['Gekommen']) {
+
+ if ($user_source['Gekommen']) {
$state[] = '<span class="text-success">' . glyph('home') . _('Arrived') . '</span>';
} else {
$state[] = '<span class="text-danger">' . _('Not arrived') . '</span>';
}
-
+
return $state;
}
/**
* Render the state section of user view for admins.
+ *
+ * @param bool $freeloader
+ * @param array $user_source
+ * @return array
*/
-function User_view_state_admin($freeloader, $user_source) {
+function User_view_state_admin($freeloader, $user_source)
+{
$state = [];
-
- if($freeloader) {
+
+ if ($freeloader) {
$state[] = '<span class="text-danger">' . glyph('exclamation-sign') . _('Freeloader') . '</span>';
}
-
+
$state[] = User_shift_state_render($user_source);
-
- if($user_source['Gekommen']) {
+
+ if ($user_source['Gekommen']) {
$state[] = '<span class="text-success">' . glyph('home')
. sprintf(_('Arrived at %s'), date('Y-m-d', $user_source['arrival_date']))
. '</span>';
- if($user_source['force_active']) {
+ if ($user_source['force_active']) {
$state[] = '<span class="text-success">' . _('Active (forced)') . '</span>';
- } elseif($user_source['Aktiv']) {
+ } elseif ($user_source['Aktiv']) {
$state[] = '<span class="text-success">' . _('Active') . '</span>';
}
- if($user_source['Tshirt']) {
+ if ($user_source['Tshirt']) {
$state[] = '<span class="text-success">' . _('T-Shirt') . '</span>';
}
} else {
@@ -562,15 +602,15 @@ function User_view_state_admin($freeloader, $user_source) {
. sprintf(_('Not arrived (Planned: %s)'), date('Y-m-d', $user_source['planned_arrival_date']))
. '</span>';
}
-
- if($user_source['got_voucher'] > 0) {
+
+ if ($user_source['got_voucher'] > 0) {
$state[] = '<span class="text-success">'
. glyph('cutlery')
. sprintf(
ngettext('Got %s voucher', 'Got %s vouchers', $user_source['got_voucher']),
$user_source['got_voucher']
- )
- . '</span>';
+ )
+ . '</span>';
} else {
$state[] = '<span class="text-danger">' . _('Got no vouchers') . '</span>';
}
@@ -731,7 +771,7 @@ function render_user_arrived_hint()
if ($user['Gekommen'] == 0) {
$event_config = EventConfig();
- if(!is_null($event_config)
+ if (!is_null($event_config)
&& !is_null($event_config['buildup_start_date'])
&& time() > $event_config['buildup_start_date']) {
return _('You are not marked as arrived. Please go to heaven\'s desk, get your angel badge and/or tell them that you arrived already.');
diff --git a/src/Database/DatabaseServiceProvider.php b/src/Database/DatabaseServiceProvider.php
index 364816cc..49fb4af5 100644
--- a/src/Database/DatabaseServiceProvider.php
+++ b/src/Database/DatabaseServiceProvider.php
@@ -12,7 +12,9 @@ class DatabaseServiceProvider extends ServiceProvider
{
$config = $this->app->get('config');
Db::connect(
- 'mysql:host=' . $config->get('database')['host'] . ';dbname=' . $config->get('database')['db'] . ';charset=utf8',
+ 'mysql:host=' . $config->get('database')['host']
+ . ';dbname=' . $config->get('database')['db']
+ . ';charset=utf8',
$config->get('database')['user'],
$config->get('database')['pw']
) || $this->exitOnError();
diff --git a/src/Database/Db.php b/src/Database/Db.php
index 7042998f..114bd8fc 100644
--- a/src/Database/Db.php
+++ b/src/Database/Db.php
@@ -71,7 +71,7 @@ class Db
*
* @param string $query
* @param array $bindings
- * @return array
+ * @return array[]
*/
public static function select($query, array $bindings = [])
{
diff --git a/src/Exceptions/Handlers/HandlerInterface.php b/src/Exceptions/Handlers/HandlerInterface.php
index 9de33e1f..838fee4a 100644
--- a/src/Exceptions/Handlers/HandlerInterface.php
+++ b/src/Exceptions/Handlers/HandlerInterface.php
@@ -15,7 +15,6 @@ interface HandlerInterface
/**
* @param Throwable $e
- * @return
*/
public function report(Throwable $e);
}
diff --git a/src/Exceptions/Handlers/Whoops.php b/src/Exceptions/Handlers/Whoops.php
index 807f5eb0..73352105 100644
--- a/src/Exceptions/Handlers/Whoops.php
+++ b/src/Exceptions/Handlers/Whoops.php
@@ -15,6 +15,11 @@ class Whoops extends Legacy implements HandlerInterface
/** @var Application */
protected $app;
+ /**
+ * Whoops constructor.
+ *
+ * @param Container $app
+ */
public function __construct(Container $app)
{
$this->app = $app;