From 6cafc73db1fa7a3315b9cb838995d269db967050 Mon Sep 17 00:00:00 2001 From: toyomoyo Date: Fri, 10 Mar 2006 06:49:39 +0000 Subject: [PATCH] blog menu block (code is in development) --- blocks/blog_menu/block_blog_menu.php | 99 ++++++++++++++++++++++++++++ 1 file changed, 99 insertions(+) create mode 100755 blocks/blog_menu/block_blog_menu.php diff --git a/blocks/blog_menu/block_blog_menu.php b/blocks/blog_menu/block_blog_menu.php new file mode 100755 index 0000000000..32e6d94398 --- /dev/null +++ b/blocks/blog_menu/block_blog_menu.php @@ -0,0 +1,99 @@ +title = get_string('blockmenutitle', 'blog'); + $this->content_type = BLOCK_TYPE_TEXT; + $this->version = 2004112000; + } + + function get_content() { + global $CFG, $course; + + if ($CFG->bloglevel < 1) { + $this->content->text = ''; + return $this->content; + } + + if ($CFG->bloglevel < 5 && !isstudent($course->id) && !isteacher($course->id)) { + $this->content->text = ''; + return $this->content; + } + + if (!isset($userBlog)) { + $userBlog ->userid = 0; + } + + global $CFG, $USER, $course; + if (isset($USER->id)) { + $userBlog->userid = $USER->id; + } //what is $userBlog anyway + if($this->content !== NULL) { + return $this->content; + } + + $output = ''; + + $this->content = new stdClass; + $this->content->footer = ''; + if (empty($this->instance) /*|| empty($CFG->blog_version)*/) { + // Either we're being asked for content without + // an associated instance of the Blog module has never been installed. + $this->content->text = $output; + return $this->content; + } + + require_once($CFG->dirroot .'/blog/lib.php'); + + //if ( blog_isLoggedIn() && !isguest() ) { + $courseviewlink = ''; + $addentrylink = ''; + + $coursearg = ''; + if(isset($course) && isset($course->id) && $course->id !=0 && $course->id!=SITEID && $CFG->bloglevel >=3 ) { + $coursearg = '&courseid='. $course->id; + // a course is specified + + $courseviewlink = ''; + $courseviewlink .= get_string('viewcourseentries', 'blog') .'
'; + } + + $blogmodon = false; + if (isset($CFG->blog_enable_moderation) && $CFG->blog_enable_moderation) { + // blog moderation is enabled + $blogmodon = true; + } + if ((isadmin() || !$blogmodon || ($blogmodon && $coursearg != '')) && $CFG->bloglevel >= 1) { + // show Add entry link - user is not admin, moderation is off, or moderation is on and the user is viewing the block within the context of a course + $addentrylink = ''. get_string('addnewentry', 'blog') .'
'; + + // show View my entries link + $addentrylink .= ''; + $addentrylink .= get_string('viewmyentries', 'blog') .'
'; + // show link to manage blog prefs + $addentrylink .= ''. get_string('blogpreferences', 'blog') .'
'; + + $output = $addentrylink; + $output .= $courseviewlink; + + } + + // show View site entries link + if ($CFG->bloglevel >= 4) { + $output .= ''; + $output .= get_string('viewsiteentries', 'blog') .'
'; + } + + // show Help with blogging link + //$output .= ''; + //$output .= get_string('helpblogging', 'blog') .''; + //} else { + // $output = ''; //guest users and users who are not logged in do not get menus + //} + + $this->content->text = $output; + return $this->content; + } +} +?> -- 2.39.5