]> git.mjollnir.org Git - moodle.git/commitdiff
MDL-12464 - if a glossary is deleted, it causes some breakage in the
authorpoltawski <poltawski>
Thu, 6 Dec 2007 15:43:46 +0000 (15:43 +0000)
committerpoltawski <poltawski>
Thu, 6 Dec 2007 15:43:46 +0000 (15:43 +0000)
random glossary block

Merged from MOODLE_19_STABLE

blocks/glossary_random/block_glossary_random.php

index 315e83014b1e35dd7c9ebcea2c8d8ccc816b6a08..b14453761f8450602f5e62dca8b4e6a0b9110428 100644 (file)
@@ -161,6 +161,21 @@ class block_glossary_random extends block_base {
             return $this->content;
         }
 
+        $glossaryid = $this->config->glossary;
+
+        if(! $glossary = get_record('glossary', 'id', $glossaryid) ){
+            // we can get here if the glossary has been deleted, so
+            // unconfigure the glossary from the block..
+            $this->config->glossary = 0;
+            $this->config->cache = '';
+            $this->instance_config_commit();
+
+            $this->content->text   = get_string('notyetconfigured','block_glossary_random');
+            $this->content->footer = '';
+            return $this->content;
+        }
+
+
         if (empty($this->config->cache)) {
             $this->config->cache = '';
         }
@@ -173,8 +188,6 @@ class block_glossary_random extends block_base {
         $this->content->text = $this->config->cache;
 
         // place link to glossary in the footer if the glossary is visible
-        $glossaryid = $this->config->glossary;
-        $glossary=get_record('glossary', 'id', $glossaryid);
 
         //Create a temp valid module structure (course,id)
         $tempmod->course = $this->course->id;