summaryrefslogtreecommitdiff
path: root/includes/view
diff options
context:
space:
mode:
authormsquare <msquare@notrademark.de>2016-09-29 11:18:17 +0200
committermsquare <msquare@notrademark.de>2016-09-29 11:18:17 +0200
commite965f8d04150fbd17ee1b5fcbca5ae85bbe6d6bd (patch)
treef610d047f1cdc830ffc34881f6ea6d26ef0e3983 /includes/view
parent91dafb19ec171e747d9976cf738606759bde3aae (diff)
prohibit inline control structures on model and view
Diffstat (limited to 'includes/view')
-rw-r--r--includes/view/AngelTypes_view.php119
-rw-r--r--includes/view/Questions_view.php22
-rw-r--r--includes/view/Rooms_view.php3
-rw-r--r--includes/view/ShiftEntry_view.php14
-rw-r--r--includes/view/ShiftTypes_view.php17
-rw-r--r--includes/view/Shifts_view.php30
-rw-r--r--includes/view/UserAngelTypes_view.php66
-rw-r--r--includes/view/User_view.php141
8 files changed, 224 insertions, 188 deletions
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
index fae52713..65abe0f3 100644
--- a/includes/view/AngelTypes_view.php
+++ b/includes/view/AngelTypes_view.php
@@ -21,42 +21,39 @@ function AngelType_name_render($angeltype) {
* @return string
*/
function AngelType_render_membership($user_angeltype) {
- $membership = "";
if ($user_angeltype['user_angeltype_id'] != null) {
if ($user_angeltype['restricted']) {
- if ($user_angeltype['confirm_user_id'] == null)
- $membership = glyph('lock') . _("Unconfirmed");
- elseif ($user_angeltype['coordinator'])
- $membership = glyph_bool(true) . _("Coordinator");
- else
- $membership = glyph_bool(true) . _("Member");
- } elseif ($user_angeltype['coordinator'])
- $membership = glyph_bool(true) . _("Coordinator");
- else
- $membership = glyph_bool(true) . _("Member");
- } else {
- $membership = glyph_bool(false);
+ if ($user_angeltype['confirm_user_id'] == null) {
+ return glyph('lock') . _("Unconfirmed");
+ } elseif ($user_angeltype['coordinator']) {
+ return glyph_bool(true) . _("Coordinator");
+ }
+ return glyph_bool(true) . _("Member");
+ } elseif ($user_angeltype['coordinator']) {
+ return glyph_bool(true) . _("Coordinator");
+ }
+ return glyph_bool(true) . _("Member");
}
- return $membership;
+ return glyph_bool(false);
}
function AngelType_delete_view($angeltype) {
return page_with_title(sprintf(_("Delete angeltype %s"), $angeltype['name']), array(
info(sprintf(_("Do you want to delete angeltype %s?"), $angeltype['name']), true),
- buttons(array(
+ buttons([
button(page_link_to('angeltypes'), _("cancel"), 'cancel'),
button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'] . '&confirmed', _("delete"), 'ok')
- ))
+ ])
));
}
function AngelType_edit_view($name, $restricted, $description, $coordinator_mode, $requires_driver_license) {
return page_with_title(sprintf(_("Edit %s"), $name), array(
- buttons(array(
+ buttons([
button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
- )),
+ ]),
msg(),
- form(array(
+ form([
$coordinator_mode ? form_info(_("Name"), $name) : form_text('name', _("Name"), $name),
$coordinator_mode ? form_info(_("Restricted"), $restricted ? _("Yes") : _("No")) : form_checkbox('restricted', _("Restricted"), $restricted),
$coordinator_mode ? form_info(_("Requires driver license"), $requires_driver_license ? _("Yes") : _("No")) : form_checkbox('requires_driver_license', _("Requires driver license"), $requires_driver_license),
@@ -64,7 +61,7 @@ function AngelType_edit_view($name, $restricted, $description, $coordinator_mode
form_textarea('description', _("Description"), $description),
form_info("", _("Please use markdown for the description.")),
form_submit('submit', _("Save"))
- ))
+ ])
));
}
@@ -73,38 +70,44 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
button(page_link_to('angeltypes'), _("Angeltypes"), 'back')
];
- if ($angeltype['requires_driver_license'])
+ if ($angeltype['requires_driver_license']) {
$buttons[] = button(user_driver_license_edit_link($user), glyph("road") . _("my driving license"));
+ }
- if ($user_angeltype == null)
+ if ($user_angeltype == null) {
$buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add');
- else {
- if ($angeltype['requires_driver_license'] && $user_driver_license == null)
+ } else {
+ if ($angeltype['requires_driver_license'] && $user_driver_license == null) {
error(_("This angeltype requires a driver license. Please enter your driver license information!"));
+ }
- if ($angeltype['restricted'] && $user_angeltype['confirm_user_id'] == null)
+ if ($angeltype['restricted'] && $user_angeltype['confirm_user_id'] == null) {
error(sprintf(_("You are unconfirmed for this angeltype. Please go to the introduction for %s to get confirmed."), $angeltype['name']));
+ }
$buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'], _("leave"), 'cancel');
}
- if ($admin_angeltypes || $coordinator)
+ if ($admin_angeltypes || $coordinator) {
$buttons[] = button(page_link_to('angeltypes') . '&action=edit&angeltype_id=' . $angeltype['id'], _("edit"), 'edit');
- if ($admin_angeltypes)
+ }
+ if ($admin_angeltypes) {
$buttons[] = button(page_link_to('angeltypes') . '&action=delete&angeltype_id=' . $angeltype['id'], _("delete"), 'delete');
+ }
- $page = array(
+ $page = [
msg(),
buttons($buttons)
- );
+ ];
$page[] = '<h3>' . _("Description") . '</h3>';
$parsedown = new Parsedown();
- if ($angeltype['description'] != "")
+ if ($angeltype['description'] != "") {
$page[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
+ }
- $coordinators = array();
- $members_confirmed = array();
- $members_unconfirmed = array();
+ $coordinators = [];
+ $members_confirmed = [];
+ $members_unconfirmed = [];
foreach ($members as $member) {
$member['Nick'] = User_Nick_render($member);
@@ -125,19 +128,21 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
]);
$members_unconfirmed[] = $member;
} elseif ($member['coordinator']) {
- if ($admin_angeltypes)
+ if ($admin_angeltypes) {
$member['actions'] = table_buttons([
button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&coordinator=0', _("Remove coordinator rights"), 'btn-xs')
]);
- else
+ } else {
$member['actions'] = '';
+ }
$coordinators[] = $member;
} else {
- if ($admin_user_angeltypes)
+ if ($admin_user_angeltypes) {
$member['actions'] = table_buttons([
$admin_angeltypes ? button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $member['user_angeltype_id'] . '&coordinator=1', _("Add coordinator rights"), 'btn-xs') : '',
button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $member['user_angeltype_id'], _("remove"), 'btn-xs')
]);
+ }
$members_confirmed[] = $member;
}
}
@@ -167,25 +172,28 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
$page[] = table($table_headers, $coordinators);
}
- if (count($members_confirmed) > 0)
+ if (count($members_confirmed) > 0) {
$members_confirmed[] = [
'Nick' => _('Sum'),
'DECT' => count($members_confirmed),
'actions' => ''
];
+ }
- if (count($members_unconfirmed) > 0)
+ if (count($members_unconfirmed) > 0) {
$members_unconfirmed[] = [
'Nick' => _('Sum'),
'DECT' => count($members_unconfirmed),
'actions' => ''
];
+ }
$page[] = '<h3>' . _("Members") . '</h3>';
- if ($admin_user_angeltypes)
+ if ($admin_user_angeltypes) {
$page[] = buttons([
button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("Add"), 'add')
]);
+ }
$page[] = table($table_headers, $members_confirmed);
if ($admin_user_angeltypes && $angeltype['restricted'] && count($members_unconfirmed) > 0) {
@@ -206,51 +214,54 @@ function AngelType_view($angeltype, $members, $user_angeltype, $admin_user_angel
* @param array $angeltypes
*/
function AngelTypes_list_view($angeltypes, $admin_angeltypes) {
- return page_with_title(angeltypes_title(), array(
+ return page_with_title(angeltypes_title(), [
msg(),
- buttons(array(
+ buttons([
$admin_angeltypes ? button(page_link_to('angeltypes') . '&action=edit', _("New angeltype"), 'add') : '',
button(page_link_to('angeltypes') . '&action=about', _("Teams/Job description"))
- )),
- table(array(
+ ]),
+ table([
'name' => _("Name"),
'restricted' => glyph('lock') . _("Restricted"),
'membership' => _("Membership"),
'actions' => ""
- ), $angeltypes)
- ));
+ ], $angeltypes)
+ ]);
}
function AngelTypes_about_view($angeltypes, $user_logged_in) {
global $faq_url;
- $content = array(
- buttons(array(
+ $content = [
+ buttons([
! $user_logged_in ? button(page_link_to('register'), register_title()) : '',
! $user_logged_in ? button(page_link_to('login'), login_title()) : '',
$user_logged_in ? button(page_link_to('angeltypes'), angeltypes_title(), 'back') : '',
button($faq_url, _("FAQ"), "btn-primary")
- )),
+ ]),
'<p>' . _("Here is the list of teams and their tasks. If you have questions, read the FAQ.") . '</p>',
'<hr />'
- );
+ ];
$parsedown = new Parsedown();
foreach ($angeltypes as $angeltype) {
$content[] = '<h2>' . $angeltype['name'] . '</h2>';
if (isset($angeltype['user_angeltype_id'])) {
- $buttons = array();
- if ($angeltype['user_angeltype_id'] != null)
+ $buttons = [];
+ if ($angeltype['user_angeltype_id'] != null) {
$buttons[] = button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $angeltype['user_angeltype_id'], _("leave"), 'cancel');
- else
+ } else {
$buttons[] = button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'], _("join"), 'add');
+ }
$content[] = buttons($buttons);
}
- if ($angeltype['restricted'])
+ if ($angeltype['restricted']) {
$content[] = info(_("This angeltype is restricted by double-opt-in by a team coordinator. Please show up at the according introduction meetings."), true);
- if ($angeltype['description'] != "")
+ }
+ if ($angeltype['description'] != "") {
$content[] = '<div class="well">' . $parsedown->parse($angeltype['description']) . '</div>';
+ }
$content[] = '<hr />';
}
diff --git a/includes/view/Questions_view.php b/includes/view/Questions_view.php
index c766125b..bdcb8a86 100644
--- a/includes/view/Questions_view.php
+++ b/includes/view/Questions_view.php
@@ -12,26 +12,26 @@ function Questions_view($open_questions, $answered_questions, $ask_action) {
$question['actions'] = '<a href="' . page_link_to("user_questions") . '&action=delete&id=' . $question['QID'] . '">' . _("delete") . '</a>';
}
- return page_with_title(questions_title(), array(
+ return page_with_title(questions_title(), [
msg(),
- '<h2>' . _("Open questions") . '</h2>',
- table(array(
+ heading(_("Open questions"), 2),
+ table([
'Question' => _("Question"),
'actions' => ""
- ), $open_questions),
- '<h2>' . _("Answered questions") . '</h2>',
- table(array(
+ ], $open_questions),
+ heading(_("Answered questions"), 2),
+ table([
'Question' => _("Question"),
'answer_user' => _("Answered by"),
'Answer' => _("Answer"),
'actions' => ""
- ), $answered_questions),
- '<h2>' . _("Ask an archangel") . '</h2>',
- form(array(
+ ], $answered_questions),
+ heading(_("Ask an archangel"), 2),
+ form([
form_textarea('question', _("Your Question:"), ""),
form_submit('submit', _("Save"))
- ), $ask_action)
- ));
+ ], $ask_action)
+ ]);
}
?> \ No newline at end of file
diff --git a/includes/view/Rooms_view.php b/includes/view/Rooms_view.php
index e1d411cb..c820e983 100644
--- a/includes/view/Rooms_view.php
+++ b/includes/view/Rooms_view.php
@@ -2,8 +2,9 @@
function Room_name_render($room) {
global $privileges;
- if (in_array('admin_rooms', $privileges))
+ if (in_array('admin_rooms', $privileges)) {
return '<a href="' . room_link($room) . '">' . glyph('map-marker') . $room['Name'] . '</a>';
+ }
return glyph('map-marker') . $room['Name'];
}
diff --git a/includes/view/ShiftEntry_view.php b/includes/view/ShiftEntry_view.php
index 9665e426..fab5be66 100644
--- a/includes/view/ShiftEntry_view.php
+++ b/includes/view/ShiftEntry_view.php
@@ -13,16 +13,16 @@
*/
function ShiftEntry_edit_view($angel, $date, $location, $title, $type, $comment, $freeloaded, $freeload_comment, $user_admin_shifts = false) {
if ($user_admin_shifts) {
- $freeload_form = array(
+ $freeload_form = [
form_checkbox('freeloaded', _("Freeloaded"), $freeloaded),
form_textarea('freeload_comment', _("Freeload comment (Only for shift coordination):"), $freeload_comment)
- );
+ ];
} else {
- $freeload_form = array();
+ $freeload_form = [];
}
- return page_with_title(_("Edit shift entry"), array(
+ return page_with_title(_("Edit shift entry"), [
msg(),
- form(array(
+ form([
form_info(_("Angel:"), $angel),
form_info(_("Date, Duration:"), $date),
form_info(_("Location:"), $location),
@@ -31,8 +31,8 @@ function ShiftEntry_edit_view($angel, $date, $location, $title, $type, $comment,
form_textarea('comment', _("Comment (for your eyes only):"), $comment),
join("", $freeload_form),
form_submit('submit', _("Save"))
- ))
- ));
+ ])
+ ]);
}
?> \ No newline at end of file
diff --git a/includes/view/ShiftTypes_view.php b/includes/view/ShiftTypes_view.php
index 10431440..163d6646 100644
--- a/includes/view/ShiftTypes_view.php
+++ b/includes/view/ShiftTypes_view.php
@@ -2,27 +2,29 @@
function ShiftType_name_render($shifttype) {
global $privileges;
- if (in_array('shifttypes', $privileges))
+ if (in_array('shifttypes', $privileges)) {
return '<a href="' . shifttype_link($shifttype) . '">' . $shifttype['name'] . '</a>';
+ }
return $shifttype['name'];
}
function ShiftType_delete_view($shifttype) {
- return page_with_title(sprintf(_("Delete shifttype %s"), $shifttype['name']), array(
+ return page_with_title(sprintf(_("Delete shifttype %s"), $shifttype['name']), [
info(sprintf(_("Do you want to delete shifttype %s?"), $shifttype['name']), true),
- buttons(array(
+ buttons([
button(page_link_to('shifttypes'), _("cancel"), 'cancel'),
button(page_link_to('shifttypes') . '&action=delete&shifttype_id=' . $shifttype['id'] . '&confirmed', _("delete"), 'ok')
- ))
- ));
+ ])
+ ]);
}
function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $shifttype_id) {
$angeltypes_select = [
'' => _('All')
];
- foreach ($angeltypes as $angeltype)
+ foreach ($angeltypes as $angeltype) {
$angeltypes_select[$angeltype['id']] = $angeltype['name'];
+ }
return page_with_title($shifttype_id ? _('Edit shifttype') : _('Create shifttype'), [
msg(),
@@ -42,8 +44,9 @@ function ShiftType_edit_view($name, $angeltype_id, $angeltypes, $description, $s
function ShiftType_view($shifttype, $angeltype) {
$parsedown = new Parsedown();
$title = $shifttype['name'];
- if ($angeltype)
+ if ($angeltype) {
$title .= ' <small>' . sprintf(_('for team %s'), $angeltype['name']) . '</small>';
+ }
return page_with_title($title, [
msg(),
buttons([
diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php
index c67ca740..95282eb5 100644
--- a/includes/view/Shifts_view.php
+++ b/includes/view/Shifts_view.php
@@ -2,10 +2,12 @@
function Shift_editor_info_render($shift) {
$info = [];
- if ($shift['created_by_user_id'] != null)
+ if ($shift['created_by_user_id'] != null) {
$info[] = sprintf(glyph('plus') . _("created at %s by %s"), date('Y-m-d H:i', $shift['created_at_timestamp']), User_Nick_render(User($shift['created_by_user_id'])));
- if ($shift['edited_by_user_id'] != null)
+ }
+ if ($shift['edited_by_user_id'] != null) {
$info[] = sprintf(glyph('pencil') . _("edited at %s by %s"), date('Y-m-d H:i', $shift['edited_at_timestamp']), User_Nick_render(User($shift['edited_by_user_id'])));
+ }
return join('<br />', $info);
}
@@ -14,32 +16,36 @@ function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null,
if ($user_angeltype == null) {
$user_angeltype = UserAngelType_by_User_and_AngelType($user, $angeltype);
- if ($user_angeltype === false)
+ if ($user_angeltype === false) {
engelsystem_error('Unable to load user angeltype.');
+ }
}
- if (Shift_signup_allowed($shift, $angeltype, $user_angeltype, $user_shifts))
+ if (Shift_signup_allowed($shift, $angeltype, $user_angeltype, $user_shifts)) {
return button(page_link_to('user_shifts') . '&shift_id=' . $shift['SID'] . '&type_id=' . $angeltype['id'], _('Sign up'));
- elseif ($user_angeltype == null)
+ } elseif ($user_angeltype == null) {
return button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], sprintf(_('Become %s'), $angeltype['name']));
- else
- return '';
+ }
+ return '';
}
function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source, $user_shift_admin, $admin_rooms, $admin_shifttypes, $user_shifts, $signed_up) {
$parsedown = new Parsedown();
$angeltypes = [];
- foreach ($angeltypes_source as $angeltype)
+ foreach ($angeltypes_source as $angeltype) {
$angeltypes[$angeltype['id']] = $angeltype;
+ }
$needed_angels = '';
foreach ($shift['NeedAngels'] as $needed_angeltype) {
$class = 'progress-bar-warning';
- if ($needed_angeltype['taken'] == 0)
+ if ($needed_angeltype['taken'] == 0) {
$class = 'progress-bar-danger';
- if ($needed_angeltype['taken'] >= $needed_angeltype['count'])
+ }
+ if ($needed_angeltype['taken'] >= $needed_angeltype['count']) {
$class = 'progress-bar-success';
+ }
$needed_angels .= '<div class="list-group-item">';
$needed_angels .= '<div class="pull-right">' . Shift_signup_button_render($shift, $angeltypes[$needed_angeltype['TID']]) . '</div>';
@@ -51,8 +57,9 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
foreach ($shift['ShiftEntry'] as $shift_entry) {
if ($shift_entry['TID'] == $needed_angeltype['TID']) {
$entry = User_Nick_render(User($shift_entry['UID']));
- if ($shift_entry['freeloaded'])
+ if ($shift_entry['freeloaded']) {
$entry = '<strike>' . $entry . '</strike>';
+ }
if ($user_shift_admin) {
$entry .= ' <div class="btn-group">';
$entry .= button_glyph(page_link_to('user_myshifts') . '&edit=' . $shift_entry['id'] . '&id=' . $shift_entry['UID'], 'pencil', 'btn-xs');
@@ -69,7 +76,6 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source,
}
return page_with_title($shift['name'] . ' <small class="moment-countdown" data-timestamp="' . $shift['start'] . '">%c</small>', [
-
msg(),
Shift_collides($shift, $user_shifts) ? info(_('This shift collides with one of your shifts.'), true) : '',
$signed_up ? info(_('You are signed up for this shift.'), true) : '',
diff --git a/includes/view/UserAngelTypes_view.php b/includes/view/UserAngelTypes_view.php
index 29bde3c4..802ec5aa 100644
--- a/includes/view/UserAngelTypes_view.php
+++ b/includes/view/UserAngelTypes_view.php
@@ -1,86 +1,88 @@
<?php
+
function UserAngelType_update_view($user_angeltype, $user, $angeltype, $coordinator) {
- return page_with_title($coordinator ? _("Add coordinator rights") : _("Remove coordinator rights"), array(
+ return page_with_title($coordinator ? _("Add coordinator rights") : _("Remove coordinator rights"), [
msg(),
info(sprintf($coordinator ? _("Do you really want to add coordinator rights for %s to %s?") : _("Do you really want to remove coordinator rights for %s from %s?"), $angeltype['name'], User_Nick_render($user)), true),
- buttons(array(
+ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
button(page_link_to('user_angeltypes') . '&action=update&user_angeltype_id=' . $user_angeltype['id'] . '&coordinator=' . ($coordinator ? '1' : '0') . '&confirmed', _("yes"), 'ok')
- ))
- ));
+ ])
+ ]);
}
function UserAngelTypes_delete_all_view($angeltype) {
- return page_with_title(_("Deny all users"), array(
+ return page_with_title(_("Deny all users"), [
msg(),
info(sprintf(_("Do you really want to deny all users for %s?"), $angeltype['name']), true),
- buttons(array(
+ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
button(page_link_to('user_angeltypes') . '&action=delete_all&angeltype_id=' . $angeltype['id'] . '&confirmed', _("yes"), 'ok')
- ))
- ));
+ ])
+ ]);
}
function UserAngelTypes_confirm_all_view($angeltype) {
- return page_with_title(_("Confirm all users"), array(
+ return page_with_title(_("Confirm all users"), [
msg(),
info(sprintf(_("Do you really want to confirm all users for %s?"), $angeltype['name']), true),
- buttons(array(
+ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
button(page_link_to('user_angeltypes') . '&action=confirm_all&angeltype_id=' . $angeltype['id'] . '&confirmed', _("yes"), 'ok')
- ))
- ));
+ ])
+ ]);
}
function UserAngelType_confirm_view($user_angeltype, $user, $angeltype) {
- return page_with_title(_("Confirm angeltype for user"), array(
+ return page_with_title(_("Confirm angeltype for user"), [
msg(),
info(sprintf(_("Do you really want to confirm %s for %s?"), User_Nick_render($user), $angeltype['name']), true),
- buttons(array(
+ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
button(page_link_to('user_angeltypes') . '&action=confirm&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed', _("yes"), 'ok')
- ))
- ));
+ ])
+ ]);
}
function UserAngelType_delete_view($user_angeltype, $user, $angeltype) {
- return page_with_title(_("Remove angeltype"), array(
+ return page_with_title(_("Remove angeltype"), [
msg(),
info(sprintf(_("Do you really want to delete %s from %s?"), User_Nick_render($user), $angeltype['name']), true),
- buttons(array(
+ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
button(page_link_to('user_angeltypes') . '&action=delete&user_angeltype_id=' . $user_angeltype['id'] . '&confirmed', _("yes"), 'ok')
- ))
- ));
+ ])
+ ]);
}
function UserAngelType_add_view($angeltype, $users_source, $user_id) {
- $users = array();
- foreach ($users_source as $user_source)
+ $users = [];
+ foreach ($users_source as $user_source) {
$users[$user_source['UID']] = User_Nick_render($user_source);
+ }
- return page_with_title(_("Add user to angeltype"), array(
+ return page_with_title(_("Add user to angeltype"), [
msg(),
- buttons(array(
+ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("back"), 'back')
- )),
- form(array(
+ ]),
+ form([
form_info(_("Angeltype"), $angeltype['name']),
form_select('user_id', _("User"), $users, $user_id),
form_submit('submit', _("Add"))
- ))
- ));
+ ])
+ ]);
}
function UserAngelType_join_view($user, $angeltype) {
- return page_with_title(sprintf(_("Become a %s"), $angeltype['name']), array(
+ return page_with_title(sprintf(_("Become a %s"), $angeltype['name']), [
msg(),
info(sprintf(_("Do you really want to add %s to %s?"), User_Nick_render($user), $angeltype['name']), true),
- buttons(array(
+ buttons([
button(page_link_to('angeltypes') . '&action=view&angeltype_id=' . $angeltype['id'], _("cancel"), 'cancel'),
button(page_link_to('user_angeltypes') . '&action=add&angeltype_id=' . $angeltype['id'] . '&user_id=' . $user['UID'] . '&confirmed', _("save"), 'ok')
- ))
- ));
+ ])
+ ]);
}
?> \ No newline at end of file
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index 4f61006e..5c258fc7 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -3,7 +3,7 @@
/**
* Available T-Shirt sizes
*/
-$tshirt_sizes = array(
+$tshirt_sizes = [
'' => _("Please select..."),
'S' => "S",
'M' => "M",
@@ -17,7 +17,7 @@ $tshirt_sizes = array(
'M-G' => "M Girl",
'L-G' => "L Girl",
'XL-G' => "XL Girl"
-);
+];
/**
* Displays the welcome message to the user and shows a login form.
@@ -112,12 +112,12 @@ function Users_view($users, $order_by, $arrived_count, $active_count, $force_act
'actions' => '<strong>' . count($users) . '</strong>'
);
- return page_with_title(_('All users'), array(
+ return page_with_title(_('All users'), [
msg(),
- buttons(array(
+ buttons([
button(page_link_to('register'), glyph('plus') . _('New user'))
- )),
- table(array(
+ ]),
+ table([
'Nick' => Users_table_header_link('Nick', _('Nick'), $order_by),
'Vorname' => Users_table_header_link('Vorname', _('Prename'), $order_by),
'Name' => Users_table_header_link('Name', _('Name'), $order_by),
@@ -131,8 +131,8 @@ function Users_view($users, $order_by, $arrived_count, $active_count, $force_act
'Size' => Users_table_header_link('Size', _('Size'), $order_by),
'lastLogIn' => Users_table_header_link('lastLogIn', _('Last login'), $order_by),
'actions' => ''
- ), $users)
- ));
+ ], $users)
+ ]);
}
function Users_table_header_link($column, $label, $order_by) {
@@ -141,24 +141,28 @@ function Users_table_header_link($column, $label, $order_by) {
function User_shift_state_render($user) {
$upcoming_shifts = ShiftEntries_upcoming_for_user($user);
- if ($upcoming_shifts === false)
+ if ($upcoming_shifts === false) {
return false;
+ }
- if (count($upcoming_shifts) == 0)
+ if (count($upcoming_shifts) == 0) {
return '<span class="text-success">' . _("Free") . '</span>';
+ }
- if ($upcoming_shifts[0]['start'] > time())
- if ($upcoming_shifts[0]['start'] - time() > 3600)
+ if ($upcoming_shifts[0]['start'] > time()) {
+ if ($upcoming_shifts[0]['start'] - time() > 3600) {
return '<span class="text-success moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Next shift %c") . '</span>';
- else
+ } else {
return '<span class="text-warning moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Next shift %c") . '</span>';
-
+ }
+ }
$halfway = ($upcoming_shifts[0]['start'] + $upcoming_shifts[0]['end']) / 2;
- if (time() < $halfway)
+ if (time() < $halfway) {
return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['start'] . '">' . _("Shift starts %c") . '</span>';
- else
+ } else {
return '<span class="text-danger moment-countdown" data-timestamp="' . $upcoming_shifts[0]['end'] . '">' . _("Shift ends %c") . '</span>';
+ }
}
function User_view($user_source, $admin_user_privilege, $freeloader, $user_angeltypes, $user_groups, $shifts, $its_me) {
@@ -166,76 +170,83 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
$user_name = htmlspecialchars($user_source['Vorname']) . " " . htmlspecialchars($user_source['Name']);
- $myshifts_table = array();
+ $myshifts_table = [];
$timesum = 0;
foreach ($shifts as $shift) {
$shift_info = '<a href="' . shift_link($shift) . '">' . $shift['name'] . '</a>';
- if ($shift['title'])
+ if ($shift['title']) {
$shift_info .= '<br /><a href="' . shift_link($shift) . '">' . $shift['title'] . '</a>';
+ }
foreach ($shift['needed_angeltypes'] as $needed_angel_type) {
$shift_info .= '<br><b>' . $needed_angel_type['name'] . ':</b> ';
- $shift_entries = array();
+ $shift_entries = [];
foreach ($needed_angel_type['users'] as $user_shift) {
$member = User_Nick_render($user_shift);
- if ($user_shift['freeloaded'])
+ if ($user_shift['freeloaded']) {
$member = '<strike>' . $member . '</strike>';
+ }
$shift_entries[] = $member;
}
$shift_info .= join(", ", $shift_entries);
}
- $myshift = array(
+ $myshift = [
'date' => date("Y-m-d", $shift['start']),
'time' => date("H:i", $shift['start']) . ' - ' . date("H:i", $shift['end']),
'room' => $shift['Name'],
'shift_info' => $shift_info,
'comment' => $shift['Comment']
- );
+ ];
if ($shift['freeloaded']) {
- if (in_array("user_shifts_admin", $privileges))
+ if (in_array("user_shifts_admin", $privileges)) {
$myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . ': ' . $shift['freeload_comment'] . '</p>';
- else
+ } else {
$myshift['comment'] .= '<br /><p class="error">' . _("Freeloaded") . '</p>';
+ }
}
$myshift['actions'] = [
button(shift_link($shift), glyph('eye-open') . _('view'), 'btn-xs')
];
- if ($its_me || in_array('user_shifts_admin', $privileges))
+ if ($its_me || in_array('user_shifts_admin', $privileges)) {
$myshift['actions'][] = button(page_link_to('user_myshifts') . '&edit=' . $shift['id'] . '&id=' . $user_source['UID'], glyph('edit') . _('edit'), 'btn-xs');
- if (($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600) || in_array('user_shifts_admin', $privileges))
+ }
+ if (($shift['start'] > time() + $LETZTES_AUSTRAGEN * 3600) || in_array('user_shifts_admin', $privileges)) {
$myshift['actions'][] = button(page_link_to('user_myshifts') . ((! $its_me) ? '&id=' . $user_source['UID'] : '') . '&cancel=' . $shift['id'], glyph('trash') . _('sign off'), 'btn-xs');
+ }
$myshift['actions'] = table_buttons($myshift['actions']);
- if ($shift['freeloaded'])
+ if ($shift['freeloaded']) {
$timesum += (- 2 * ($shift['end'] - $shift['start']));
- else
+ } else {
$timesum += ($shift['end'] - $shift['start']);
+ }
$myshifts_table[] = $myshift;
}
- if (count($myshifts_table) > 0)
- $myshifts_table[] = array(
+ if (count($myshifts_table) > 0) {
+ $myshifts_table[] = [
'date' => '<b>' . _("Sum:") . '</b>',
'time' => "<b>" . round($timesum / 3600, 1) . " h</b>",
'room' => "",
'shift_info' => "",
'comment' => "",
'actions' => ""
- );
+ ];
+ }
- return page_with_title('<span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . ' <small>' . $user_name . '</small>', array(
+ return page_with_title('<span class="icon-icon_angel"></span> ' . htmlspecialchars($user_source['Nick']) . ' <small>' . $user_name . '</small>', [
msg(),
- div('row', array(
- div('col-md-3', array(
+ div('row', [
+ div('col-md-3', [
'<h1>',
'<span class="glyphicon glyphicon-phone"></span>',
$user_source['DECT'],
'</h1>'
- )),
- div('col-md-3', array(
+ ]),
+ div('col-md-3', [
'<h4>' . _("User state") . '</h4>',
($admin_user_privilege && $freeloader) ? '<span class="text-danger"><span class="glyphicon glyphicon-exclamation-sign"></span> ' . _("Freeloader") . '</span><br />' : '',
$user_source['Gekommen'] ? User_shift_state_render($user_source) . '<br />' : '',
@@ -243,19 +254,19 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
$admin_user_privilege ? ($user_source['got_voucher'] > 0 ? '<br /><span class="text-success">' . glyph('cutlery') . sprintf(ngettext("Got %s voucher", "Got %s vouchers", $user_source['got_voucher']), $user_source['got_voucher']) . '</span><br />' : '<br /><span class="text-danger">' . _("Got no vouchers") . '</span><br />') : '',
($user_source['Gekommen'] && $admin_user_privilege && $user_source['Aktiv']) ? ' <span class="text-success">' . _("Active") . '</span>' : '',
($user_source['Gekommen'] && $admin_user_privilege && $user_source['Tshirt']) ? ' <span class="text-success">' . _("T-Shirt") . '</span>' : ''
- )),
- div('col-md-3', array(
+ ]),
+ div('col-md-3', [
'<h4>' . _("Angeltypes") . '</h4>',
User_angeltypes_render($user_angeltypes)
- )),
- div('col-md-3', array(
+ ]),
+ div('col-md-3', [
'<h4>' . _("Rights") . '</h4>',
User_groups_render($user_groups)
- ))
- )),
- div('row space-top', array(
- div('col-md-12', array(
- buttons(array(
+ ])
+ ]),
+ div('row space-top', [
+ div('col-md-12', [
+ buttons([
$admin_user_privilege ? button(page_link_to('admin_user') . '&id=' . $user_source['UID'], glyph("edit") . _("edit")) : '',
$admin_user_privilege ? button(user_driver_license_edit_link($user_source), glyph("road") . _("driving license")) : '',
($admin_user_privilege && ! $user_source['Gekommen']) ? button(page_link_to('admin_arrive') . '&arrived=' . $user_source['UID'], _("arrived")) : '',
@@ -264,63 +275,65 @@ function User_view($user_source, $admin_user_privilege, $freeloader, $user_angel
$its_me ? button(page_link_to('ical') . '&key=' . $user_source['api_key'], glyph('calendar') . _("iCal Export")) : '',
$its_me ? button(page_link_to('shifts_json_export') . '&key=' . $user_source['api_key'], glyph('export') . _("JSON Export")) : '',
$its_me ? button(page_link_to('user_myshifts') . '&reset', glyph('repeat') . _('Reset API key')) : ''
- ))
- ))
- )),
+ ])
+ ])
+ ]),
($its_me || $admin_user_privilege) ? '<h2>' . _("Shifts") . '</h2>' : '',
- ($its_me || $admin_user_privilege) ? table(array(
+ ($its_me || $admin_user_privilege) ? table([
'date' => _("Day"),
'time' => _("Time"),
'room' => _("Location"),
'shift_info' => _("Name &amp; workmates"),
'comment' => _("Comment"),
'actions' => _("Action")
- ), $myshifts_table) : '',
+ ], $myshifts_table) : '',
$its_me ? info(glyph('info-sign') . _("Your night shifts between 2 and 8 am count twice."), true) : '',
$its_me && count($shifts) == 0 ? error(sprintf(_("Go to the <a href=\"%s\">shifts table</a> to sign yourself up for some shifts."), page_link_to('user_shifts')), true) : ''
- ));
+ ]);
}
/**
* View for password recovery step 1: E-Mail
*/
function User_password_recovery_view() {
- return page_with_title(user_password_recovery_title(), array(
+ return page_with_title(user_password_recovery_title(), [
msg(),
_("We will send you an e-mail with a password recovery link. Please use the email address you used for registration."),
- form(array(
+ form([
form_text('email', _("E-Mail"), ""),
form_submit('submit', _("Recover"))
- ))
- ));
+ ])
+ ]);
}
/**
* View for password recovery step 2: New password
*/
function User_password_set_view() {
- return page_with_title(user_password_recovery_title(), array(
+ return page_with_title(user_password_recovery_title(), [
msg(),
_("Please enter a new password."),
- form(array(
+ form([
form_password('password', _("Password")),
form_password('password2', _("Confirm password")),
form_submit('submit', _("Save"))
- ))
- ));
+ ])
+ ]);
}
function User_angeltypes_render($user_angeltypes) {
- $output = array();
+ $output = [];
foreach ($user_angeltypes as $angeltype) {
$class = "";
- if ($angeltype['restricted'] == 1)
- if ($angeltype['confirm_user_id'] != null)
+ if ($angeltype['restricted'] == 1) {
+ if ($angeltype['confirm_user_id'] != null) {
$class = 'text-success';
- else
+ } else {
$class = 'text-warning';
- else
+ }
+ } else {
$class = 'text-success';
+ }
$output[] = '<a href="' . angeltype_link($angeltype['id']) . '" class="' . $class . '">' . ($angeltype['coordinator'] ? glyph('education') : '') . $angeltype['name'] . '</a>';
}
return join('<br />', $output);