summaryrefslogtreecommitdiff
path: root/includes/view
diff options
context:
space:
mode:
Diffstat (limited to 'includes/view')
-rw-r--r--includes/view/AngelTypes_view.php17
-rw-r--r--includes/view/ShiftEntry_view.php71
-rw-r--r--includes/view/ShiftTypes_view.php6
-rw-r--r--includes/view/UserAngelTypes_view.php51
-rw-r--r--includes/view/User_view.php14
5 files changed, 101 insertions, 58 deletions
diff --git a/includes/view/AngelTypes_view.php b/includes/view/AngelTypes_view.php
index fa9136c8..a8b34df8 100644
--- a/includes/view/AngelTypes_view.php
+++ b/includes/view/AngelTypes_view.php
@@ -50,14 +50,14 @@ function AngelType_delete_view($angeltype)
return page_with_title(sprintf(_('Delete angeltype %s'), $angeltype['name']), [
info(sprintf(_('Do you want to delete angeltype %s?'), $angeltype['name']), true),
buttons([
- button(page_link_to('angeltypes'), _('cancel'), 'cancel'),
+ button(page_link_to('angeltypes'), glyph('remove') . _('cancel')),
button(
page_link_to(
'angeltypes',
['action' => 'delete', 'angeltype_id' => $angeltype['id'], 'confirmed' => 1]
),
- _('delete'),
- 'ok'
+ glyph('ok') . _('delete'),
+ 'btn-danger'
)
])
]);
@@ -153,7 +153,7 @@ function AngelType_view_buttons($angeltype, $user_angeltype, $admin_angeltypes,
}
$buttons[] = button(
page_link_to('user_angeltypes', ['action' => 'delete', 'user_angeltype_id' => $user_angeltype['id']]),
- _('leave'), 'cancel'
+ _('leave')
);
}
@@ -442,13 +442,11 @@ function AngelType_view_info(
$info[] = buttons([
button(
page_link_to('user_angeltypes', ['action' => 'confirm_all', 'angeltype_id' => $angeltype['id']]),
- _('confirm all'),
- 'ok'
+ glyph('ok') . _('confirm all')
),
button(
page_link_to('user_angeltypes', ['action' => 'delete_all', 'angeltype_id' => $angeltype['id']]),
- _('deny all'),
- 'cancel'
+ glyph('remove') . _('deny all')
)
]);
$info[] = table($table_headers, $members_unconfirmed);
@@ -523,8 +521,7 @@ function AngelTypes_about_view_angeltype($angeltype)
'user_angeltypes',
['action' => 'delete', 'user_angeltype_id' => $angeltype['user_angeltype_id']]
),
- _('leave'),
- 'cancel'
+ _('leave')
);
} else {
$buttons[] = button(
diff --git a/includes/view/ShiftEntry_view.php b/includes/view/ShiftEntry_view.php
index 2e638df6..6dceac10 100644
--- a/includes/view/ShiftEntry_view.php
+++ b/includes/view/ShiftEntry_view.php
@@ -1,6 +1,77 @@
<?php
/**
+ * Sign off from an user from a shift with admin permissions, asking for ack.
+ *
+ * @param array $shiftEntry
+ * @param array $shift
+ * @param array $angeltype
+ * @param array $signoff_user
+ *
+ * @return string HTML
+ */
+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),
+ buttons([
+ button(user_link($signoff_user), glyph('remove') . _('cancel')),
+ button(ShiftEntry_delete_link($shiftEntry, ['continue' => 1]), glyph('ok') . _('delete'), 'btn-danger')
+ ])
+ ]);
+}
+
+/**
+ * Sign off from a shift, asking for ack.
+ *
+ * @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),
+ buttons([
+ button(user_link($signoff_user), glyph('remove') . _('cancel')),
+ button(ShiftEntry_delete_link($shiftEntry, ['continue' => 1]), glyph('ok') . _('delete'), 'btn-danger')
+ ])
+ ]);
+}
+
+/**
+ * Link to delete a shift entry.
+ * @param array $shiftEntry
+ *
+ * @return string URL
+ */
+function ShiftEntry_delete_link($shiftEntry, $params = []) {
+ $params = array_merge(['entry_id' => $shiftEntry['id']], $params);
+ return page_link_to('user_shifts', $params);
+}
+
+/**
+ * Title for deleting a shift entry.
+ */
+function ShiftEntry_delete_title() {
+ return _('Shift sign off');
+}
+
+/**
* Display form for adding/editing a shift entry.
*
* @param string $angel
diff --git a/includes/view/ShiftTypes_view.php b/includes/view/ShiftTypes_view.php
index 74e0d7c0..7dee4521 100644
--- a/includes/view/ShiftTypes_view.php
+++ b/includes/view/ShiftTypes_view.php
@@ -22,14 +22,14 @@ function ShiftType_delete_view($shifttype)
return page_with_title(sprintf(_('Delete shifttype %s'), $shifttype['name']), [
info(sprintf(_('Do you want to delete shifttype %s?'), $shifttype['name']), true),
buttons([
- button(page_link_to('shifttypes'), _('cancel'), 'cancel'),
+ button(page_link_to('shifttypes'), glyph('remove') . _('cancel')),
button(
page_link_to(
'shifttypes',
['action' => 'delete', 'shifttype_id' => $shifttype['id'], 'confirmed' => 1]
),
- _('delete'),
- 'ok btn-danger'
+ glyph('ok') . _('delete'),
+ 'btn-danger'
)
])
]);
diff --git a/includes/view/UserAngelTypes_view.php b/includes/view/UserAngelTypes_view.php
index 98f6c3e9..c46c1ee1 100644
--- a/includes/view/UserAngelTypes_view.php
+++ b/includes/view/UserAngelTypes_view.php
@@ -21,8 +21,7 @@ function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporte
buttons([
button(
page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
- _('cancel'),
- 'cancel'
+ glyph('remove') . _('cancel')
),
button(
page_link_to('user_angeltypes', [
@@ -31,8 +30,8 @@ function UserAngelType_update_view($user_angeltype, $user, $angeltype, $supporte
'supporter' => ($supporter ? '1' : '0'),
'confirmed' => 1,
]),
- _('yes'),
- 'ok'
+ glyph('ok') . _('yes'),
+ 'btn-primary'
)
])
]);
@@ -53,16 +52,15 @@ function UserAngelTypes_delete_all_view($angeltype)
'angeltypes',
['action' => 'view', 'angeltype_id' => $angeltype['id']]
),
- _('cancel'),
- 'cancel'
+ glyph('remove') . _('cancel')
),
button(
page_link_to(
'user_angeltypes',
['action' => 'delete_all', 'angeltype_id' => $angeltype['id'], 'confirmed' => 1]
),
- _('yes'),
- 'ok'
+ glyph('ok') . _('yes'),
+ 'btn-primary'
)
])
]);
@@ -78,13 +76,12 @@ function UserAngelTypes_confirm_all_view($angeltype)
msg(),
info(sprintf(_('Do you really want to confirm all users for %s?'), $angeltype['name']), true),
buttons([
- button(page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]), _('cancel'),
- 'cancel'),
+ button(angeltype_link($angeltype['id']), glyph('remove') . _('cancel')),
button(
page_link_to('user_angeltypes',
['action' => 'confirm_all', 'angeltype_id' => $angeltype['id'], 'confirmed' => 1]),
- _('yes'),
- 'ok'
+ glyph('ok') . _('yes'),
+ 'btn-primary'
)
])
]);
@@ -102,18 +99,14 @@ function UserAngelType_confirm_view($user_angeltype, $user, $angeltype)
msg(),
info(sprintf(_('Do you really want to confirm %s for %s?'), User_Nick_render($user), $angeltype['name']), true),
buttons([
- button(
- page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
- _('cancel'),
- 'cancel'
- ),
+ button(angeltype_link($angeltype['id']), glyph('remove') . _('cancel')),
button(
page_link_to(
'user_angeltypes',
['action' => 'confirm', 'user_angeltype_id' => $user_angeltype['id'], 'confirmed' => 1]
),
- _('yes'),
- 'ok'
+ glyph('ok') . _('yes'),
+ 'btn-primary'
)
])
]);
@@ -131,16 +124,12 @@ function UserAngelType_delete_view($user_angeltype, $user, $angeltype)
msg(),
info(sprintf(_('Do you really want to delete %s from %s?'), User_Nick_render($user), $angeltype['name']), true),
buttons([
- button(
- page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
- _('cancel'),
- 'cancel'
- ),
+ button(angeltype_link($angeltype['id']), glyph('remove') . _('cancel')),
button(
page_link_to('user_angeltypes',
['action' => 'delete', 'user_angeltype_id' => $user_angeltype['id'], 'confirmed' => 1]),
- _('yes'),
- 'ok'
+ glyph('ok') . _('yes'),
+ 'btn-primary'
)
])
]);
@@ -187,18 +176,14 @@ function UserAngelType_join_view($user, $angeltype)
msg(),
info(sprintf(_('Do you really want to add %s to %s?'), User_Nick_render($user), $angeltype['name']), true),
buttons([
- button(
- page_link_to('angeltypes', ['action' => 'view', 'angeltype_id' => $angeltype['id']]),
- _('cancel'),
- 'cancel'
- ),
+ button(angeltype_link($angeltype['id']), glyph('remove') . _('cancel')),
button(
page_link_to(
'user_angeltypes',
['action' => 'add', 'angeltype_id' => $angeltype['id'], 'user_id' => $user['UID'], 'confirmed' => 1]
),
- _('save'),
- 'ok'
+ glyph('ok') . _('save'),
+ 'btn-primary'
)
])
]);
diff --git a/includes/view/User_view.php b/includes/view/User_view.php
index 04fb4d04..e47603fb 100644
--- a/includes/view/User_view.php
+++ b/includes/view/User_view.php
@@ -363,19 +363,9 @@ function User_view_myshift($shift, $user_source, $its_me)
'btn-xs'
);
}
- if (
- ($shift['start'] > time() + config('last_unsubscribe') * 3600)
- || in_array('user_shifts_admin', $privileges)
- ) {
- $parameters = [
- 'cancel' => $shift['id'],
- 'id' => $user_source['UID'],
- ];
- if ($its_me) {
- $parameters['id'] = '';
- }
+ if (Shift_signout_allowed($shift, ['id' => $shift['TID']], $user_source)) {
$myshift['actions'][] = button(
- page_link_to('user_myshifts', $parameters),
+ ShiftEntry_delete_link($shift),
glyph('trash') . _('sign off'),
'btn-xs'
);