Commit 949a0b32 authored by Robert Lyon's avatar Robert Lyon Committed by Gerrit Code Review

Merge "Allowing each blogpost in taggedblog block to show comments (Bug #1037531)"

parents 5a7e9f6b 4953a54a
......@@ -89,15 +89,27 @@ class PluginBlocktypeTaggedposts extends SystemBlocktype {
'view' => $view,
'block' => $instance->get('id'),
);
require_once(get_config('docroot') . 'lib/view.php');
$viewobj = new View($view);
foreach ($results as $result) {
$dataobject["artefact"] = $result->parent;
ensure_record_exists('view_artefact', $dataobject, $dataobject);
$result->postedbyon = get_string('postedbyon', 'artefact.blog', display_default_name($result->owner), format_date(strtotime($result->ctime)));
$result->displaydate= format_date(strtotime($result->ctime));
// get comment count for this post
// get comments for this post
require_once(get_config('docroot') . 'artefact/blog/lib.php');
$artefact = new ArtefactTypeBlogpost($result->id);
$result->commentcount = count_records_select('artefact_comment_comment', "onartefact = {$result->id} AND private = 0 AND deletedby IS NULL");
$allowcomments = $artefact->get('allowcomments');
if (empty($result->commentcount) && empty($allowcomments)) {
$result->commentcount = null;
}
require_once(get_config('docroot') . 'artefact/comment/lib.php');
require_once(get_config('docroot') . 'artefact/blog/lib.php');
list($commentcount, $comments) = ArtefactTypeComment::get_artefact_comments_for_view($artefact, $viewobj, null, false);
$result->comments = $comments;
// get all tags for this post
$taglist = get_records_array('artefact_tag', 'artefact', $result->id, "tag DESC");
......
......@@ -25,7 +25,25 @@
<div class="postdetails">{$post->postedbyon}</div>
<div class="detail">{$post->description|clean_html|safe}</div>
<div class="tags">{str tag=tags}: {list_tags owner=$post->owner tags=$post->taglist}</div>
{if $post->allowcomments}<div class="postdetails"><a href="{$WWWROOT}artefact/artefact.php?artefact={$post->id}&view={$view}">{str tag=Comments section=artefact.comment} ({$post->commentcount})</a></div>{/if}
{if $post->commentcount != null}
<div class="comments">
{if $post->commentcount > 0}
<a id="block_0{$post->id}{$blockid}" class="commentlink" href="{$WWWROOT}artefact/artefact.php?artefact={$post->id}&view={$view}">{str tag=Comments section=artefact.comment} ({$post->commentcount})</a>
{else}
{if $post->allowcomments}
<span class="nocomments">{str tag=Comments section=artefact.comment} ({$post->commentcount})</span>
{/if}
{/if}
{if $post->allowcomments}
<a class="addcomment bar-before" href="{$WWWROOT}artefact/artefact.php?artefact={$post->id}&view={$view}">{str tag=addcomment section=artefact.comment}</a>
{/if}
</div>
<div class="feedbacktablewrapper">
<div id="feedbacktable_0{$post->id}{$blockid}" class="feedbacktable">
{$post->comments->tablerows|safe}
</div>
</div>
{/if}
</div>
{/foreach}
</div>
......
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