MDL-52338 blocks: message link should not appear when set false
[moodle.git] / blocks / course_overview / renderer.php
index 8923322..1dad1ab 100644 (file)
@@ -325,7 +325,7 @@ class block_course_overview_renderer extends plugin_renderer_base {
      * @return string html string for welcome area.
      */
     public function welcome_area($msgcount) {
-        global $USER;
+        global $CFG, $USER;
         $output = $this->output->box_start('welcome_area');
 
         $picture = $this->output->user_picture($USER, array('size' => 75, 'class' => 'welcome_userpicture'));
@@ -334,16 +334,19 @@ class block_course_overview_renderer extends plugin_renderer_base {
         $output .= $this->output->box_start('welcome_message');
         $output .= $this->output->heading(get_string('welcome', 'block_course_overview', $USER->firstname));
 
-        $plural = 's';
-        if ($msgcount > 0) {
-            $output .= get_string('youhavemessages', 'block_course_overview', $msgcount);
-            if ($msgcount == 1) {
-                $plural = '';
+        if (!empty($CFG->messaging)) {
+            $plural = 's';
+            if ($msgcount > 0) {
+                $output .= get_string('youhavemessages', 'block_course_overview', $msgcount);
+                if ($msgcount == 1) {
+                    $plural = '';
+                }
+            } else {
+                $output .= get_string('youhavenomessages', 'block_course_overview');
             }
-        } else {
-            $output .= get_string('youhavenomessages', 'block_course_overview');
+            $output .= html_writer::link(new moodle_url('/message/index.php'),
+                    get_string('message'.$plural, 'block_course_overview'));
         }
-        $output .= html_writer::link(new moodle_url('/message/index.php'), get_string('message'.$plural, 'block_course_overview'));
         $output .= $this->output->box_end();
         $output .= $this->output->box('', 'flush');
         $output .= $this->output->box_end();