Skip to content

Commit

Permalink
Merge pull request #16 from durenadev/MDLSITE-1357
Browse files Browse the repository at this point in the history
Fix shows stash timemodified if exists
  • Loading branch information
mudrd8mz authored Jan 7, 2025
2 parents 33d9a8a + 98f4d71 commit 7fa3772
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
4 changes: 4 additions & 0 deletions locallib.php
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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, '/'));
Expand Down
19 changes: 16 additions & 3 deletions renderer.php
Original file line number Diff line number Diff line change
Expand Up @@ -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))),
Expand Down Expand Up @@ -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');

Expand Down

0 comments on commit 7fa3772

Please sign in to comment.