Commit f78caa47 by Cecilia Vela Gurovic Committed by Robert Lyon

Bug 1666099: Draft journal entries should be hidden

When a journal entry is marked as draft, we can't add it to a block we don't show it in a page, instead we show a placeholder with a message see bug 1387858 Change-Id: I73c475bbc6baddc0dc38c9e7a2c3c60b24a617b4 behatnotneeded (cherry picked from commit 6eb1dde2)
parent 0a3d7d82
......@@ -105,6 +105,7 @@ class PluginBlocktypeBlog extends MaharaCoreBlocktype {
$canaddpost = true;
}
$smarty->assign('alldraftposts', (isset($posts['alldraftposts']) ? $posts['alldraftposts'] : null));
$smarty->assign('options', $configdata);
$smarty->assign('description', $blog->get('description'));
$smarty->assign('owner', $blog->get('owner'));
......
......@@ -30,6 +30,7 @@ $string['attachedfilelistloaded'] = 'Attached file list loaded';
$string['attachedfiles'] = 'Attached files';
$string['attachment'] = 'Attachment';
$string['attachments'] = 'Attachments';
$string['alldraftposts'] = 'The journal entries have not been published yet.';
$string['blogcopiedfromanotherview'] = 'Note: This block has been copied from another page. You may move it around or remove it, but you cannot change what %s is in it.';
$string['blogdesc'] = 'Description';
$string['blogdescdesc'] = 'e.g., ‘A record of Jill\'s experiences and reflections’.';
......
......@@ -947,11 +947,17 @@ class ArtefactTypeBlogPost extends ArtefactType {
if (isset($viewoptions['before'])) {
$from .= " AND a.ctime < '{$viewoptions['before']}'";
}
$draftentries = count_records_sql('SELECT COUNT(*) ' . $from, array($id));
$from .= ' AND bp.published = 1';
}
$results['count'] = count_records_sql('SELECT COUNT(*) ' . $from, array($id));
//check if all posts are drafts
if (isset($draftentries) && $draftentries > 0 && $results['count'] == 0) {
$results['alldraftposts'] = true;
}
$data = get_records_sql_assoc('
SELECT
a.id, a.title, a.description, a.author, a.authorname, ' .
......
......@@ -3489,6 +3489,11 @@ class View {
}
}
if (isset($data['blocktype']) && $data['blocktype'] == 'blogpost') {
$from .= ' INNER JOIN artefact_blog_blogpost abb on a.id = abb.blogpost ';
$select .= ' AND abb.published = 1 ';
}
$artefacts = get_records_sql_assoc(
'SELECT ' . $cols . $from . ' WHERE ' . $select . $sortorder, $selectph, $offset, $limit
);
......
<div class="blog">
{if $alldraftposts}
{str tag='alldraftposts' section='artefact.blog'}
{/if}
{if ($editing && $canaddpost)}
<a class="panel-footer" href="{$WWWROOT}artefact/blog/post.php?blog={$blogid}">
<span class="icon icon-plus text-success left" role="presentation" aria-hidden="true"></span>
......
{**
* This template displays a blog post.
*}
{if $published}
<div id="blogpost-{$postid}" class="panel-body flush">
{if $artefacttitle && $simpledisplay}
......@@ -78,3 +78,8 @@
</div>
{/if}
</div>
{else}
<div>
{$notpublishedblogpost|safe}
</div>
{/if}
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