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
= 2004112000;
13 function get_content() {
16 if (!isset($course)) {
20 if (empty($CFG->bloglevel
)) {
21 $this->content
->text
= '';
22 return $this->content
;
25 // don't display menu block if block is set at site level, and user is not logged in
26 if ($CFG->bloglevel
< BLOG_GLOBAL_LEVEL
&& !(isloggedin() && !isguest())) {
27 $this->content
->text
= '';
28 return $this->content
;
31 if (!isset($userBlog)) {
32 $userBlog ->userid
= 0;
35 global $CFG, $USER, $course;
36 if (!empty($USER->id
)) {
37 $userBlog->userid
= $USER->id
;
38 } //what is $userBlog anyway
39 if($this->content
!== NULL) {
40 return $this->content
;
45 $this->content
= new stdClass
;
46 $this->content
->footer
= '';
47 if (empty($this->instance
) /*|| empty($CFG->blog_version)*/) {
48 // Either we're being asked for content without
49 // an associated instance of the Blog module has never been installed.
50 $this->content
->text
= $output;
51 return $this->content
;
54 //if ( blog_isLoggedIn() && !isguest() ) {
59 $sitecontext = get_context_instance(CONTEXT_SYSTEM
, SITEID
);
61 if (isset($course) && isset($course->id
)
62 && $course->id
!= 0 && $course->id
!= SITEID
) {
64 $incoursecontext = true;
65 $curcontext = get_context_instance(CONTEXT_COURSE
, $course->id
);
67 $incoursecontext = false;
68 $curcontext = $sitecontext;
71 $canviewblogs = has_capability('moodle/blog:view', $curcontext);
73 /// Accessibility: markup as a list.
75 if ( (isloggedin() && !isguest()) && $incoursecontext
76 && $CFG->bloglevel
>= BLOG_COURSE_LEVEL
&& $canviewblogs) {
78 $coursearg = '&courseid='.$course->id
;
79 // a course is specified
81 $courseviewlink = '<li><a href="'. $CFG->wwwroot
.'/blog/index.php?filtertype=course&filterselect='. $course->id
.'">';
82 $courseviewlink .= get_string('viewcourseentries', 'blog') ."</a></li>\n";
87 if ( (isloggedin() && !isguest())
88 && (!$blogmodon ||
($blogmodon && $coursearg != ''))
89 && $CFG->bloglevel
>= BLOG_USER_LEVEL
) {
91 // show Add entry link
92 if (has_capability('moodle/blog:create', $sitecontext)) {
93 $addentrylink = '<li><a href="'. $CFG->wwwroot
. '/blog/edit.php?action=add'
94 .$coursearg.'">'.get_string('addnewentry', 'blog') ."</a></li>\n";
96 // show View my entries link
97 $addentrylink .= '<li><a href="'. $CFG->wwwroot
.'/blog/index.php?userid='.
98 $userBlog->userid
.'">'.get_string('viewmyentries', 'blog').
101 // show link to manage blog prefs
102 $addentrylink .= '<li><a href="'. $CFG->wwwroot
. '/blog/preferences.php?userid='.
103 $userBlog->userid
. $coursearg .'">'.
104 get_string('blogpreferences', 'blog')."</a></li>\n";
106 $output = $addentrylink;
107 $output .= $courseviewlink;
110 // show View site entries link
111 if ($CFG->bloglevel
>= BLOG_SITE_LEVEL
&& $canviewblogs) {
112 $output .= '<li><a href="'. $CFG->wwwroot
.'/blog/index.php?filtertype=site&">';
113 $output .= get_string('viewsiteentries', 'blog')."</a></li>\n";
116 if (has_capability('moodle/blog:manageofficialtags', $sitecontext)
117 or has_capability('moodle/blog:managepersonaltags', $sitecontext)
118 or has_capability('moodle/blog:create', $sitecontext)) {
120 $output .= '<li>'. link_to_popup_window("/blog/tags.php",'popup',get_string('tagmanagement'), 400, 500, 'Popup window', 'none', true) ."</li>\n";
123 // show Help with blogging link
124 //$output .= '<li><a href="'. $CFG->wwwroot .'/help.php?module=blog&file=user.html">';
125 //$output .= get_string('helpblogging', 'blog') ."</a></li>\n";
127 // $output = ''; //guest users and users who are not logged in do not get menus
130 $this->content
->text
= '<ul class="list">'. $output ."</ul>\n";
131 return $this->content
;