diff --git a/locallib.php b/locallib.php index 5f52dc1..0bac3e5 100644 --- a/locallib.php +++ b/locallib.php @@ -40,6 +40,8 @@ class local_amos_stash implements renderable { public $name; /** @var int timestamp of when the stash was created */ public $timecreated; + /** @var int timestamp of when the stash was modified */ + public $timemodified; /** @var stdClass the owner of the stash */ public $owner; /** @var array of language names */ @@ -71,6 +73,7 @@ public static function instance_from_mlang_stash(mlang_stash $stash, stdClass $o $new->id = $stash->id; $new->name = $stash->name; $new->timecreated = $stash->timecreated; + $new->timemodified = $stash->timemodified; $stage = new mlang_stage(); $stash->apply($stage); @@ -109,6 +112,7 @@ public static function instance_from_record(stdClass $record, stdClass $owner) { $new->id = $record->id; $new->name = $record->name; $new->timecreated = $record->timecreated; + $new->timemodified = $record->timemodified; $new->strings = $record->strings; $new->components = explode('/', trim($record->components, '/')); $new->languages = explode('/', trim($record->languages, '/')); diff --git a/renderer.php b/renderer.php index 02800b9..4002ee1 100644 --- a/renderer.php +++ b/renderer.php @@ -334,8 +334,14 @@ protected function render_local_amos_stash(local_amos_stash $stash) { 'class' => 'my-2 mr-2 d-inline-block', 'size' => 21, ]); - $output .= html_writer::tag('div', userdate($stash->timecreated, get_string('strftimedaydatetime', 'langconfig')), - ['class' => 'timecreated']); + + if ($stash->timemodified) { + $output .= html_writer::tag('div', userdate($stash->timemodified, get_string('strftimedaydatetime', 'langconfig')), + ['class' => 'timemodified']); + } else { + $output .= html_writer::tag('div', userdate($stash->timecreated, get_string('strftimedaydatetime', 'langconfig')), + ['class' => 'timecreated']); + } $output .= html_writer::tag('div', get_string('stashstrings', 'local_amos', $stash->strings), ['class' => 'strings']); $output .= html_writer::tag('div', get_string('stashlanguages', 'local_amos', s(implode(', ', $stash->languages))), @@ -372,8 +378,15 @@ protected function render_local_amos_contribution(local_amos_contribution $contr $output = ''; $output .= $this->output->heading('#'.$contrib->info->id.' '.s($contrib->info->subject), 3, 'subject'); $output .= $this->output->container($this->output->user_picture($contrib->author) . fullname($contrib->author), 'author'); - $output .= $this->output->container(userdate($contrib->info->timecreated, + + if ($contrib->info->timemodified) { + $output .= $this->output->container(userdate($contrib->info->timemodified, + get_string('strftimedaydatetime', 'langconfig')), 'timemodified'); + } else { + $output .= $this->output->container(userdate($contrib->info->timecreated, get_string('strftimedaydatetime', 'langconfig')), 'timecreated'); + } + $output .= $this->output->container(format_text($contrib->info->message), 'message'); $output = $this->box($output, 'generalbox source');