From f2b7d1c7dd6747493f24565348fdd2fbab8b31b4 Mon Sep 17 00:00:00 2001 From: Benjamin Walker Date: Wed, 31 Dec 2025 15:27:01 +1000 Subject: [PATCH] Display creation info on manage outage page --- classes/output/manage/base_table.php | 35 +++++++++++++++++++++++++ classes/output/manage/history_table.php | 6 ++++- classes/output/manage/planned_table.php | 6 ++++- lang/en/auth_outage.php | 2 ++ version.php | 4 +-- 5 files changed, 49 insertions(+), 4 deletions(-) diff --git a/classes/output/manage/base_table.php b/classes/output/manage/base_table.php index 4223470..0e5b305 100644 --- a/classes/output/manage/base_table.php +++ b/classes/output/manage/base_table.php @@ -64,6 +64,41 @@ class base_table extends flexible_table { $this->set_attribute('class', 'generaltable admintable'); } + /** + * Displays a user by their fullname with a link to a profile. + * @param int $userid + * @return string HTML link to user profile + */ + private function format_user(int $userid): string { + if ($userid == 0 || !$user = \core_user::get_user($userid)) { + return get_string('na', 'auth_outage'); + } + $url = new moodle_url('/user/profile.php', ['id' => $userid]); + return html_writer::link($url, fullname($user)); + } + + /** + * Formats created by column. + * @param outage $outage + * @return string The user who created the outage. + */ + protected function format_created(outage $outage): string { + return $this->format_user($outage->createdby); + } + + /** + * Formats modified by column. + * @param outage $outage + * @return string The user who last modiifed the outage and the last modified time. + */ + protected function format_modified(outage $outage): string { + $timestamp = html_writer::div( + userdate($outage->lastmodified, get_string('datetimeformat', 'auth_outage')), + 'small text-muted' + ); + return $this->format_user($outage->modifiedby) . $timestamp; + } + /** * Create the action buttons HTML code for a specific outage. * @param outage $outage The outage to generate the buttons. diff --git a/classes/output/manage/history_table.php b/classes/output/manage/history_table.php index 2514a6d..8740515 100644 --- a/classes/output/manage/history_table.php +++ b/classes/output/manage/history_table.php @@ -36,7 +36,7 @@ class history_table extends base_table { public function __construct() { parent::__construct(); - $this->define_columns(['warning', 'starts', 'durationplanned', 'durationactual', 'title', 'actions']); + $this->define_columns(['warning', 'starts', 'duration', 'durationactual', 'title', 'created', 'modified', 'actions']); $this->define_headers([ get_string('tableheaderwarnbefore', 'auth_outage'), @@ -44,6 +44,8 @@ class history_table extends base_table { get_string('tableheaderdurationplanned', 'auth_outage'), get_string('tableheaderdurationactual', 'auth_outage'), get_string('tableheadertitle', 'auth_outage'), + get_string('tableheadercreatedby', 'auth_outage'), + get_string('tableheadermodifiedby', 'auth_outage'), get_string('actions'), ]); @@ -64,6 +66,8 @@ class history_table extends base_table { format_time($outage->get_duration_planned()), $finished, $outage->get_title(), + $this->format_created($outage), + $this->format_modified($outage), $this->create_data_buttons($outage, false), ]); } diff --git a/classes/output/manage/planned_table.php b/classes/output/manage/planned_table.php index 6c78aef..18cf472 100644 --- a/classes/output/manage/planned_table.php +++ b/classes/output/manage/planned_table.php @@ -38,13 +38,15 @@ class planned_table extends base_table { public function __construct() { parent::__construct(); - $this->define_columns(['warning', 'starts', 'duration', 'title', 'actions']); + $this->define_columns(['warning', 'starts', 'duration', 'title', 'created', 'modified', 'actions']); $this->define_headers([ get_string('tableheaderwarnbefore', 'auth_outage'), get_string('tableheaderstarttime', 'auth_outage'), get_string('tableheaderduration', 'auth_outage'), get_string('tableheadertitle', 'auth_outage'), + get_string('tableheadercreatedby', 'auth_outage'), + get_string('tableheadermodifiedby', 'auth_outage'), get_string('actions'), ]); @@ -68,6 +70,8 @@ class planned_table extends base_table { self::create_starttime_string($outage->starttime), format_time($outage->get_duration_planned()), $title, + $this->format_created($outage), + $this->format_modified($outage), $this->create_data_buttons($outage, true), ]); } diff --git a/lang/en/auth_outage.php b/lang/en/auth_outage.php index 2948336..15f1b85 100644 --- a/lang/en/auth_outage.php +++ b/lang/en/auth_outage.php @@ -149,9 +149,11 @@ $string['settingssectionplugin'] = 'Plugin Configuration'; $string['settingssectionplugindescription'] = 'General outage management plugin settings.'; $string['starttime'] = 'Start date and time'; $string['starttime_help'] = 'At which date and time the outage starts, preventing general access to the system.'; +$string['tableheadercreatedby'] = 'Created by'; $string['tableheaderduration'] = 'Duration'; $string['tableheaderdurationactual'] = 'Actual duration'; $string['tableheaderdurationplanned'] = 'Planned duration'; +$string['tableheadermodifiedby'] = 'Last modified by'; $string['tableheaderstartedtime'] = 'Started on'; $string['tableheaderstarttime'] = 'Starts on'; $string['tableheadertitle'] = 'Title'; diff --git a/version.php b/version.php index 3025f3e..665bd72 100644 --- a/version.php +++ b/version.php @@ -28,8 +28,8 @@ defined('MOODLE_INTERNAL') || die(); $plugin->component = "auth_outage"; -$plugin->version = 2024081902; // The current plugin version (Date: YYYYMMDDXX). -$plugin->release = 2024081902; // Human-readable release information. +$plugin->version = 2024081903; // The current plugin version (Date: YYYYMMDDXX). +$plugin->release = 2024081903; // Human-readable release information. $plugin->requires = 2017111309; // 2017111309 = T13, but this really requires 3.9 and higher. $plugin->maturity = MATURITY_STABLE; // Suitable for PRODUCTION environments! $plugin->supported = [39, 405]; // A range of branch numbers of supported moodle versions.