diff --git a/blocks/section_links/block_section_links.php b/blocks/section_links/block_section_links.php index 391091392be..4ce0aeabba2 100644 --- a/blocks/section_links/block_section_links.php +++ b/blocks/section_links/block_section_links.php @@ -4,7 +4,7 @@ class block_section_links extends block_base { function init() { $this->title = get_string('blockname', 'block_section_links'); - $this->version = 2007101509; + $this->version = 2007101511; } function instance_config($instance) { @@ -31,6 +31,11 @@ class block_section_links extends block_base { global $CFG, $USER, $DB; $highlight = 0; + if(isset($this->config)){ + $config = $this->config; + } else{ + $config = get_config('blocks/section_links'); + } if ($this->content !== NULL) { return $this->content; @@ -58,11 +63,21 @@ class block_section_links extends block_base { $sectionname = 'topic'; } $inc = 1; - if ($course->numsections > 22) { - $inc = 2; + + if(!empty($config->numsections1) and ($course->numsections > $config->numsections1)) { + $inc = $config->incby1; + } else { + if ($course->numsections > 22) { + $inc = 2; + } } - if ($course->numsections > 40) { - $inc = 5; + + if(!empty($config->numsections2) and ($course->numsections > $config->numsections2)) { + $inc = $config->incby1; + } else { + if ($course->numsections > 40) { + $inc = 5; + } } if (!empty($USER->id)) { @@ -110,6 +125,16 @@ class block_section_links extends block_base { $this->content->text = $text; return $this->content; } + /** + * Has instance config + * @return boolean + **/ + function instance_allow_config() { + return true; + } + function before_delete() { + delete_records('config_plugins', 'plugin', 'blocks/section_links'); + } } diff --git a/blocks/section_links/config_instance.html b/blocks/section_links/config_instance.html new file mode 100755 index 00000000000..069e22ee90c --- /dev/null +++ b/blocks/section_links/config_instance.html @@ -0,0 +1,73 @@ +config)){ + $config = $this->config; +} else{ + $config = get_config('blocks/section_links'); +} + +$selected = array(); +if (!empty($config->numsections1)) { + if (!empty($config->incby1)) { + $config->incby1 = 2; + } + $selected[1] = array($config->numsections1, $config->incby1); +} else { + $selected[1] = array(22, 2); +} + +if (!empty($config->numsections2)) { + if (!empty($config->incby1)) { + $config->incby1 = 5; + } + $selected[2] = array($config->numsections2, $config->incby2); +} else { + $selected[2] = array(40, 5); +} + +?> +
| + : + | ++ + | ++ + | +
| + : + | ++ + | ++ + | +
| + + + | +||