From: poltawski Date: Thu, 6 Dec 2007 15:43:46 +0000 (+0000) Subject: MDL-12464 - if a glossary is deleted, it causes some breakage in the X-Git-Url: http://git.mjollnir.org/gw?a=commitdiff_plain;h=f9192b65388484251112bf73b610140489a4df78;p=moodle.git MDL-12464 - if a glossary is deleted, it causes some breakage in the random glossary block Merged from MOODLE_19_STABLE --- diff --git a/blocks/glossary_random/block_glossary_random.php b/blocks/glossary_random/block_glossary_random.php index 315e83014b..b14453761f 100644 --- a/blocks/glossary_random/block_glossary_random.php +++ b/blocks/glossary_random/block_glossary_random.php @@ -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;