. /** * Blog Menu Block page. * * @package block_blog_menu * @copyright 2009 Nicolas Connault * @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later */ defined('MOODLE_INTERNAL') || die(); /** * The blog menu block class */ class block_blog_menu extends block_base { function init() { $this->title = get_string('pluginname', 'block_blog_menu'); } function instance_allow_multiple() { return true; } function has_config() { return false; } function applicable_formats() { return array('all' => true, 'my' => false, 'tag' => false); } function instance_allow_config() { return true; } function get_content() { global $CFG; // detect if blog enabled if ($this->content !== NULL) { return $this->content; } if (empty($CFG->enableblogs)) { $this->content = new stdClass(); $this->content->text = ''; if ($this->page->user_is_editing()) { $this->content->text = get_string('blogdisable', 'blog'); } return $this->content; } else if ($CFG->bloglevel < BLOG_GLOBAL_LEVEL and (!isloggedin() or isguestuser())) { $this->content = new stdClass(); $this->content->text = ''; return $this->content; } // require necessary libs and get content require_once($CFG->dirroot .'/blog/lib.php'); // Prep the content $this->content = new stdClass(); $options = blog_get_all_options($this->page); if (count($options) == 0) { $this->content->text = ''; return $this->content; } // Iterate the option types $menulist = array(); foreach ($options as $types) { foreach ($types as $link) { $menulist[] = html_writer::link($link['link'], $link['string']); } $menulist[] = '