Skip to content

Commit 7fa3772

Browse files
authored
Merge pull request #16 from durenadev/MDLSITE-1357
Fix shows stash timemodified if exists
2 parents 33d9a8a + 98f4d71 commit 7fa3772

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

locallib.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,8 @@ class local_amos_stash implements renderable {
4040
public $name;
4141
/** @var int timestamp of when the stash was created */
4242
public $timecreated;
43+
/** @var int timestamp of when the stash was modified */
44+
public $timemodified;
4345
/** @var stdClass the owner of the stash */
4446
public $owner;
4547
/** @var array of language names */
@@ -71,6 +73,7 @@ public static function instance_from_mlang_stash(mlang_stash $stash, stdClass $o
7173
$new->id = $stash->id;
7274
$new->name = $stash->name;
7375
$new->timecreated = $stash->timecreated;
76+
$new->timemodified = $stash->timemodified;
7477

7578
$stage = new mlang_stage();
7679
$stash->apply($stage);
@@ -109,6 +112,7 @@ public static function instance_from_record(stdClass $record, stdClass $owner) {
109112
$new->id = $record->id;
110113
$new->name = $record->name;
111114
$new->timecreated = $record->timecreated;
115+
$new->timemodified = $record->timemodified;
112116
$new->strings = $record->strings;
113117
$new->components = explode('/', trim($record->components, '/'));
114118
$new->languages = explode('/', trim($record->languages, '/'));

renderer.php

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -334,8 +334,14 @@ protected function render_local_amos_stash(local_amos_stash $stash) {
334334
'class' => 'my-2 mr-2 d-inline-block',
335335
'size' => 21,
336336
]);
337-
$output .= html_writer::tag('div', userdate($stash->timecreated, get_string('strftimedaydatetime', 'langconfig')),
338-
['class' => 'timecreated']);
337+
338+
if ($stash->timemodified) {
339+
$output .= html_writer::tag('div', userdate($stash->timemodified, get_string('strftimedaydatetime', 'langconfig')),
340+
['class' => 'timemodified']);
341+
} else {
342+
$output .= html_writer::tag('div', userdate($stash->timecreated, get_string('strftimedaydatetime', 'langconfig')),
343+
['class' => 'timecreated']);
344+
}
339345
$output .= html_writer::tag('div', get_string('stashstrings', 'local_amos', $stash->strings),
340346
['class' => 'strings']);
341347
$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
372378
$output = '';
373379
$output .= $this->output->heading('#'.$contrib->info->id.' '.s($contrib->info->subject), 3, 'subject');
374380
$output .= $this->output->container($this->output->user_picture($contrib->author) . fullname($contrib->author), 'author');
375-
$output .= $this->output->container(userdate($contrib->info->timecreated,
381+
382+
if ($contrib->info->timemodified) {
383+
$output .= $this->output->container(userdate($contrib->info->timemodified,
384+
get_string('strftimedaydatetime', 'langconfig')), 'timemodified');
385+
} else {
386+
$output .= $this->output->container(userdate($contrib->info->timecreated,
376387
get_string('strftimedaydatetime', 'langconfig')), 'timecreated');
388+
}
389+
377390
$output .= $this->output->container(format_text($contrib->info->message), 'message');
378391
$output = $this->box($output, 'generalbox source');
379392

0 commit comments

Comments
 (0)