]> git.mjollnir.org Git - moodle.git/commitdiff
Don't display blocks that have no content at all. I 'm not sure if this
authordefacer <defacer>
Tue, 20 Apr 2004 07:43:26 +0000 (07:43 +0000)
committerdefacer <defacer>
Tue, 20 Apr 2004 07:43:26 +0000 (07:43 +0000)
could cause any confusion, but it solves the problem with the admin block
being displayed to guests.

The thought about a "display only to X and Y kinds of users" feature came
to mind, but maybe that would be more confusing than useful.

blocks/moodleblock.class.php

index 1e36b5338543b362bba52c9e910ecf7fea03cd91..b515b8d8fbc81779598c87efaca591613c5d3cfd 100644 (file)
@@ -49,15 +49,20 @@ class MoodleBlock {
         return $this->get_content();
     }
     function print_block() {
-        // Wrap it up, in case we have buttons too
+        // Wrap the title in a floating DIV, in case we have edit controls to display
+        // These controls will always be wrapped on a right-floating DIV
         $title = '<div style="float: left;">'.$this->title.'</div>';
         if($this->edit_controls !== NULL) {
             $title .= $this->edit_controls;
         }
+
         $this->get_content();
 
         switch($this->content_type) {
             case BLOCK_TYPE_TEXT:
+                if(empty($this->content->text)) {
+                    break;
+                }
                 if ($this->edit_controls !== NULL || !$this->hide_header()) {
                     print_side_block($title, $this->content->text, NULL, NULL, $this->content->footer);
                 } else {
@@ -65,6 +70,9 @@ class MoodleBlock {
                 }
             break;
             case BLOCK_TYPE_LIST:
+                if(empty($this->content->items)) {
+                    break;
+                }
                 if ($this->edit_controls !== NULL || !$this->hide_header()) {
                     print_side_block($title, '', $this->content->items, $this->content->icons, $this->content->footer);
                 } else {