diff options
Diffstat (limited to 'includes')
-rw-r--r-- | includes/model/Shifts_model.php | 10 | ||||
-rw-r--r-- | includes/view/Shifts_view.php | 13 |
2 files changed, 20 insertions, 3 deletions
diff --git a/includes/model/Shifts_model.php b/includes/model/Shifts_model.php index c12d3e01..d32de0cb 100644 --- a/includes/model/Shifts_model.php +++ b/includes/model/Shifts_model.php @@ -101,6 +101,7 @@ function Shift_delete($shift_id) { * Update a shift. */ function Shift_update($shift) { + global $user; $shift['name'] = ShiftType($shift['shifttype_id'])['name']; mail_shift_change(Shift($shift['SID']), $shift); @@ -111,7 +112,9 @@ function Shift_update($shift) { `RID`='" . sql_escape($shift['RID']) . "', `title`=" . sql_null($shift['title']) . ", `URL`=" . sql_null($shift['URL']) . ", - `PSID`=" . sql_null($shift['PSID']) . " + `PSID`=" . sql_null($shift['PSID']) . ", + `edited_by_user_id`='" . sql_escape($user['UID']) . "', + `edited_at_timestamp`=" . time() . " WHERE `SID`='" . sql_escape($shift['SID']) . "'"); } @@ -134,6 +137,7 @@ function Shift_update_by_psid($shift) { * @return new shift id or false */ function Shift_create($shift) { + global $user; $result = sql_query("INSERT INTO `Shifts` SET `shifttype_id`='" . sql_escape($shift['shifttype_id']) . "', `start`='" . sql_escape($shift['start']) . "', @@ -141,7 +145,9 @@ function Shift_create($shift) { `RID`='" . sql_escape($shift['RID']) . "', `title`=" . sql_null($shift['title']) . ", `URL`=" . sql_null($shift['URL']) . ", - `PSID`=" . sql_null($shift['PSID'])); + `PSID`=" . sql_null($shift['PSID']) . ", + `created_by_user_id`='" . sql_escape($user['UID']) . "', + `created_at_timestamp`=" . time()); if ($result === false) return false; return sql_id(); diff --git a/includes/view/Shifts_view.php b/includes/view/Shifts_view.php index 9586cf90..b0628a3b 100644 --- a/includes/view/Shifts_view.php +++ b/includes/view/Shifts_view.php @@ -1,5 +1,14 @@ <?php +function Shift_editor_info_render($shift) { + $info = []; + 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) + $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); +} + function Shift_signup_button_render($shift, $angeltype, $user_angeltype = null, $user_shifts = null) { global $user; @@ -60,6 +69,7 @@ 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) : '', @@ -104,7 +114,8 @@ function Shift_view($shift, $shifttype, $room, $shift_admin, $angeltypes_source, '<h2>' . _('Description') . '</h2>', $parsedown->parse($shifttype['description']) ]) - ]) + ]), + $shift_admin ? Shift_editor_info_render($shift) : '' ]); } |