Skip to content

Commit

Permalink
MDL-12464 - if a glossary is deleted, it causes some breakage in the
Browse files Browse the repository at this point in the history
random glossary block

Merged from MOODLE_19_STABLE
  • Loading branch information
poltawski committed Dec 6, 2007
1 parent 9776dba commit f9192b6
Showing 1 changed file with 15 additions and 2 deletions.
17 changes: 15 additions & 2 deletions blocks/glossary_random/block_glossary_random.php
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,21 @@ function get_content() {
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 = '';
}
Expand All @@ -173,8 +188,6 @@ function get_content() {
$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;
Expand Down

0 comments on commit f9192b6

Please sign in to comment.