From bfe600c3e9aadabb90d2775f446bce2e367386a5 Mon Sep 17 00:00:00 2001 From: Martin Dougiamas Date: Wed, 19 May 2010 08:03:02 +0000 Subject: [PATCH] Don't show community heading unless there are courses under it --- blocks/community/block_community.php | 28 +++++++++++++++------------- 1 file changed, 15 insertions(+), 13 deletions(-) diff --git a/blocks/community/block_community.php b/blocks/community/block_community.php index f716fc8cdd9..d116d33ade2 100644 --- a/blocks/community/block_community.php +++ b/blocks/community/block_community.php @@ -48,20 +48,22 @@ class block_community extends block_list { $community = new community(); $courses = $community->get_community_courses($USER->id); - $this->content->items[] = ''; - $this->content->icons[] = ''; - $this->content->items[] = get_string('mycommunities', 'block_community'); - $this->content->icons[] = ''; - foreach ($courses as $course) { - //delete link - $deleteicon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/cross_red_small'))); - $deleteurl = new moodle_url($CFG->wwwroot.'/blocks/community/communitycourse.php', - array('remove'=>true, 'communityid'=> $course->id, 'sesskey' => sesskey())); - $deleteatag = html_writer::tag('a', $deleteicon, array('href' => $deleteurl)); - - $this->content->items[] = ''.$course->coursename.' ' . - $deleteatag; + if ($courses) { + $this->content->items[] = '
'; $this->content->icons[] = ''; + $this->content->items[] = get_string('mycommunities', 'block_community'); + $this->content->icons[] = ''; + foreach ($courses as $course) { + //delete link + $deleteicon = html_writer::empty_tag('img', array('src' => $OUTPUT->pix_url('i/cross_red_small'))); + $deleteurl = new moodle_url($CFG->wwwroot.'/blocks/community/communitycourse.php', + array('remove'=>true, 'communityid'=> $course->id, 'sesskey' => sesskey())); + $deleteatag = html_writer::tag('a', $deleteicon, array('href' => $deleteurl)); + + $this->content->items[] = ''.$course->coursename.' ' . + $deleteatag; + $this->content->icons[] = ''; + } } return $this->content;