3 require_once($CFG->dirroot
.'/blog/lib.php');
5 class block_blog_menu
extends block_base
{
8 $this->title
= get_string('blockmenutitle', 'blog');
9 $this->content_type
= BLOCK_TYPE_TEXT
;
10 $this->version
= 2007101509;
13 function get_content() {
14 global $CFG, $USER, $COURSE;
16 if (empty($CFG->bloglevel
)) {
17 $this->content
->text
= '';
18 return $this->content
;
21 // don't display menu block if block is set at site level, and user is not logged in
22 if ($CFG->bloglevel
< BLOG_GLOBAL_LEVEL
&& !(isloggedin() && !isguest())) {
23 $this->content
->text
= '';
24 return $this->content
;
27 if (!isset($userBlog)) {
28 $userBlog ->userid
= 0;
31 if (!empty($USER->id
)) {
32 $userBlog->userid
= $USER->id
;
33 } //what is $userBlog anyway
34 if($this->content
!== NULL) {
35 return $this->content
;
40 $this->content
= new stdClass
;
41 $this->content
->footer
= '';
42 if (empty($this->instance
) /*|| empty($CFG->blog_version)*/) {
43 // Either we're being asked for content without
44 // an associated instance of the Blog module has never been installed.
45 $this->content
->text
= $output;
46 return $this->content
;
49 //if ( blog_isLoggedIn() && !isguest() ) {
54 $sitecontext = get_context_instance(CONTEXT_SYSTEM
);
56 if ($COURSE->id
!= SITEID
) {
58 $incoursecontext = true;
59 $curcontext = get_context_instance(CONTEXT_COURSE
, $COURSE->id
);
61 $incoursecontext = false;
62 $curcontext = $sitecontext;
65 $canviewblogs = has_capability('moodle/blog:view', $curcontext);
67 /// Accessibility: markup as a list.
69 if ( (isloggedin() && !isguest()) && $incoursecontext
70 && $CFG->bloglevel
>= BLOG_COURSE_LEVEL
&& $canviewblogs) {
72 $coursearg = '&courseid='.$COURSE->id
;
73 // a course is specified
75 $courseviewlink = '<li><a href="'. $CFG->wwwroot
.'/blog/index.php?filtertype=course&filterselect='. $COURSE->id
.'">';
76 $courseviewlink .= get_string('viewcourseentries', 'blog') ."</a></li>\n";
81 if ( (isloggedin() && !isguest())
82 && (!$blogmodon ||
($blogmodon && $coursearg != ''))
83 && $CFG->bloglevel
>= BLOG_USER_LEVEL
) {
85 // show Add entry link
86 if (has_capability('moodle/blog:create', $sitecontext)) {
87 $addentrylink = '<li><a href="'. $CFG->wwwroot
. '/blog/edit.php?action=add'
88 .$coursearg.'">'.get_string('addnewentry', 'blog') ."</a></li>\n";
90 // show View my entries link
91 $addentrylink .= '<li><a href="'. $CFG->wwwroot
.'/blog/index.php?userid='.
92 $userBlog->userid
.'">'.get_string('viewmyentries', 'blog').
95 // show link to manage blog prefs
96 $addentrylink .= '<li><a href="'. $CFG->wwwroot
. '/blog/preferences.php?userid='.
97 $userBlog->userid
. $coursearg .'">'.
98 get_string('blogpreferences', 'blog')."</a></li>\n";
100 $output = $addentrylink;
101 $output .= $courseviewlink;
104 // show View site entries link
105 if ($CFG->bloglevel
>= BLOG_SITE_LEVEL
&& $canviewblogs) {
106 $output .= '<li><a href="'. $CFG->wwwroot
.'/blog/index.php?filtertype=site&">';
107 $output .= get_string('viewsiteentries', 'blog')."</a></li>\n";
110 // took out tag management interface/link, should use tag/manage.php
112 // show Help with blogging link
113 //$output .= '<li><a href="'. $CFG->wwwroot .'/help.php?module=blog&file=user.html">';
114 //$output .= get_string('helpblogging', 'blog') ."</a></li>\n";
116 // $output = ''; //guest users and users who are not logged in do not get menus
119 $this->content
->text
= '<ul class="list">'. $output ."</ul>\n";
120 return $this->content
;