Commit d05c68b8 authored by Aaron Wells's avatar Aaron Wells
Browse files

Don't display comments area for images with no comments & comments disallowed

Bug 1419547

Change-Id: I2419b6443ad66992ca40d47263690c62ad5d9576
parent 561fb82f
......@@ -505,7 +505,7 @@ class ArtefactTypeComment extends ArtefactType {
/**
* Fetching the comments for an artefact to display on a view
*
* @param object $artfact The artefact to display comments for
* @param ArtefactType $artfact The artefact to display comments for
* @param object $view The view on which the artefact appears
* @param int $blockid The id of the block instance that connects the artefact to the view
* @param bool $html Whether to return the information rendered as html or not
......@@ -514,7 +514,7 @@ class ArtefactTypeComment extends ArtefactType {
* @return array $commentcount, $comments The count of comments and either the comments
* or the html to render them.
*/
public function get_artefact_comments_for_view($artefact, $view, $blockid, $html = true, $editing = false) {
public function get_artefact_comments_for_view(ArtefactType $artefact, $view, $blockid, $html = true, $editing = false) {
if (!is_object($artefact) || !is_object($view)) {
throw new MaharaException('we do not have the right information to display the comments');
}
......@@ -527,6 +527,11 @@ class ArtefactTypeComment extends ArtefactType {
$comments = ArtefactTypeComment::get_comments($commentoptions);
$commentcount = isset($comments->count) ? $comments->count : 0;
// If there are no comments, and comments are not allowed, don't display anything.
if ($commentcount == 0 && !$artefact->get('allowcomments')) {
return array(0, '');
}
$artefacturl = get_config('wwwroot') . 'artefact/artefact.php?view=' . $view->get('id') . '&artefact=' . $artefact->get('id');
if ($html) {
$smarty = smarty_core();
......
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