MDL-12464 - if a glossary is deleted, it causes some breakage in the
random glossary entry block
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user