Commit d2752322 authored by Robert Lyon's avatar Robert Lyon Committed by Cecilia Vela Gurovic
Browse files

Bug 1381228: Show created and updated dates for blogpost



If the created and updated dates are different for a
blogpost, we see both dates.

Based on  Robert's Proof of Concept

With showing both the created and updated dates for a
journal entry (blogpost)

Change-Id: If1701b56a12d39b017a8bb498fa1fbd0ea1ce92b
Signed-off-by: Robert Lyon's avatarRobert Lyon <robertl@catalyst.net.nz>
parent 552d6e93
......@@ -16,3 +16,4 @@ $string['description'] = 'Display the most recent journal entries (see Content -
$string['itemstoshow'] = 'Entries to show';
$string['postedin'] = 'in';
$string['postedon'] = 'on';
$string['updatedon'] = 'Last updated';
......@@ -90,7 +90,7 @@ class PluginBlocktypeRecentposts extends MaharaCoreBlocktype {
$blogids = $configdata['artefactids'];
$artefactids = implode(', ', array_map('db_quote', $blogids));
$mostrecent = get_records_sql_array(
'SELECT a.title, ' . db_format_tsfield('a.ctime', 'ctime') . ', p.title AS parenttitle, a.id, a.parent
'SELECT a.title, ' . db_format_tsfield('a.ctime', 'ctime') . ', p.title AS parenttitle, a.id, a.parent, ' . db_format_tsfield('a.mtime', 'mtime') . '
FROM {artefact} a
JOIN {artefact} p ON a.parent = p.id
JOIN {artefact_blog_blogpost} ab ON (ab.blogpost = a.id AND ab.published = 1)
......@@ -115,6 +115,9 @@ class PluginBlocktypeRecentposts extends MaharaCoreBlocktype {
// format the dates
foreach ($mostrecent as &$data) {
$data->displaydate = format_date($data->ctime);
if ($data->ctime != $data->mtime) {
$data->updateddate = format_date($data->mtime);
}
}
$smarty = smarty_core();
$smarty->assign('mostrecent', $mostrecent);
......
......@@ -37,6 +37,7 @@ $string['notagsavailable'] = 'You have not created any tags';
$string['notagsavailableerror'] = 'No tag selected. You need to add tags to your journal entries before being able to select them here.';
$string['postedin'] = 'in';
$string['postedon'] = 'on';
$string['updatedon'] = 'Last updated';
$string['itemstoshow'] = 'Items to show';
$string['configerror'] = 'Error during block configuration';
$string['showjournalitemsinfull'] = 'Show journal entries in full';
......
......@@ -106,7 +106,7 @@ class PluginBlocktypeTaggedposts extends MaharaCoreBlocktype {
$tagsout = array_filter($tagsout);
$sqlvalues = array($view);
$sql =
'SELECT a.title, p.title AS parenttitle, a.id, a.parent, a.owner, a.description, a.allowcomments, at.tag, a.ctime
'SELECT a.title, p.title AS parenttitle, a.id, a.parent, a.owner, a.description, a.allowcomments, at.tag, a.ctime, a.mtime
FROM {artefact} a
JOIN {artefact} p ON a.parent = p.id
JOIN {artefact_blog_blogpost} ab ON (ab.blogpost = a.id AND ab.published = 1)
......@@ -215,6 +215,9 @@ class PluginBlocktypeTaggedposts extends MaharaCoreBlocktype {
$dataobject["artefact"] = $result->parent;
$result->postedbyon = get_string('postedbyon', 'artefact.blog', display_default_name($result->owner), format_date(strtotime($result->ctime)));
$result->displaydate= format_date(strtotime($result->ctime));
if ($result->ctime != $result->mtime) {
$result->updateddate= format_date(strtotime($result->mtime));
}
$artefact = new ArtefactTypeBlogpost($result->id);
// get comments for this post
......
......@@ -95,6 +95,7 @@ $string['post'] = 'entry';
$string['postbody'] = 'Entry';
$string['postbodydesc'] = ' ';
$string['postedon'] = 'Posted on';
$string['updatedon'] = 'Last updated';
$string['postedbyon'] = 'Posted by %s on %s';
$string['posttitle'] = 'Title';
$string['posts'] = 'entries';
......
......@@ -878,6 +878,9 @@ class ArtefactTypeBlogPost extends ArtefactType {
$smarty->assign('postedbyon', get_string('postedbyon', 'artefact.blog',
display_name($this->owner),
format_date($this->ctime)));
if ($this->ctime != $this->mtime) {
$smarty->assign('updatedon', get_string('updatedon', 'artefact.blog') . ' ' . format_date($this->mtime));
}
return array('html' => $smarty->fetch('artefact:blog:render/blogpost_renderfull.tpl'),
'javascript' => '');
}
......@@ -1026,6 +1029,9 @@ class ArtefactTypeBlogPost extends ArtefactType {
$post->comments = $comments;
}
}
if ($post->ctime != $post->mtime) {
$post->lastupdated = format_date($post->mtime, 'strftimedaydatetime');
}
$post->ctime = format_date($post->ctime, 'strftimedaydatetime');
$post->mtime = format_date($post->mtime);
......
......@@ -41,6 +41,11 @@
<span class="metadata">
{str tag='postedon' section='blocktype.blog/recentposts'}
{$post->displaydate}
<br>
{if $post->updateddate}
{str tag='updatedon' section='blocktype.blog/recentposts'}
{$post->updateddate}
{/if}
</span>
</div>
{/foreach}
......
......@@ -125,6 +125,11 @@
<span class="metadata">
{str tag='postedon' section='blocktype.blog/taggedposts'}
{$post->displaydate}
{if $post->updateddate}
<br>
{str tag='updatedon' section='blocktype.blog/taggedposts'}
{$post->updateddate}
{/if}
</span>
</h4>
</div>
......
......@@ -45,6 +45,14 @@
{str tag=postedon section=artefact.blog}:
</strong>
{$post->ctime}
{if $post->lastupdated}
<br>
<span class="icon icon-calendar left" role="presentation" aria-hidden="true"></span>
<strong>
{str tag=updatedon section=artefact.blog}:
</strong>
{$post->lastupdated}
{/if}
{if $post->tags}
<p id="posttags_{$post->id}" class="tags">
......
......@@ -13,6 +13,11 @@
<div class="postdetails metadata">
<span class="icon icon-calendar left" role="presentation" aria-hidden="true"></span>
{$postedbyon}
{if $updatedon}
<br>
<span class="icon icon-calendar left" role="presentation" aria-hidden="true"></span>
{$updatedon}
{/if}
</div>
{if $artefact->get('tags')}
......
......@@ -7,6 +7,11 @@
<div class="postdetails metadata">
<span class="icon icon-calendar left" role="presentation" aria-hidden="true"></span>
{$post->postedby}
{if $post->lastupdated}
<br>
<span class="icon icon-calendar left" role="presentation" aria-hidden="true"></span>
{str tag=updatedon section=artefact.blog} {$post->lastupdated}
{/if}
</div>
{if $post->tags}
<div class="tags metadata">
......
@javascript @core @core_artefact
Feature: Editing my journal
In order to edit my journal
As an admin/user
As an user
I need to create a journal
Background:
......@@ -10,8 +10,8 @@ Given the following "users" exist:
| userA | Kupuhipa1 | test01@example.com | Pete | Mc | mahara | internal | member |
Scenario Outline: Creating a journal and editing it (Bug 1513716)
Given I log in as "<log>" with password "Kupuhipa1"
Scenario: Creating a journal and editing it (Bug 1513716)
Given I log in as "userA" with password "Kupuhipa1"
# Creating a journal
And I choose "Journals" in "Content"
And I should see "Journals"
......@@ -27,10 +27,6 @@ And I set the following fields to these values:
| Title | My new journal |
| Entry | Jinelle was here Nov 2015 |
And I press "Save entry"
And I should see "Journal entry saved"
And I should see "Jinelle was here Nov 2015"
Examples:
| log |
| admin |
| userA |
And I should see "Jinelle was here Nov 2015"
And I should see "Last updated:"
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment